Programming Reference for VirtualLab Fusion
2025.1
|
This class contains various mathematical functions and constants. More...
Static Public Member Functions | |
static double | Abs (this double number) |
Returns the absolute value of the double number. | |
static double | Cos (double d) |
Special cosine function as the Math.Cos function has problems with with large values (in .Net Framework 4.8) and with \(\cos\left(\frac{\pi}{2}\right)\) in general. | |
static double | DegreeToRadian (double degree) |
Convert Degree to Radian. | |
static List< int[]> | DrawAllSubsetsOfGivenSizeFromSetOfIndices (int subsetSize, int populationSize) |
Method for creating all possible subsets of a given size out of a set of indices. | |
static double | Factorial (int m) |
Calculates the factorial \(n!\). | |
static int | GetQuantizationLevel (double value, double minimumQuantizedValue, double maximumQuantizedValue, double quantizationDifference) |
Gets the quantization level on which a certain value lies. | |
static double | GetQuantizedValue (double value, double minimumQuantizedValue, double maximumQuantizedValue, double quantizationDifference) |
Gets the quantized value. | |
static double | IndexOfTriangleNumber (int number) |
The ith triangle number is i * (i+1) / 2 which we have solved for i to return the double index of the matching triangle number. For example this method returns 2.0 for 3 because 3 is the second triangle number. It returns 2.4 for 4 which means that 4 is above the second and below the third triangle number. | |
static void | InitQuantizationMinMaxRiser (double minimum, double maximum, int numberOfQuantizationLevels, out double minimumQuantizedValue, out double maximumQuantizedValue, out double quantizationDifference) |
Initializes a "Min-Max-Riser" quantization. | |
static void | InitQuantizationMinMaxTread (double minimum, double maximum, int numberOfQuantizationLevels, out double minimumQuantizedValue, out double maximumQuantizedValue, out double quantizationDifference) |
Initializes a "Min-Max-Tread" quantization. | |
static double | NumericDerivative (Func< double, double > function, double position, double epsilon=Globals.Epsilon) |
Calculates the numerical derivative of a function. | |
static double | Pow (double baseNumber, double exponent) |
Raises the double number to the given power. | |
static Complex | QuantizePoint (Complex point, int amplitudeLevels, int phaseLevels) |
Quantizes a value in the amplitude range \(0 \ldots 1\) and the phase range \(-\pi \ldots \pi\). The phase levels are calculated with the following formula: \(\frac{\pi}{2} - k \cdot \frac{\pi}{n}\). \(n\) is the number of phase levels, \(k = 0, \ldots, n-1\). | |
static Complex | QuantizePoint (Complex point, int amplitudeLevels, int phaseLevels, double factor) |
Quantizes a value in the amplitude range \(0 \ldots 1\) and the phase range \(-\pi \ldots \pi\). The phase levels are calculated with the following formula: \(\frac{\pi}{2} - k \cdot \frac{\pi}{n}\). \(n\) is the number of phase levels, \(k = 0, \ldots, n-1\). | |
static double | RadianToDegree (double radian) |
Convert Degree to Radian. | |
static double | RMS (LargeList< double > values, bool relativeToAverage=false, LargeList< double > weights=null) |
Calculates the RMS (root mean square) of the given value. | |
static double | RMS (LargeList< double > values, double average) |
Calculates the RMS (root mean square) of the given value with respect to the given average. | |
static double | RombergIntegral (RealFunctionWithSingleArgument f, double xmin, double xmax, int n) |
Computes the definite integral of the real function \(f\) in the range from xmin to xmax. Romberg integration with \(2^{(n-1)+1}\) equidistant function evaluations is used to this end. | |
static double | Sin (double d) |
Special sine function as the Math.Sin function has problems with large values (in .Net Framework 4.8) and with \(\sin\left(\pi\right)\) in general. | |
static int | SolveQuadraticEquation (double a2, double a1, double a0, out double x1, out double x2) |
Function solving the general quadratic equation \(0 = a_2 \cdot x^2 + a_1 \cdot x + a_0\) . | |
static double | SphericalPhase (VectorD position, double k, double radius, double signumZ, double signumKz) |
Calculates the phase of the spherical phase function on the position \(\boldsymbol{r}\). The spherical phase function is defined as \(f(\boldsymbol{r}) = \exp{(\text{signumZ} \cdot \text{signumKz} \cdot k \cdot a)}\) with \(a = \sqrt{(x^2 + y^2 + z^2)}\). | |
static VectorD | SphericalPhaseDerivative (VectorD position, double k, double radius, double signumZ, double signumKz) |
Calculates the first derivative of spherical phase function (not a complex number but just the phase value). The spherical phase function is defined as \(f(\boldsymbol{r}) = \exp{(signumZ * signumKz * k * a)}\) with \(a = \sqrt{(x^2 + y^2 + z^2)}\). | |
static Complex | SphericalPhaseFunction (VectorD position, double k, double radius, double signumZ, double signumKz) |
Calculates the value of a spherical phase function on the position \(\boldsymbol{r}\). The spherical phase function is defined as \(f(\boldsymbol{r}) = \exp{(\text{signumZ} \cdot \text{signumKz} \cdot k \cdot a)}\) with \(a = \sqrt{(x^2 + y^2 + z^2)}\). | |
static void | SymDefSolve (double[,] matr, ref double[] vect) |
Solves the linear system matr * x = vect by using the Cholesky decomposition of matr. | |
static double | Tan (double d) |
Special tangent function as the Math.Tan function has problems with \(\tan\left(\frac{\pi}{2}\right)\) and \(\tan\left(\pi\right)\). | |
static double | ToThePowerOf (this double baseNumber, double exponent) |
Raises the double number to the given power. | |
static int | TriangleNumber (int index) |
Calculates the ith triangle number which is i * (i+1) / 2. | |
Static Public Attributes | |
const double | HalfPi |
Constant value of \(\frac{\pi}{2}\). | |
const double | TwoPi |
Constant value of \(2 \cdot \pi\). | |
This class contains various mathematical functions and constants.
|
static |
Returns the absolute value of the double number.
number | The double number. |
|
static |
Special cosine function as the Math.Cos function has problems with with large values (in .Net Framework 4.8) and with \(\cos\left(\frac{\pi}{2}\right)\) in general.
d | The argument of the cosine. |
|
static |
Convert Degree to Radian.
degree | The angle in degree. |
|
static |
Method for creating all possible subsets of a given size out of a set of indices.
subsetSize | Size of the subses to draw. |
populationSize | Size of the (zero based) index set. So the highest index is populationSize - 1. |
|
static |
Calculates the factorial \(n!\).
m | Order of factorial to calculate: \(n\). |
|
static |
Gets the quantization level on which a certain value lies.
value | The value to quantize. |
minimumQuantizedValue | The value corresponding to the lowest quantization level. |
maximumQuantizedValue | The value corresponding to the highest quantization level. |
quantizationDifference | The difference between two consecutive quantization levels. |
|
static |
Gets the quantized value.
value | The value to quantize. |
minimumQuantizedValue | The value corresponding to the lowest quantization level. |
maximumQuantizedValue | The value corresponding to the highest quantization level. |
quantizationDifference | The difference between two consecutive quantization levels. |
|
static |
The ith triangle number is i * (i+1) / 2 which we have solved for i to return the double index of the matching triangle number. For example this method returns 2.0 for 3 because 3 is the second triangle number. It returns 2.4 for 4 which means that 4 is above the second and below the third triangle number.
number | The number for which the index of the matching triangle number is determined. |
System.ArgumentException | Number must be larger or equal than zero. |
|
static |
Initializes a "Min-Max-Riser" quantization.
minimum | The minimum of the value range to quantize. |
maximum | The maximum of the value range to quantize. |
numberOfQuantizationLevels | The number of quantization levels. |
minimumQuantizedValue | Out parameter to return the minimum quantized value. |
maximumQuantizedValue | Out parameter to return the maximum quantized value. |
quantizationDifference | Out parameter to return the difference between two consecutive quantization levels. |
|
static |
Initializes a "Min-Max-Tread" quantization.
minimum | The minimum of the value range to quantize. |
maximum | The maximum of the value range to quantize. |
numberOfQuantizationLevels | The number of quantization levels. |
minimumQuantizedValue | Out parameter to return the minimum quantized value. |
maximumQuantizedValue | Out parameter to return the maximum quantized value. |
quantizationDifference | Out parameter to return the difference between two consecutive quantization levels. |
|
static |
Calculates the numerical derivative of a function.
function | The function 𝑦 = f(𝑥). |
position | The position 𝑥 at which the derivative is calculated. |
epsilon | The numerical derivative is calculated by calculating the function values at two positions 𝑥 + ε and 𝑥 - ε. |
|
static |
Raises the double number to the given power.
baseNumber | The base. |
exponent | The exponent. |
Quantizes a value in the amplitude range \(0 \ldots 1\) and the phase range \(-\pi \ldots \pi\). The phase levels are calculated with the following formula: \(\frac{\pi}{2} - k \cdot \frac{\pi}{n}\). \(n\) is the number of phase levels, \(k = 0, \ldots, n-1\).
point | The complex value to quantize. |
amplitudeLevels | Number of amplitude levels. Zero means no quantization. |
phaseLevels | Number of phase levels. Zero means no quantization. |
|
static |
Quantizes a value in the amplitude range \(0 \ldots 1\) and the phase range \(-\pi \ldots \pi\). The phase levels are calculated with the following formula: \(\frac{\pi}{2} - k \cdot \frac{\pi}{n}\). \(n\) is the number of phase levels, \(k = 0, \ldots, n-1\).
point | The complex value to quantize. |
amplitudeLevels | Number of amplitude levels. Zero means no quantization. |
phaseLevels | Number of phase levels. Zero means no quantization. |
factor | The projection strength \(\lambda\). \(\lambda = 1\) means hard quantization and \(\lambda = 0\) means no quantization. Values of \(\lambda\) between 0 and 1 lead to soft quantization. The used formulas can be found in the quantization chapter of the manual. |
|
static |
Convert Degree to Radian.
radian | The angle in radian. |
|
static |
Calculates the RMS (root mean square) of the given value.
values | The list of values. |
relativeToAverage | If this optional parameter is set to true the RMS refers to the average value. Otherwise it refers to zero. |
weights | Optional list containing a weight per value. |
ArgumentException | RMS calculation: For every value there must be exactly one weight. |
|
static |
Calculates the RMS (root mean square) of the given value with respect to the given average.
values | The list of values. |
average | Optional average. Zero by default. |
|
static |
Computes the definite integral of the real function \(f\) in the range from xmin to xmax. Romberg integration with \(2^{(n-1)+1}\) equidistant function evaluations is used to this end.
f | Delegate of the real function \(f\) to integrate. |
xmin | Lower border of integration interval. |
xmax | Upper border of integration interval. |
n | Order of the method. 1 means trapezoidal, 2 means Simpson rule. |
|
static |
Special sine function as the Math.Sin function has problems with large values (in .Net Framework 4.8) and with \(\sin\left(\pi\right)\) in general.
d | The argument of the sine. |
|
static |
Function solving the general quadratic equation \(0 = a_2 \cdot x^2 + a_1 \cdot x + a_0\) .
a2 | Coefficient of quadratic term. |
a1 | Coefficient of linear term. |
a0 | Coefficient of constant term. |
x1 | Out parameter giving the solution if only one solution exists or the smaller of the two solutions. |
x2 | Out parameter giving the larger solution in case of two solutions. |
|
static |
Calculates the phase of the spherical phase function on the position \(\boldsymbol{r}\). The spherical phase function is defined as \(f(\boldsymbol{r}) = \exp{(\text{signumZ} \cdot \text{signumKz} \cdot k \cdot a)}\) with \(a = \sqrt{(x^2 + y^2 + z^2)}\).
position | Position \(\boldsymbol{r}\) spherical phase is to be calculated for. |
k | Absolute value of the wave vector \(k\). |
radius | Distance \(z\) from the source plane of the spherical phase function. |
signumZ | Sign of the spherical phase radius, i.e. is the definition plane before or behind the source. The product of signumZ and signumKz ( \(\operatorname{sgn}(z) \cdot \operatorname{sgn}(k_z)\)) determines if the phase is diverging or converging. |
signumKz | Sign of the z-component of the k-vector of the harmonic field, i.e. whether propagation in positive or negative z-direction is considered. The product of signumZ and signumKz ( \(\operatorname{sgn}(radius) \cdot \operatorname{sgn}(k_z)\)) determines if the phase is diverging or converging. |
|
static |
Calculates the first derivative of spherical phase function (not a complex number but just the phase value). The spherical phase function is defined as \(f(\boldsymbol{r}) = \exp{(signumZ * signumKz * k * a)}\) with \(a = \sqrt{(x^2 + y^2 + z^2)}\).
position | Position \(\boldsymbol{r}\) spherical phase is to be calculated for. |
k | Absolute value of the wave vector \(k\). |
radius | Distance \(z\) from the source plane of the spherical phase function. |
signumZ | Sign of the spherical phase radius, i.e. is the definition plane before or behind the source. The product of signumZ and signumKz ( \(\operatorname{sgn}(z) \cdot \operatorname{sgn}(k_z)\)) determines if the phase is diverging or converging. |
signumKz | Sign of the z-component of the k-vector of the harmonic field, i.e. whether propagation in positive or negative z-direction is considered. The product of signumZ and signumKz ( \(\operatorname{sgn}(radius) \cdot \operatorname{sgn}(k_z)\)) determines if the phase is diverging or converging. |
|
static |
Calculates the value of a spherical phase function on the position \(\boldsymbol{r}\). The spherical phase function is defined as \(f(\boldsymbol{r}) = \exp{(\text{signumZ} \cdot \text{signumKz} \cdot k \cdot a)}\) with \(a = \sqrt{(x^2 + y^2 + z^2)}\).
position | Position \(\boldsymbol{r}\) spherical phase is to be calculated for. |
k | Absolute value of the wave vector \(k\). |
radius | Distance \(z\) from the source plane of the spherical phase function. |
signumZ | Sign of the spherical phase radius, i.e. is the definition plane before or behind the source. The product of signumZ and signumKz ( \(\operatorname{sgn}(z) \cdot \operatorname{sgn}(k_z)\)) determines if the phase is diverging or converging. |
signumKz | Sign of the z-component of the k-vector of the harmonic field, i.e. whether propagation in positive or negative z-direction is considered. The product of signumZ and signumKz ( \(\operatorname{sgn}(radius) \cdot \operatorname{sgn}(k_z)\)) determines if the phase is diverging or converging. |
|
static |
Solves the linear system matr * x = vect by using the Cholesky decomposition of matr.
matr | A two dimensional coefficients matrix. The matrix must be symmetric and positive definite. |
vect | In the function call this parameter must contain the function values vector of the equation system. After the evaluation of the function this parameter contains the solution vector x. |
|
static |
Special tangent function as the Math.Tan function has problems with \(\tan\left(\frac{\pi}{2}\right)\) and \(\tan\left(\pi\right)\).
d | The argument of the tangent. |
|
static |
Raises the double number to the given power.
baseNumber | The base. |
exponent | The exponent. |
|
static |
Calculates the ith triangle number which is i * (i+1) / 2.
index | The index of the triangle number to calculate. |