go2hx

manual

github

Module: stdgo.math.cmplx

(view library index)

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

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

(view code)

function _cAlike

function _cAlike(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128):Bool

(view code)

function _cSoclose

function _cSoclose(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128, _e:stdgo.GoFloat64):Bool

(view code)

function _cTolerance

function _cTolerance(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128, _e:stdgo.GoFloat64):Bool

(view code)

function _cVeryclose

function _cVeryclose(_a:stdgo.GoComplex128, _b:stdgo.GoComplex128):Bool

(view code)

function _isExact

function _isExact(_x:stdgo.GoFloat64):Bool

(view code)

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.

(view code)

function _sinhcosh

function _sinhcosh(_x:stdgo.GoFloat64):{
	_1:stdgo.GoFloat64;
	_0:stdgo.GoFloat64;
}

calculate sinh and cosh.

(view code)

function _tanSeries

function _tanSeries(_z:stdgo.GoComplex128):stdgo.GoFloat64

Taylor series expansion for cosh(2y) - cos(2x)

(view code)

function _tolerance

function _tolerance(_a:stdgo.GoFloat64, _b:stdgo.GoFloat64, _e:stdgo.GoFloat64):Bool

functions borrowed from pkg/math/all_test.go

(view code)

function _veryclose

function _veryclose(_a:stdgo.GoFloat64, _b:stdgo.GoFloat64):Bool

(view code)

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)))));
    }

(view code)

function acos

function acos(_x:stdgo.GoComplex128):stdgo.GoComplex128

Acos returns the inverse cosine of x.

(view code)

function acosh

function acosh(_x:stdgo.GoComplex128):stdgo.GoComplex128

Acosh returns the inverse hyperbolic cosine of x.

(view code)

function asin

function asin(_x:stdgo.GoComplex128):stdgo.GoComplex128

Asin returns the inverse sine of x.

(view code)

function asinh

function asinh(_x:stdgo.GoComplex128):stdgo.GoComplex128

Asinh returns the inverse hyperbolic sine of x.

(view code)

function atan

function atan(_x:stdgo.GoComplex128):stdgo.GoComplex128

Atan returns the inverse tangent of x.

(view code)

function atanh

function atanh(_x:stdgo.GoComplex128):stdgo.GoComplex128

Atanh returns the inverse hyperbolic tangent of x.

(view code)

function benchmarkAbs

function benchmarkAbs(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkAcos

function benchmarkAcos(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkAcosh

function benchmarkAcosh(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkAsin

function benchmarkAsin(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkAsinh

function benchmarkAsinh(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkAtan

function benchmarkAtan(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkAtanh

function benchmarkAtanh(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkConj

function benchmarkConj(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkCos

function benchmarkCos(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkCosh

function benchmarkCosh(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkExp

function benchmarkExp(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkLog

function benchmarkLog(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkLog10

function benchmarkLog10(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkPhase

function benchmarkPhase(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkPolar

function benchmarkPolar(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkPow

function benchmarkPow(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkRect

function benchmarkRect(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkSin

function benchmarkSin(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkSinh

function benchmarkSinh(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkSqrt

function benchmarkSqrt(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkTan

function benchmarkTan(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkTanh

function benchmarkTanh(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function conj

function conj(_x:stdgo.GoComplex128):stdgo.GoComplex128

Conj returns the complex conjugate of x.

(view code)

function cos

function cos(_x:stdgo.GoComplex128):stdgo.GoComplex128

Cos returns the cosine of x.

(view code)

function cosh

function cosh(_x:stdgo.GoComplex128):stdgo.GoComplex128

Cosh returns the hyperbolic cosine of x.

(view code)

function cot

function cot(_x:stdgo.GoComplex128):stdgo.GoComplex128

Cot returns the cotangent of x.

(view code)

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))));
    }

(view code)

function inf

function inf():stdgo.GoComplex128

Inf returns a complex infinity, complex(+Inf, +Inf).

(view code)

function isInf

function isInf(_x:stdgo.GoComplex128):Bool

IsInf reports whether either real(x) or imag(x) is an infinity.

(view code)

function isNaN

function isNaN(_x:stdgo.GoComplex128):Bool

IsNaN reports whether either real(x) or imag(x) is NaN and neither is an infinity.

(view code)

function log

function log(_x:stdgo.GoComplex128):stdgo.GoComplex128

Log returns the natural logarithm of x.

(view code)

function log10

function log10(_x:stdgo.GoComplex128):stdgo.GoComplex128

Log10 returns the decimal logarithm of x.

(view code)

function naN

function naN():stdgo.GoComplex128

NaN returns a complex “not-a-number” value.

(view code)

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].

(view code)

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)));
    }

(view code)

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.

(view code)

function rect

function rect(_r:stdgo.GoFloat64, __952:stdgo.GoFloat64):stdgo.GoComplex128

Rect returns the complex number x with polar coordinates r, θ.

(view code)

function sin

function sin(_x:stdgo.GoComplex128):stdgo.GoComplex128

Sin returns the sine of x.

(view code)

function sinh

function sinh(_x:stdgo.GoComplex128):stdgo.GoComplex128

Sinh returns the hyperbolic sine of x.

(view code)

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).

(view code)

function tan

function tan(_x:stdgo.GoComplex128):stdgo.GoComplex128

Tan returns the tangent of x.

(view code)

function tanh

function tanh(_x:stdgo.GoComplex128):stdgo.GoComplex128

Tanh returns the hyperbolic tangent of x.

(view code)

function testAbs

function testAbs(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testAcos

function testAcos(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testAcosh

function testAcosh(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testAsin

function testAsin(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testAsinh

function testAsinh(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testAtan

function testAtan(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testAtanh

function testAtanh(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testConj

function testConj(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testCos

function testCos(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testCosh

function testCosh(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testExp

function testExp(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testInfiniteLoopIntanSeries

function testInfiniteLoopIntanSeries(_t:stdgo.Ref<stdgo.testing.T_>):Void

See issue 17577

(view code)

function testIsNaN

function testIsNaN(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testLog

function testLog(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testLog10

function testLog10(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testPolar

function testPolar(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testPow

function testPow(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testRect

function testRect(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testSin

function testSin(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testSinh

function testSinh(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testSqrt

function testSqrt(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testTan

function testTan(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testTanHuge

function testTanHuge(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testTanh

function testTanh(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

Typedefs

import stdgo.math.cmplx.*

typedef T__struct_0

typedef T__struct_0 = {
	_want:stdgo.GoComplex128;
	_in:stdgo.GoComplex128;
};