Class ArrayMath
Utility class for simple vector arithmetic.
public static class ArrayMath
- Inheritance
-
ArrayMath
- Inherited Members
Methods
Argmax(double[])
Find index of maximum element in the vector x
public static int Argmax(double[] x)
Parameters
xdouble[]input vector
Returns
- int
index of the maximum element. Index of the first maximum element is returned if multiple maximums are found.
InnerProduct(double[], double[])
public static double InnerProduct(double[] vecA, double[] vecB)
Parameters
Returns
InvL2norm(double[])
Inverse L2-norm
public static double InvL2norm(double[] v)
Parameters
vdouble[]
Returns
L1norm(double[])
L1-norm
public static double L1norm(double[] v)
Parameters
vdouble[]
Returns
L2norm(double[])
L2-norm
public static double L2norm(double[] v)
Parameters
vdouble[]
Returns
LogSumOfExps(double[])
Computes \log(\sum_{i=1}^n e^{x_i}) using a maximum-element trick to avoid arithmetic overflow.
public static double LogSumOfExps(double[] x)
Parameters
xdouble[]input vector
Returns
- double
log-sum of exponentials of vector elements
Max(double[])
public static double Max(double[] x)
Parameters
xdouble[]
Returns
SumFeatures(Context?[], float[]?, double[])
public static void SumFeatures(Context?[] context, float[]? values, double[] prior)
Parameters
ToDoubleArray(IList<double>)
Convert a list of Double objects into an array of primitive doubles
public static double[] ToDoubleArray(IList<double> list)
Parameters
Returns
- double[]
ToIntArray(IList<int>)
Convert a list of Integer objects into an array of primitive integers
public static int[] ToIntArray(IList<int> list)
Parameters
Returns
- int[]