C# Class Microsoft.Scripting.Utils.MathUtils

Show file Open project: jschementi/iron

Public Methods

Method Description
Abs ( this self ) : System.Numerics.BigInteger
Abs ( this self ) : double
AsInt32 ( this self, int &ret ) : bool
AsInt64 ( this self, long &ret ) : bool
BitLength ( BigInteger x ) : int
BitLength ( System.Numerics.BigInteger x ) : int
BitLength ( int x ) : int
BitLength ( long x ) : int
Conjugate ( this self ) : System.Numerics.Complex
Erf ( double v0 ) : double
ErfComplement ( double v0 ) : double
FloorDivideUnchecked ( int x, int y ) : int

Calculates the quotient of two 32-bit signed integers rounded towards negative infinity.

The caller must check for overflow (x = Int32.MinValue, y = -1)

FloorDivideUnchecked ( long x, long y ) : long

Calculates the quotient of two 32-bit signed integers rounded towards negative infinity.

The caller must check for overflow (x = Int64.MinValue, y = -1)

FloorRemainder ( int x, int y ) : int

Calculates the remainder of floor division of two 32-bit signed integers.

FloorRemainder ( long x, long y ) : long

Calculates the remainder of floor division of two 32-bit signed integers.

Gamma ( double v0 ) : double
GetBitCount ( this self ) : int
GetByteCount ( this self ) : int
GetRandBits ( this generator, int bits ) : BigInteger
GetRandBits ( this generator, int bits ) : System.Numerics.BigInteger
GetWordCount ( this self ) : int
Hypot ( double x, double y ) : double
Imaginary ( this self ) : double
IsNegative ( this self ) : bool
IsNegativeZero ( double self ) : bool
IsPositive ( this self ) : bool
IsZero ( this self ) : bool
Log ( this self ) : double
Log ( this self, double baseValue ) : double
Log10 ( this self ) : double
LogGamma ( double v0 ) : double
MakeComplex ( double real, double imag ) : Complex64
MakeComplex ( double real, double imag ) : System.Numerics.Complex
MakeImaginary ( double imag ) : Complex64
MakeImaginary ( double imag ) : System.Numerics.Complex
MakeReal ( double real ) : Complex64
MakeReal ( double real ) : System.Numerics.Complex
ModPow ( this self, System.Numerics.BigInteger power, System.Numerics.BigInteger mod ) : System.Numerics.BigInteger
ModPow ( this self, int power, System.Numerics.BigInteger mod ) : System.Numerics.BigInteger
Pow ( this self, Complex64 power ) : Complex64
Pow ( this self, System.Numerics.Complex power ) : System.Numerics.Complex
Power ( this self, int exp ) : System.Numerics.BigInteger
Random ( this generator, BigInteger limit ) : BigInteger
Random ( this generator, System.Numerics.BigInteger limit ) : System.Numerics.BigInteger
RoundAwayFromZero ( double value ) : double

Behaves like Math.Round(value, MidpointRounding.AwayFromZero) Needed because CoreCLR doesn't support this particular overload of Math.Round

RoundAwayFromZero ( double value, int precision ) : double

Behaves like Math.Round(value, precision, MidpointRounding.AwayFromZero) However, it works correctly on negative precisions and cases where precision is outside of the [-15, 15] range. (This function is also needed because CoreCLR lacks this overload.)

ToFloat64 ( this self ) : double
ToString ( this self, int radix ) : string
TryToFloat64 ( this self, double &result ) : bool

Private Methods

Method Description
AbsSinPi ( double v0 ) : double

A numerically precise version of |sin(v0 * pi)|

AppendRadix ( uint rem, uint radix, char tmp, StringBuilder buf, bool leadingZeros, bool lowerCase ) : void
AsUInt32 ( this self, uint &ret ) : bool
AsUInt64 ( this self, ulong &ret ) : bool
BigIntegerToString ( uint d, int sign, int radix, bool lowerCase ) : string
BitLengthUnsigned ( uint x ) : int
BitLengthUnsigned ( ulong x ) : int
EvalPolynomial ( double v0, double coeffs ) : double

Evaluates a polynomial in v0 where the coefficients are ordered in increasing degree

EvalPolynomial ( double v0, double coeffs, bool reverse ) : double

Evaluates a polynomial in v0 where the coefficients are ordered in increasing degree if reverse is false, and increasing degree if reverse is true.

GammaRationalFunc ( double v0 ) : double

Take the quotient of the 2 polynomials forming the Lanczos approximation with N=13 and G=13.144565

GetHighestByte ( System.Numerics.BigInteger self, int &index, byte &byteArray ) : byte
GetPowerOf10 ( int precision ) : double
GetWord ( byte bytes, int start, int end ) : uint
GetWord ( this self, int index ) : uint
GetWords ( this self ) : uint[]
PositiveGamma ( double v0 ) : double

Computes the Gamma function on positive values, using the Lanczos approximation. Lanczos parameters are N=13 and G=13.144565.

PositiveLGamma ( double v0 ) : double

Computes the Log-Gamma function on positive values, using the Lanczos approximation. Lanczos parameters are N=13 and G=13.144565.

SinPi ( double v0 ) : double

A numerically precise version of sin(v0 * pi)

div ( uint n, int &nl, uint d ) : uint

Method Details

Abs() public static method

public static Abs ( this self ) : System.Numerics.BigInteger
self this
return System.Numerics.BigInteger

Abs() public static method

public static Abs ( this self ) : double
self this
return double

AsInt32() public static method

public static AsInt32 ( this self, int &ret ) : bool
self this
ret int
return bool

AsInt64() public static method

public static AsInt64 ( this self, long &ret ) : bool
self this
ret long
return bool

BitLength() public static method

public static BitLength ( BigInteger x ) : int
x Microsoft.Scripting.Math.BigInteger
return int

BitLength() public static method

public static BitLength ( System.Numerics.BigInteger x ) : int
x System.Numerics.BigInteger
return int

BitLength() public static method

public static BitLength ( int x ) : int
x int
return int

BitLength() public static method

public static BitLength ( long x ) : int
x long
return int

Conjugate() public static method

public static Conjugate ( this self ) : System.Numerics.Complex
self this
return System.Numerics.Complex

Erf() public static method

public static Erf ( double v0 ) : double
v0 double
return double

ErfComplement() public static method

public static ErfComplement ( double v0 ) : double
v0 double
return double

FloorDivideUnchecked() public static method

Calculates the quotient of two 32-bit signed integers rounded towards negative infinity.
The caller must check for overflow (x = Int32.MinValue, y = -1)
is 0.
public static FloorDivideUnchecked ( int x, int y ) : int
x int Dividend.
y int Divisor.
return int

FloorDivideUnchecked() public static method

Calculates the quotient of two 32-bit signed integers rounded towards negative infinity.
The caller must check for overflow (x = Int64.MinValue, y = -1)
is 0.
public static FloorDivideUnchecked ( long x, long y ) : long
x long Dividend.
y long Divisor.
return long

FloorRemainder() public static method

Calculates the remainder of floor division of two 32-bit signed integers.
is 0.
public static FloorRemainder ( int x, int y ) : int
x int Dividend.
y int Divisor.
return int

FloorRemainder() public static method

Calculates the remainder of floor division of two 32-bit signed integers.
is 0.
public static FloorRemainder ( long x, long y ) : long
x long Dividend.
y long Divisor.
return long

Gamma() public static method

public static Gamma ( double v0 ) : double
v0 double
return double

GetBitCount() public static method

public static GetBitCount ( this self ) : int
self this
return int

GetByteCount() public static method

public static GetByteCount ( this self ) : int
self this
return int

GetRandBits() public static method

public static GetRandBits ( this generator, int bits ) : BigInteger
generator this
bits int
return Microsoft.Scripting.Math.BigInteger

GetRandBits() public static method

public static GetRandBits ( this generator, int bits ) : System.Numerics.BigInteger
generator this
bits int
return System.Numerics.BigInteger

GetWordCount() public static method

public static GetWordCount ( this self ) : int
self this
return int

Hypot() public static method

public static Hypot ( double x, double y ) : double
x double
y double
return double

Imaginary() public static method

public static Imaginary ( this self ) : double
self this
return double

IsNegative() public static method

public static IsNegative ( this self ) : bool
self this
return bool

IsNegativeZero() public static method

public static IsNegativeZero ( double self ) : bool
self double
return bool

IsPositive() public static method

public static IsPositive ( this self ) : bool
self this
return bool

IsZero() public static method

public static IsZero ( this self ) : bool
self this
return bool

Log() public static method

public static Log ( this self ) : double
self this
return double

Log() public static method

public static Log ( this self, double baseValue ) : double
self this
baseValue double
return double

Log10() public static method

public static Log10 ( this self ) : double
self this
return double

LogGamma() public static method

public static LogGamma ( double v0 ) : double
v0 double
return double

MakeComplex() public static method

public static MakeComplex ( double real, double imag ) : Complex64
real double
imag double
return Microsoft.Scripting.Math.Complex64

MakeComplex() public static method

public static MakeComplex ( double real, double imag ) : System.Numerics.Complex
real double
imag double
return System.Numerics.Complex

MakeImaginary() public static method

public static MakeImaginary ( double imag ) : Complex64
imag double
return Microsoft.Scripting.Math.Complex64

MakeImaginary() public static method

public static MakeImaginary ( double imag ) : System.Numerics.Complex
imag double
return System.Numerics.Complex

MakeReal() public static method

public static MakeReal ( double real ) : Complex64
real double
return Microsoft.Scripting.Math.Complex64

MakeReal() public static method

public static MakeReal ( double real ) : System.Numerics.Complex
real double
return System.Numerics.Complex

ModPow() public static method

public static ModPow ( this self, System.Numerics.BigInteger power, System.Numerics.BigInteger mod ) : System.Numerics.BigInteger
self this
power System.Numerics.BigInteger
mod System.Numerics.BigInteger
return System.Numerics.BigInteger

ModPow() public static method

public static ModPow ( this self, int power, System.Numerics.BigInteger mod ) : System.Numerics.BigInteger
self this
power int
mod System.Numerics.BigInteger
return System.Numerics.BigInteger

Pow() public static method

public static Pow ( this self, Complex64 power ) : Complex64
self this
power Microsoft.Scripting.Math.Complex64
return Microsoft.Scripting.Math.Complex64

Pow() public static method

public static Pow ( this self, System.Numerics.Complex power ) : System.Numerics.Complex
self this
power System.Numerics.Complex
return System.Numerics.Complex

Power() public static method

public static Power ( this self, int exp ) : System.Numerics.BigInteger
self this
exp int
return System.Numerics.BigInteger

Random() public static method

public static Random ( this generator, BigInteger limit ) : BigInteger
generator this
limit Microsoft.Scripting.Math.BigInteger
return Microsoft.Scripting.Math.BigInteger

Random() public static method

public static Random ( this generator, System.Numerics.BigInteger limit ) : System.Numerics.BigInteger
generator this
limit System.Numerics.BigInteger
return System.Numerics.BigInteger

RoundAwayFromZero() public static method

Behaves like Math.Round(value, MidpointRounding.AwayFromZero) Needed because CoreCLR doesn't support this particular overload of Math.Round
public static RoundAwayFromZero ( double value ) : double
value double
return double

RoundAwayFromZero() public static method

Behaves like Math.Round(value, precision, MidpointRounding.AwayFromZero) However, it works correctly on negative precisions and cases where precision is outside of the [-15, 15] range. (This function is also needed because CoreCLR lacks this overload.)
public static RoundAwayFromZero ( double value, int precision ) : double
value double
precision int
return double

ToFloat64() public static method

public static ToFloat64 ( this self ) : double
self this
return double

ToString() public static method

public static ToString ( this self, int radix ) : string
self this
radix int
return string

TryToFloat64() public static method

public static TryToFloat64 ( this self, double &result ) : bool
self this
result double
return bool