Class ArrayMath

Namespace
NOpenNLP.Tools.Ml
Assembly
NOpenNLP.Tools.dll

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

x double[]

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

vecA double[]
vecB double[]

Returns

double

InvL2norm(double[])

Inverse L2-norm

public static double InvL2norm(double[] v)

Parameters

v double[]

Returns

double

L1norm(double[])

L1-norm

public static double L1norm(double[] v)

Parameters

v double[]

Returns

double

L2norm(double[])

L2-norm

public static double L2norm(double[] v)

Parameters

v double[]

Returns

double

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

x double[]

input vector

Returns

double

log-sum of exponentials of vector elements

Max(double[])

public static double Max(double[] x)

Parameters

x double[]

Returns

double

SumFeatures(Context?[], float[]?, double[])

public static void SumFeatures(Context?[] context, float[]? values, double[] prior)

Parameters

context Context[]
values float[]
prior double[]

ToDoubleArray(IList<double>)

Convert a list of Double objects into an array of primitive doubles

public static double[] ToDoubleArray(IList<double> list)

Parameters

list IList<double>

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

list IList<int>

Returns

int[]