Class Tools
Set of mathematical tools.
Inheritance
Namespace: ISynergy.Framework.Mathematics.Common
Assembly: ISynergy.Framework.Mathematics.dll
Syntax
public static class Tools : object
Methods
View SourceAcosh(Double)
Returns the hyperbolic arc cosine of the specified value.
Declaration
public static double Acosh(double x)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x |
Returns
Type | Description |
---|---|
System.Double |
Angle(Point, Point)
Gets the displacement angle between two points.
Declaration
public static double Angle(Point previous, Point next)
Parameters
Type | Name | Description |
---|---|---|
Point | previous | |
Point | next |
Returns
Type | Description |
---|---|
System.Double |
Angle(Double, Double)
Gets the angle formed by the vector [x,y].
Declaration
public static double Angle(double x, double y)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | |
System.Double | y |
Returns
Type | Description |
---|---|
System.Double |
Angle(Single, Single)
Gets the angle formed by the vector [x,y].
Declaration
public static float Angle(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | |
System.Single | y |
Returns
Type | Description |
---|---|
System.Single |
Asinh(Double)
Returns the hyperbolic arc sine of the specified value.
Declaration
public static double Asinh(double d)
Parameters
Type | Name | Description |
---|---|---|
System.Double | d |
Returns
Type | Description |
---|---|
System.Double |
Atanh(Double)
Returns the hyperbolic arc tangent of the specified value.
Declaration
public static double Atanh(double d)
Parameters
Type | Name | Description |
---|---|---|
System.Double | d |
Returns
Type | Description |
---|---|
System.Double |
Direction(Point, Point)
Gets the displacement angle between two points, coded as an integer varying from 0 to 20.
Declaration
public static int Direction(Point previous, Point next)
Parameters
Type | Name | Description |
---|---|---|
Point | previous | |
Point | next |
Returns
Type | Description |
---|---|
System.Int32 |
FactorialPower(Int32, Int32)
Returns the factorial falling power of the specified value.
Declaration
public static int FactorialPower(int value, int degree)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | |
System.Int32 | degree |
Returns
Type | Description |
---|---|
System.Int32 |
GetDecimalCount(Decimal)
Get decimals behind comma.
Declaration
public static int GetDecimalCount(decimal value)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | value |
Returns
Type | Description |
---|---|
System.Int32 |
GetDecimalCount(Double)
Get decimals behind comma.
Declaration
public static int GetDecimalCount(double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value |
Returns
Type | Description |
---|---|
System.Int32 |
GreatestCommonDivisor(Int32, Int32)
Gets the greatest common divisor between two integers.
Declaration
public static int GreatestCommonDivisor(int a, int b)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | a | First value. |
System.Int32 | b | Second value. |
Returns
Type | Description |
---|---|
System.Int32 | The greatest common divisor. |
Hypotenuse(Decimal, Decimal)
Hypotenuse calculus without overflow/underflow
Declaration
public static decimal Hypotenuse(decimal a, decimal b)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | a | first value |
System.Decimal | b | second value |
Returns
Type | Description |
---|---|
System.Decimal | The hypotenuse Sqrt(a^2 + b^2) |
Hypotenuse(Double, Double)
Hypotenuse calculus without overflow/underflow
Declaration
public static double Hypotenuse(double a, double b)
Parameters
Type | Name | Description |
---|---|---|
System.Double | a | First value |
System.Double | b | Second value |
Returns
Type | Description |
---|---|
System.Double | The hypotenuse Sqrt(a^2 + b^2) |
Hypotenuse(Single, Single)
Hypotenuse calculus without overflow/underflow
Declaration
public static float Hypotenuse(float a, float b)
Parameters
Type | Name | Description |
---|---|---|
System.Single | a | first value |
System.Single | b | second value |
Returns
Type | Description |
---|---|
System.Single | The hypotenuse Sqrt(a^2 + b^2) |
Interpolate1D(Double, Double[], Double[], Double, Double)
Interpolates data using a piece-wise linear function.
Declaration
public static double Interpolate1D(double value, double[] x, double[] y, double lower, double upper)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The value to be calculated. |
System.Double[] | x | The input data points |
System.Double[] | y | The output data points |
System.Double | lower | The value to be returned for values before the first point in |
System.Double | upper | The value to be returned for values after the last point in |
Returns
Type | Description |
---|---|
System.Double | Computes the output for f(value) by using a piecewise linear
interpolation of the data points |
InvSqrt(Single)
Fast inverse floating-point square root.
Declaration
public static float InvSqrt(float f)
Parameters
Type | Name | Description |
---|---|---|
System.Single | f |
Returns
Type | Description |
---|---|
System.Single |
IsPowerOf2(Int32)
Checks if the specified integer is power of 2.
Declaration
public static bool IsPowerOf2(int x)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Integer number to check. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the specified number is power of 2. Otherwise returns false. |
Log2(Int32)
Get base of binary logarithm.
Declaration
public static int Log2(int x)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Source integer number. |
Returns
Type | Description |
---|---|
System.Int32 | Power of the number (base of binary logarithm). |
Max(Double, Double, Double)
Gets the maximum value among three values.
Declaration
public static double Max(double a, double b, double c)
Parameters
Type | Name | Description |
---|---|---|
System.Double | a | The first value |
System.Double | b | The second value |
System.Double | c | The third value |
Returns
Type | Description |
---|---|
System.Double | The maximum value among |
Min(Double, Double, Double)
Gets the minimum value among three values.
Declaration
public static double Min(double a, double b, double c)
Parameters
Type | Name | Description |
---|---|---|
System.Double | a | The first value |
System.Double | b | The second value |
System.Double | c | The third value |
Returns
Type | Description |
---|---|
System.Double | The minimum value among |
Mod(Double, Double)
Gets the proper modulus operation for a real value x and modulo m.
Declaration
public static double Mod(double x, double m)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | |
System.Double | m |
Returns
Type | Description |
---|---|
System.Double |
Mod(Int32, Int32)
Gets the proper modulus operation for an integer value x and modulo m.
Declaration
public static int Mod(int x, int m)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | |
System.Int32 | m |
Returns
Type | Description |
---|---|
System.Int32 |
NextPowerOf2(Int32)
Returns the next power of 2 after the input value x.
Declaration
public static int NextPowerOf2(int x)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Input value x. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the next power of 2 after the input value x. |
Pow2(Int32)
Calculates power of 2.
Declaration
public static int Pow2(int power)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | power | Power to raise in. |
Returns
Type | Description |
---|---|
System.Int32 | Returns specified power of 2 in the case if power is in the range of [0, 30]. Otherwise returns 0. |
PreviousPowerOf2(Int32)
Returns the previous power of 2 after the input value x.
Declaration
public static int PreviousPowerOf2(int x)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Input value x. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the previous power of 2 after the input value x. |
Sqrt(Decimal, Decimal)
Returns the square root of the specified
Declaration
public static decimal Sqrt(decimal x, decimal epsilon = 0.0M)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | x | |
System.Decimal | epsilon |
Returns
Type | Description |
---|---|
System.Decimal |
TruncatedPower(Double, Double)
Truncated power function.
Declaration
public static double TruncatedPower(double value, double degree)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | |
System.Double | degree |
Returns
Type | Description |
---|---|
System.Double |