Module: stdgo.math.cmplx
Overview
Package cmplx provides basic constants and mathematical functions for complex numbers. Special case handling conforms to the C99 standard Annex G IEC 60559-compatible complex arithmetic.
Index
-
function _alike(_a:stdgo.GoFloat64, _b:stdgo.GoFloat64):Bool
-
function _cAlike(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128):Bool
-
function _cSoclose(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128, _e:stdgo.GoFloat64):Bool
-
function _cTolerance(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128, _e:stdgo.GoFloat64):Bool
-
function _cVeryclose(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128):Bool
-
function _sinhcosh(_x:stdgo.GoFloat64):{ _1:stdgo.GoFloat64; _0:stdgo.GoFloat64; }
-
function _tolerance(_a:stdgo.GoFloat64, _b:stdgo.GoFloat64, _e:stdgo.GoFloat64):Bool
-
function _veryclose(_a:stdgo.GoFloat64, _b:stdgo.GoFloat64):Bool
-
function polar(_x:stdgo.GoComplex128):{ _1:stdgo.GoFloat64; _0:stdgo.GoFloat64; }
-
function pow(_x:stdgo.GoComplex128, _y:stdgo.GoComplex128):stdgo.GoComplex128
-
function rect(_r:stdgo.GoFloat64, __952:stdgo.GoFloat64):stdgo.GoComplex128
-
function testInfiniteLoopIntanSeries(_t:stdgo.Ref<stdgo.testing.T_>):Void
Examples
Variables
import stdgo.math.cmplx.Cmplx
var _abs:stdgo.Slice<stdgo.GoFloat64>
var _absSC:stdgo.Slice<stdgo.GoFloat64>
var _acos:stdgo.Slice<stdgo.GoComplex128>
var _acosSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _acosh:stdgo.Slice<stdgo.GoComplex128>
var _acoshSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _asin:stdgo.Slice<stdgo.GoComplex128>
var _asinSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _asinh:stdgo.Slice<stdgo.GoComplex128>
var _asinhSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _atan:stdgo.Slice<stdgo.GoComplex128>
var _atanSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _atanh:stdgo.Slice<stdgo.GoComplex128>
var _atanhSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _branchPoints:stdgo.Slice<stdgo.GoArray<stdgo.GoComplex128>>
var _conj:stdgo.Slice<stdgo.GoComplex128>
var _conjSC:stdgo.Slice<stdgo.GoComplex128>
var _cos:stdgo.Slice<stdgo.GoComplex128>
var _cosSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _cosh:stdgo.Slice<stdgo.GoComplex128>
var _coshSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _eps:stdgo.GoFloat64
var _exp:stdgo.Slice<stdgo.GoComplex128>
var _expSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _hugeIn:stdgo.Slice<stdgo.GoComplex128>
huge values along the real axis for testing reducePi in Tan
var _inf:stdgo.GoFloat64
special cases conform to C99 standard appendix G.6 Complex arithmetic
var _isNaNSC:stdgo.Slice<Bool>
var _log:stdgo.Slice<stdgo.GoComplex128>
var _log10:stdgo.Slice<stdgo.GoComplex128>
var _log10SC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _logSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _nan:stdgo.GoFloat64
special cases conform to C99 standard appendix G.6 Complex arithmetic
var _polar:stdgo.Slice<stdgo.math.cmplx.T_ff>
var _polarSC:stdgo.Slice<stdgo.math.cmplx.T_ff>
var _pow:stdgo.Slice<stdgo.GoComplex128>
var _powSC:stdgo.Slice<stdgo.GoComplex128>
var _sin:stdgo.Slice<stdgo.GoComplex128>
var _sinSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _sinh:stdgo.Slice<stdgo.GoComplex128>
var _sinhSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _sqrt:stdgo.Slice<stdgo.GoComplex128>
var _sqrtSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _tan:stdgo.Slice<stdgo.GoComplex128>
var _tanHuge:stdgo.Slice<stdgo.GoComplex128>
Results for tanHuge[i] calculated with https://github.com/robpike/ivy using 4096 bits of working precision.
var _tanSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _tanh:stdgo.Slice<stdgo.GoComplex128>
var _tanhSC:stdgo.Slice<stdgo.math.cmplx.T__struct_0>
var _vc:stdgo.Slice<stdgo.GoComplex128>
var _vc26:stdgo.Slice<stdgo.GoComplex128>
The higher-precision values in vc26 were used to derive the input arguments vc (see also comment below). For reference only (do not delete).
var _vcAbsSC:stdgo.Slice<stdgo.GoComplex128>
var _vcConjSC:stdgo.Slice<stdgo.GoComplex128>
var _vcIsNaNSC:stdgo.Slice<stdgo.GoComplex128>
var _vcPolarSC:stdgo.Slice<stdgo.GoComplex128>
var _vcPowSC:stdgo.Slice<stdgo.GoArray<stdgo.GoComplex128>>
var _zero:stdgo.GoFloat64
Functions
import stdgo.math.cmplx.Cmplx
function _alike
function _alike(_a:stdgo.GoFloat64, _b:stdgo.GoFloat64):Bool
function _cAlike
function _cAlike(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128):Bool
function _cSoclose
function _cSoclose(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128, _e:stdgo.GoFloat64):Bool
function _cTolerance
function _cTolerance(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128, _e:stdgo.GoFloat64):Bool
function _cVeryclose
function _cVeryclose(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128):Bool
function _isExact
function _isExact(_x:stdgo.GoFloat64):Bool
function _reducePi
function _reducePi(_x:stdgo.GoFloat64):stdgo.GoFloat64
reducePi reduces the input argument x to the range (-Pi/2, Pi/2]. x must be greater than or equal to 0. For small arguments it uses Cody-Waite reduction in 3 float64 parts based on: "Elementary Function Evaluation: Algorithms and Implementation" Jean-Michel Muller, 1997. For very large arguments it uses Payne-Hanek range reduction based on: "ARGUMENT REDUCTION FOR HUGE ARGUMENTS: Good to the Last Bit" K. C. Ng et al, March 24, 1992.
function _sinhcosh
function _sinhcosh(_x:stdgo.GoFloat64):{
_1:stdgo.GoFloat64;
_0:stdgo.GoFloat64;
}
calculate sinh and cosh.
function _tanSeries
function _tanSeries(_z:stdgo.GoComplex128):stdgo.GoFloat64
Taylor series expansion for cosh(2y) - cos(2x)
function _tolerance
function _tolerance(_a:stdgo.GoFloat64, _b:stdgo.GoFloat64, _e:stdgo.GoFloat64):Bool
functions borrowed from pkg/math/all_test.go
function _veryclose
function _veryclose(_a:stdgo.GoFloat64, _b:stdgo.GoFloat64):Bool
function abs
function abs(_x:stdgo.GoComplex128):stdgo.GoFloat64
Abs returns the absolute value (also called the modulus) of x.
exampleAbs
function exampleAbs():Void {
stdgo.fmt.Fmt.printf(("%.1f" : stdgo.GoString), stdgo.Go.toInterface(stdgo.math.cmplx.Cmplx.abs(((3f64 : stdgo.GoFloat64) + new stdgo.GoComplex128(0f64, 4f64)))));
}
function acos
function acos(_x:stdgo.GoComplex128):stdgo.GoComplex128
Acos returns the inverse cosine of x.
function acosh
function acosh(_x:stdgo.GoComplex128):stdgo.GoComplex128
Acosh returns the inverse hyperbolic cosine of x.
function asin
function asin(_x:stdgo.GoComplex128):stdgo.GoComplex128
Asin returns the inverse sine of x.
function asinh
function asinh(_x:stdgo.GoComplex128):stdgo.GoComplex128
Asinh returns the inverse hyperbolic sine of x.
function atan
function atan(_x:stdgo.GoComplex128):stdgo.GoComplex128
Atan returns the inverse tangent of x.
function atanh
function atanh(_x:stdgo.GoComplex128):stdgo.GoComplex128
Atanh returns the inverse hyperbolic tangent of x.
function benchmarkAbs
function benchmarkAbs(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkAcos
function benchmarkAcos(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkAcosh
function benchmarkAcosh(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkAsin
function benchmarkAsin(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkAsinh
function benchmarkAsinh(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkAtan
function benchmarkAtan(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkAtanh
function benchmarkAtanh(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkConj
function benchmarkConj(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkCos
function benchmarkCos(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkCosh
function benchmarkCosh(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkExp
function benchmarkExp(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkLog
function benchmarkLog(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkLog10
function benchmarkLog10(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkPhase
function benchmarkPhase(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkPolar
function benchmarkPolar(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkPow
function benchmarkPow(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkRect
function benchmarkRect(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkSin
function benchmarkSin(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkSinh
function benchmarkSinh(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkSqrt
function benchmarkSqrt(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkTan
function benchmarkTan(_b:stdgo.Ref<stdgo.testing.B>):Void
function benchmarkTanh
function benchmarkTanh(_b:stdgo.Ref<stdgo.testing.B>):Void
function conj
function conj(_x:stdgo.GoComplex128):stdgo.GoComplex128
Conj returns the complex conjugate of x.
function cos
function cos(_x:stdgo.GoComplex128):stdgo.GoComplex128
Cos returns the cosine of x.
function cosh
function cosh(_x:stdgo.GoComplex128):stdgo.GoComplex128
Cosh returns the hyperbolic cosine of x.
function cot
function cot(_x:stdgo.GoComplex128):stdgo.GoComplex128
Cot returns the cotangent of x.
function exp
function exp(_x:stdgo.GoComplex128):stdgo.GoComplex128
Exp returns e\\x, the base-e exponential of x.
exampleExp
function exampleExp():Void {
stdgo.fmt.Fmt.printf(("%.1f" : stdgo.GoString), stdgo.Go.toInterface(stdgo.math.cmplx.Cmplx.exp(((0f64 : stdgo.GoFloat64) + new stdgo.GoComplex128(0f64, 3.141592653589793f64))) + ((1f64 : stdgo.GoFloat64) + new stdgo.GoComplex128(0f64, 0f64))));
}
function inf
function inf():stdgo.GoComplex128
Inf returns a complex infinity, complex(+Inf, +Inf).
function isInf
function isInf(_x:stdgo.GoComplex128):Bool
IsInf reports whether either real(x) or imag(x) is an infinity.
function isNaN
function isNaN(_x:stdgo.GoComplex128):Bool
IsNaN reports whether either real(x) or imag(x) is NaN and neither is an infinity.
function log
function log(_x:stdgo.GoComplex128):stdgo.GoComplex128
Log returns the natural logarithm of x.
function log10
function log10(_x:stdgo.GoComplex128):stdgo.GoComplex128
Log10 returns the decimal logarithm of x.
function naN
function naN():stdgo.GoComplex128
NaN returns a complex “not-a-number” value.
function phase
function phase(_x:stdgo.GoComplex128):stdgo.GoFloat64
Phase returns the phase (also called the argument) of x. The returned value is in the range [-Pi, Pi].
function polar
function polar(_x:stdgo.GoComplex128):{
_1:stdgo.GoFloat64;
_0:stdgo.GoFloat64;
}
Polar returns the absolute value r and phase θ of x, such that x = r \ e\*θi. The phase is in the range [-Pi, Pi].
examplePolar
function examplePolar():Void {
var __tmp__ = stdgo.math.cmplx.Cmplx.polar(((0f64 : stdgo.GoFloat64) + new stdgo.GoComplex128(0f64, 2f64))), _r:stdgo.GoFloat64 = __tmp__._0, _theta:stdgo.GoFloat64 = __tmp__._1;
stdgo.fmt.Fmt.printf(("r: %.1f, θ: %.1f*π" : stdgo.GoString), stdgo.Go.toInterface(_r), stdgo.Go.toInterface(_theta / (3.141592653589793 : stdgo.GoFloat64)));
}
function pow
function pow(_x:stdgo.GoComplex128, _y:stdgo.GoComplex128):stdgo.GoComplex128
Pow returns x\\y, the base-x exponential of y. For generalized compatibility with math.Pow:
Pow(0, ±0) returns 1+0i
Pow(0, c) for real(c)<0 returns Inf+0i if imag(c) is zero, otherwise Inf+Inf i.
function rect
function rect(_r:stdgo.GoFloat64, __952:stdgo.GoFloat64):stdgo.GoComplex128
Rect returns the complex number x with polar coordinates r, θ.
function sin
function sin(_x:stdgo.GoComplex128):stdgo.GoComplex128
Sin returns the sine of x.
function sinh
function sinh(_x:stdgo.GoComplex128):stdgo.GoComplex128
Sinh returns the hyperbolic sine of x.
function sqrt
function sqrt(_x:stdgo.GoComplex128):stdgo.GoComplex128
Sqrt returns the square root of x. The result r is chosen so that real(r) ≥ 0 and imag(r) has the same sign as imag(x).
function tan
function tan(_x:stdgo.GoComplex128):stdgo.GoComplex128
Tan returns the tangent of x.
function tanh
function tanh(_x:stdgo.GoComplex128):stdgo.GoComplex128
Tanh returns the hyperbolic tangent of x.
function testAbs
function testAbs(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testAcos
function testAcos(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testAcosh
function testAcosh(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testAsin
function testAsin(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testAsinh
function testAsinh(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testAtan
function testAtan(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testAtanh
function testAtanh(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testConj
function testConj(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testCos
function testCos(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testCosh
function testCosh(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testExp
function testExp(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testInfiniteLoopIntanSeries
function testInfiniteLoopIntanSeries(_t:stdgo.Ref<stdgo.testing.T_>):Void
See issue 17577
function testIsNaN
function testIsNaN(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testLog
function testLog(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testLog10
function testLog10(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testPolar
function testPolar(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testPow
function testPow(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testRect
function testRect(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testSin
function testSin(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testSinh
function testSinh(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testSqrt
function testSqrt(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testTan
function testTan(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testTanHuge
function testTanHuge(_t:stdgo.Ref<stdgo.testing.T_>):Void
function testTanh
function testTanh(_t:stdgo.Ref<stdgo.testing.T_>):Void
Typedefs
import stdgo.math.cmplx.*
typedef T__struct_0
typedef T__struct_0 = {
_want:stdgo.GoComplex128;
_in:stdgo.GoComplex128;
};