You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

646 lines
18 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>cmplx - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package cmplx</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "math/cmplx"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. </dl>
  58. </div>
  59. <!-- The package's Name is printed as title by the top-level template -->
  60. <div id="pkg-overview" class="toggleVisible">
  61. <div class="collapsed">
  62. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  63. </div>
  64. <div class="expanded">
  65. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  66. <p>
  67. Package cmplx provides basic constants and mathematical functions for
  68. complex numbers.
  69. </p>
  70. </div>
  71. </div>
  72. <div id="pkg-index" class="toggleVisible">
  73. <div class="collapsed">
  74. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  75. </div>
  76. <div class="expanded">
  77. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  78. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  79. <div id="manual-nav">
  80. <dl>
  81. <dd><a href="index.html#Abs">func Abs(x complex128) float64</a></dd>
  82. <dd><a href="index.html#Acos">func Acos(x complex128) complex128</a></dd>
  83. <dd><a href="index.html#Acosh">func Acosh(x complex128) complex128</a></dd>
  84. <dd><a href="index.html#Asin">func Asin(x complex128) complex128</a></dd>
  85. <dd><a href="index.html#Asinh">func Asinh(x complex128) complex128</a></dd>
  86. <dd><a href="index.html#Atan">func Atan(x complex128) complex128</a></dd>
  87. <dd><a href="index.html#Atanh">func Atanh(x complex128) complex128</a></dd>
  88. <dd><a href="index.html#Conj">func Conj(x complex128) complex128</a></dd>
  89. <dd><a href="index.html#Cos">func Cos(x complex128) complex128</a></dd>
  90. <dd><a href="index.html#Cosh">func Cosh(x complex128) complex128</a></dd>
  91. <dd><a href="index.html#Cot">func Cot(x complex128) complex128</a></dd>
  92. <dd><a href="index.html#Exp">func Exp(x complex128) complex128</a></dd>
  93. <dd><a href="index.html#Inf">func Inf() complex128</a></dd>
  94. <dd><a href="index.html#IsInf">func IsInf(x complex128) bool</a></dd>
  95. <dd><a href="index.html#IsNaN">func IsNaN(x complex128) bool</a></dd>
  96. <dd><a href="index.html#Log">func Log(x complex128) complex128</a></dd>
  97. <dd><a href="index.html#Log10">func Log10(x complex128) complex128</a></dd>
  98. <dd><a href="index.html#NaN">func NaN() complex128</a></dd>
  99. <dd><a href="index.html#Phase">func Phase(x complex128) float64</a></dd>
  100. <dd><a href="index.html#Polar">func Polar(x complex128) (r, θ float64)</a></dd>
  101. <dd><a href="index.html#Pow">func Pow(x, y complex128) complex128</a></dd>
  102. <dd><a href="index.html#Rect">func Rect(r, θ float64) complex128</a></dd>
  103. <dd><a href="index.html#Sin">func Sin(x complex128) complex128</a></dd>
  104. <dd><a href="index.html#Sinh">func Sinh(x complex128) complex128</a></dd>
  105. <dd><a href="index.html#Sqrt">func Sqrt(x complex128) complex128</a></dd>
  106. <dd><a href="index.html#Tan">func Tan(x complex128) complex128</a></dd>
  107. <dd><a href="index.html#Tanh">func Tanh(x complex128) complex128</a></dd>
  108. </dl>
  109. </div><!-- #manual-nav -->
  110. <h4>Package files</h4>
  111. <p>
  112. <span style="font-size:90%">
  113. <a href="http://localhost:6060/src/math/cmplx/abs.go">abs.go</a>
  114. <a href="http://localhost:6060/src/math/cmplx/asin.go">asin.go</a>
  115. <a href="http://localhost:6060/src/math/cmplx/conj.go">conj.go</a>
  116. <a href="http://localhost:6060/src/math/cmplx/exp.go">exp.go</a>
  117. <a href="http://localhost:6060/src/math/cmplx/isinf.go">isinf.go</a>
  118. <a href="http://localhost:6060/src/math/cmplx/isnan.go">isnan.go</a>
  119. <a href="http://localhost:6060/src/math/cmplx/log.go">log.go</a>
  120. <a href="http://localhost:6060/src/math/cmplx/phase.go">phase.go</a>
  121. <a href="http://localhost:6060/src/math/cmplx/polar.go">polar.go</a>
  122. <a href="http://localhost:6060/src/math/cmplx/pow.go">pow.go</a>
  123. <a href="http://localhost:6060/src/math/cmplx/rect.go">rect.go</a>
  124. <a href="http://localhost:6060/src/math/cmplx/sin.go">sin.go</a>
  125. <a href="http://localhost:6060/src/math/cmplx/sqrt.go">sqrt.go</a>
  126. <a href="http://localhost:6060/src/math/cmplx/tan.go">tan.go</a>
  127. </span>
  128. </p>
  129. </div><!-- .expanded -->
  130. </div><!-- #pkg-index -->
  131. <div id="pkg-callgraph" class="toggle" style="display: none">
  132. <div class="collapsed">
  133. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  134. </div> <!-- .expanded -->
  135. <div class="expanded">
  136. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  137. <p>
  138. In the call graph viewer below, each node
  139. is a function belonging to this package
  140. and its children are the functions it
  141. calls&mdash;perhaps dynamically.
  142. </p>
  143. <p>
  144. The root nodes are the entry points of the
  145. package: functions that may be called from
  146. outside the package.
  147. There may be non-exported or anonymous
  148. functions among them if they are called
  149. dynamically from another package.
  150. </p>
  151. <p>
  152. Click a node to visit that function's source code.
  153. From there you can visit its callers by
  154. clicking its declaring <code>func</code>
  155. token.
  156. </p>
  157. <p>
  158. Functions may be omitted if they were
  159. determined to be unreachable in the
  160. particular programs or tests that were
  161. analyzed.
  162. </p>
  163. <!-- Zero means show all package entry points. -->
  164. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  165. </div>
  166. </div> <!-- #pkg-callgraph -->
  167. <h2 id="Abs">func <a href="http://localhost:6060/src/math/cmplx/abs.go?s=349:379#L2">Abs</a></h2>
  168. <pre>func Abs(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#float64">float64</a></pre>
  169. <p>
  170. Abs returns the absolute value (also called the modulus) of x.
  171. </p>
  172. <h2 id="Acos">func <a href="http://localhost:6060/src/math/cmplx/asin.go?s=2849:2883#L84">Acos</a></h2>
  173. <pre>func Acos(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  174. <p>
  175. Acos returns the inverse cosine of x.
  176. </p>
  177. <h2 id="Acosh">func <a href="http://localhost:6060/src/math/cmplx/asin.go?s=3001:3036#L90">Acosh</a></h2>
  178. <pre>func Acosh(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  179. <p>
  180. Acosh returns the inverse hyperbolic cosine of x.
  181. </p>
  182. <h2 id="Asin">func <a href="http://localhost:6060/src/math/cmplx/asin.go?s=1687:1721#L41">Asin</a></h2>
  183. <pre>func Asin(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  184. <p>
  185. Asin returns the inverse sine of x.
  186. </p>
  187. <h2 id="Asinh">func <a href="http://localhost:6060/src/math/cmplx/asin.go?s=2150:2185#L57">Asinh</a></h2>
  188. <pre>func Asinh(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  189. <p>
  190. Asinh returns the inverse hyperbolic sine of x.
  191. </p>
  192. <h2 id="Atan">func <a href="http://localhost:6060/src/math/cmplx/asin.go?s=4064:4098#L132">Atan</a></h2>
  193. <pre>func Atan(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  194. <p>
  195. Atan returns the inverse tangent of x.
  196. </p>
  197. <h2 id="Atanh">func <a href="http://localhost:6060/src/math/cmplx/asin.go?s=4492:4527#L156">Atanh</a></h2>
  198. <pre>func Atanh(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  199. <p>
  200. Atanh returns the inverse hyperbolic tangent of x.
  201. </p>
  202. <h2 id="Conj">func <a href="http://localhost:6060/src/math/cmplx/conj.go?s=219:253#L1">Conj</a></h2>
  203. <pre>func Conj(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  204. <p>
  205. Conj returns the complex conjugate of x.
  206. </p>
  207. <h2 id="Cos">func <a href="http://localhost:6060/src/math/cmplx/sin.go?s=2612:2645#L88">Cos</a></h2>
  208. <pre>func Cos(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  209. <p>
  210. Cos returns the cosine of x.
  211. </p>
  212. <h2 id="Cosh">func <a href="http://localhost:6060/src/math/cmplx/sin.go?s=3059:3093#L107">Cosh</a></h2>
  213. <pre>func Cosh(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  214. <p>
  215. Cosh returns the hyperbolic cosine of x.
  216. </p>
  217. <h2 id="Cot">func <a href="http://localhost:6060/src/math/cmplx/tan.go?s=4220:4253#L165">Cot</a></h2>
  218. <pre>func Cot(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  219. <p>
  220. Cot returns the cotangent of x.
  221. </p>
  222. <h2 id="Exp">func <a href="http://localhost:6060/src/math/cmplx/exp.go?s=1624:1657#L41">Exp</a></h2>
  223. <pre>func Exp(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  224. <p>
  225. Exp returns e**x, the base-e exponential of x.
  226. </p>
  227. <h2 id="Inf">func <a href="http://localhost:6060/src/math/cmplx/isinf.go?s=434:455#L8">Inf</a></h2>
  228. <pre>func Inf() <a href="../../builtin/index.html#complex128">complex128</a></pre>
  229. <p>
  230. Inf returns a complex infinity, complex(+Inf, +Inf).
  231. </p>
  232. <h2 id="IsInf">func <a href="http://localhost:6060/src/math/cmplx/isinf.go?s=257:286#L1">IsInf</a></h2>
  233. <pre>func IsInf(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#bool">bool</a></pre>
  234. <p>
  235. IsInf returns true if either real(x) or imag(x) is an infinity.
  236. </p>
  237. <h2 id="IsNaN">func <a href="http://localhost:6060/src/math/cmplx/isnan.go?s=279:308#L1">IsNaN</a></h2>
  238. <pre>func IsNaN(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#bool">bool</a></pre>
  239. <p>
  240. IsNaN returns true if either real(x) or imag(x) is NaN
  241. and neither is an infinity.
  242. </p>
  243. <h2 id="Log">func <a href="http://localhost:6060/src/math/cmplx/log.go?s=1845:1878#L47">Log</a></h2>
  244. <pre>func Log(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  245. <p>
  246. Log returns the natural logarithm of x.
  247. </p>
  248. <h2 id="Log10">func <a href="http://localhost:6060/src/math/cmplx/log.go?s=1973:2008#L52">Log10</a></h2>
  249. <pre>func Log10(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  250. <p>
  251. Log10 returns the decimal logarithm of x.
  252. </p>
  253. <h2 id="NaN">func <a href="http://localhost:6060/src/math/cmplx/isnan.go?s=525:546#L12">NaN</a></h2>
  254. <pre>func NaN() <a href="../../builtin/index.html#complex128">complex128</a></pre>
  255. <p>
  256. NaN returns a complex &ldquo;not-a-number&rdquo; value.
  257. </p>
  258. <h2 id="Phase">func <a href="http://localhost:6060/src/math/cmplx/phase.go?s=299:331#L1">Phase</a></h2>
  259. <pre>func Phase(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#float64">float64</a></pre>
  260. <p>
  261. Phase returns the phase (also called the argument) of x.
  262. The returned value is in the range [-Pi, Pi].
  263. </p>
  264. <h2 id="Polar">func <a href="http://localhost:6060/src/math/cmplx/polar.go?s=301:341#L1">Polar</a></h2>
  265. <pre>func Polar(x <a href="../../builtin/index.html#complex128">complex128</a>) (r, θ <a href="../../builtin/index.html#float64">float64</a>)</pre>
  266. <p>
  267. Polar returns the absolute value r and phase θ of x,
  268. such that x = r * e**θi.
  269. The phase is in the range [-Pi, Pi].
  270. </p>
  271. <h2 id="Pow">func <a href="http://localhost:6060/src/math/cmplx/pow.go?s=1709:1745#L39">Pow</a></h2>
  272. <pre>func Pow(x, y <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  273. <p>
  274. Pow returns x**y, the base-x exponential of y.
  275. For generalized compatibility with math.Pow:
  276. </p>
  277. <pre>Pow(0, ±0) returns 1+0i
  278. Pow(0, c) for real(c)&lt;0 returns Inf+0i if imag(c) is zero, otherwise Inf+Inf i.
  279. </pre>
  280. <h2 id="Rect">func <a href="http://localhost:6060/src/math/cmplx/rect.go?s=257:292#L1">Rect</a></h2>
  281. <pre>func Rect(r, θ <a href="../../builtin/index.html#float64">float64</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  282. <p>
  283. Rect returns the complex number x with polar coordinates r, θ.
  284. </p>
  285. <h2 id="Sin">func <a href="http://localhost:6060/src/math/cmplx/sin.go?s=1600:1633#L43">Sin</a></h2>
  286. <pre>func Sin(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  287. <p>
  288. Sin returns the sine of x.
  289. </p>
  290. <h2 id="Sinh">func <a href="http://localhost:6060/src/math/cmplx/sin.go?s=2082:2116#L63">Sinh</a></h2>
  291. <pre>func Sinh(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  292. <p>
  293. Sinh returns the hyperbolic sine of x.
  294. </p>
  295. <h2 id="Sqrt">func <a href="http://localhost:6060/src/math/cmplx/sqrt.go?s=1929:1963#L48">Sqrt</a></h2>
  296. <pre>func Sqrt(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  297. <p>
  298. Sqrt returns the square root of x.
  299. The result r is chosen so that real(r) ≥ 0 and imag(r) has the same sign as imag(x).
  300. </p>
  301. <h2 id="Tan">func <a href="http://localhost:6060/src/math/cmplx/tan.go?s=1834:1867#L49">Tan</a></h2>
  302. <pre>func Tan(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  303. <p>
  304. Tan returns the tangent of x.
  305. </p>
  306. <h2 id="Tanh">func <a href="http://localhost:6060/src/math/cmplx/tan.go?s=2396:2430#L73">Tanh</a></h2>
  307. <pre>func Tanh(x <a href="../../builtin/index.html#complex128">complex128</a>) <a href="../../builtin/index.html#complex128">complex128</a></pre>
  308. <p>
  309. Tanh returns the hyperbolic tangent of x.
  310. </p>
  311. <div id="footer">
  312. Build version go1.6.<br>
  313. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  314. the content of this page is licensed under the
  315. Creative Commons Attribution 3.0 License,
  316. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  317. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  318. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  319. </div>
  320. </div><!-- .container -->
  321. </div><!-- #page -->
  322. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  323. <script type="text/javascript" src="../../../lib/godoc/jquery.js"></script>
  324. <script type="text/javascript" src="../../../lib/godoc/jquery.treeview.js"></script>
  325. <script type="text/javascript" src="../../../lib/godoc/jquery.treeview.edit.js"></script>
  326. <script type="text/javascript" src="../../../lib/godoc/godocs.js"></script>
  327. </body>
  328. </html>