Modifier and Type | Field and Description |
---|---|
private static double |
DELTA
A small number to handle numbers near 0 as 0.
|
protected static java.lang.String |
ERR_DIMENSIONS
Error message when dimensionalities do not agree.
|
protected static java.lang.String |
ERR_INVALID_RANGE
Error message when min > max is given as a range.
|
protected static java.lang.String |
ERR_MATRIX_DIMENSIONS
Error message when matrix dimensionalities do not agree.
|
protected static java.lang.String |
ERR_MATRIX_INNERDIM
Error message when matrix dimensionalities do not agree.
|
protected static java.lang.String |
ERR_MATRIX_NONSQUARE
Error when a non-square matrix is used with determinant.
|
protected static java.lang.String |
ERR_MATRIX_NOT_SPD
When a symmetric positive definite matrix is required.
|
protected static java.lang.String |
ERR_MATRIX_RANK_DEFICIENT
When a matrix is rank deficient.
|
protected static java.lang.String |
ERR_SINGULAR
Error with a singular matrix.
|
protected static java.lang.String |
ERR_VEC_DIMENSIONS
Error message when vector dimensionalities do not agree.
|
Modifier | Constructor and Description |
---|---|
private |
VMath()
Fake constructor.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
almostEquals(double[][] m1,
double[][] m2)
Compare two matrices with a delta parameter to take numerical errors into
account.
|
static boolean |
almostEquals(double[][] m1,
double[][] m2,
double maxdelta)
Compare two matrices with a delta parameter to take numerical errors into
account.
|
static boolean |
almostEquals(double[] m1,
double[] m2)
Compare two matrices with a delta parameter to take numerical errors into
account.
|
static boolean |
almostEquals(double[] m1,
double[] m2,
double maxdelta)
Compare two matrices with a delta parameter to take numerical errors into
account.
|
static double |
angle(double[] v1,
double[] v2)
Compute the cosine of the angle between two vectors,
where the smaller angle between those vectors is viewed.
|
static double |
angle(double[] v1,
double[] v2,
double[] o)
Compute the cosine of the angle between two vectors,
where the smaller angle between those vectors is viewed.
|
static double[][] |
appendColumns(double[][] m1,
double[][] m2)
Returns a matrix which consists of this matrix and the specified columns.
|
static int |
argmax(double[] v)
Find the maximum value.
|
static void |
clear(double[] v1)
Reset the vector to 0.
|
static void |
clear(double[][] m)
Reset the matrix to 0.
|
static double[] |
columnPackedCopy(double[][] m1)
Make a one-dimensional column packed copy of the internal array.
|
static double[] |
copy(double[] v)
Returns a copy of this vector.
|
static double[][] |
copy(double[][] m1)
Make a deep copy of a matrix.
|
static double[][] |
diagonal(double[] v1)
Returns a quadratic matrix consisting of zeros and of the given values on
the diagonal.
|
static double |
dot(double[] v1,
double[] v2)
Returns the dot product (scalar product) of two vectors,
v1·v2 = v1T v2.
|
static boolean |
equals(double[][] m1,
double[][] m2)
Test for equality
|
static boolean |
equals(double[] v1,
double[] v2)
Compare for equality.
|
static double |
euclideanLength(double[] v1)
Euclidean length of the vector sqrt(v1T v1).
|
static double[] |
getCol(double[][] m1,
int col)
Get a column from a matrix as vector.
|
static int |
getColumnDimensionality(double[][] m1)
Returns the dimensionality of the columns of this matrix.
|
static double[] |
getDiagonal(double[][] m1)
getDiagonal returns array of diagonal-elements.
|
static double[][] |
getMatrix(double[][] m1,
int[] r,
int[] c)
Get a submatrix.
|
static double[][] |
getMatrix(double[][] m1,
int[] r,
int c0,
int c1)
Get a submatrix.
|
static double[][] |
getMatrix(double[][] m1,
int r0,
int r1,
int[] c)
Get a submatrix.
|
static double[][] |
getMatrix(double[][] m1,
int r0,
int r1,
int c0,
int c1)
Get a submatrix.
|
static double[] |
getRow(double[][] m1,
int r)
Returns the
r th row of this matrix as vector. |
static int |
getRowDimensionality(double[][] m1)
Returns the dimensionality of the rows of this matrix.
|
static int |
hashCode(double[] v1)
Compute the hash code for the vector.
|
static int |
hashCode(double[][] m1)
Compute hash code
|
static double[][] |
identity(int m,
int n)
Generate unit / identity / "eye" matrix.
|
static double[][] |
inverse(double[][] A)
Matrix inverse or pseudoinverse
|
static double |
mahalanobisDistance(double[][] B,
double[] a,
double[] c)
Matrix multiplication, (a-c)T * B * (a-c)
Note: it may (or may not) be more efficient to materialize (a-c), then use
transposeTimesTimes(a_minus_c, B, a_minus_c) instead. |
static double[][] |
minus(double[][] m1,
double[][] m2)
Component-wise matrix subtraction m3 = m1 - m2.
|
static double[] |
minus(double[] v1,
double s1)
Subtract component-wise v1 - s1.
|
static double[] |
minus(double[] v1,
double[] v2)
Computes component-wise v1 - v2.
|
static double[][] |
minusEquals(double[][] m1,
double[][] m2)
Component-wise matrix subtraction: m1 = m1 - m2,
overwriting the existing matrix m1.
|
static double[] |
minusEquals(double[] v1,
double s1)
Subtract component-wise in-place v1 = v1 - s1,
overwriting the vector v1.
|
static double[] |
minusEquals(double[] v1,
double[] v2)
Computes component-wise v1 = v1 - v2,
overwriting the vector v1.
|
static double[][] |
minusTimes(double[][] m1,
double[][] m2,
double s2)
Component-wise matrix operation: m3 = m1 - m2 * s2
|
static double[] |
minusTimes(double[] v1,
double[] v2,
double s2)
Computes component-wise v1 - v2 * s2.
|
static double[][] |
minusTimesEquals(double[][] m1,
double[][] m2,
double s2)
Component-wise matrix operation: m1 = m1 - m2 * s2,
overwriting the existing matrix m1.
|
static double[] |
minusTimesEquals(double[] v1,
double[] v2,
double s2)
Computes component-wise v1 = v1 - v2 * s2,
overwriting the vector v1.
|
static double[] |
normalize(double[] v1)
Normalizes v1 to the length of 1.0.
|
static void |
normalizeColumns(double[][] m1)
Normalizes the columns of this matrix to length of 1.0.
|
static double[] |
normalizeEquals(double[] v1)
Normalizes v1 to the length of 1.0 in place.
|
static double |
normF(double[][] elements)
Frobenius norm
|
static double[][] |
orthonormalize(double[][] m1)
Returns an orthonormalization of this matrix.
|
static double[] |
overwriteTimes(double[] v1,
double[] v2,
double s)
Multiply component-wise v1 = v2 * s,
overwriting the vector v1.
|
static double[][] |
plus(double[][] m1,
double[][] m2)
Component-wise matrix sum: m3 = m1 + m2.
|
static double[] |
plus(double[] v1,
double s1)
Computes component-wise v1 + s1.
|
static double[] |
plus(double[] v1,
double[] v2)
Computes component-wise v1 + v2 for vectors.
|
static double[][] |
plusEquals(double[][] m1,
double[][] m2)
Component-wise matrix operation: m1 = m1 + m2,
overwriting the existing matrix m1.
|
static double[] |
plusEquals(double[] v1,
double s1)
Computes component-wise v1 = v1 + s1,
overwriting the vector v1.
|
static double[] |
plusEquals(double[] v1,
double[] v2)
Computes component-wise v1 = v1 + v2,
overwriting the vector v1.
|
static double[][] |
plusTimes(double[][] m1,
double[][] m2,
double s2)
Component-wise matrix operation: m3 = m1 + m2 * s2.
|
static double[] |
plusTimes(double[] v1,
double[] v2,
double s2)
Computes component-wise v1 + v2 * s2.
|
static double[][] |
plusTimesEquals(double[][] m1,
double[][] m2,
double s2)
Component-wise matrix operation: m1 = m1 + m2 * s2,
overwriting the existing matrix m1.
|
static double[] |
plusTimesEquals(double[] v1,
double[] v2,
double s2)
Computes component-wise v1 = v1 + v2 * s2,
overwriting the vector v1.
|
static double[] |
rotate90Equals(double[] v1)
Rotate the two-dimensional vector by 90 degrees.
|
static double[] |
rowPackedCopy(double[][] m1)
Make a one-dimensional row packed copy of the internal array.
|
static double |
scalarProduct(double[] v1,
double[] v2)
Returns the scalar product (dot product) of two vectors,
<v1,v2> = v1T v2.
|
static void |
setCol(double[][] m1,
int c,
double[] column)
Sets the
c th column of this matrix to the specified column. |
static void |
setMatrix(double[][] m1,
int[] r,
int[] c,
double[][] m2)
Set a submatrix.
|
static void |
setMatrix(double[][] m1,
int[] r,
int c0,
int c1,
double[][] m2)
Set a submatrix.
|
static void |
setMatrix(double[][] m1,
int r0,
int r1,
int[] c,
double[][] m2)
Set a submatrix.
|
static void |
setMatrix(double[][] m1,
int r0,
int r1,
int c0,
int c1,
double[][] m2)
Set a submatrix.
|
static void |
setRow(double[][] m1,
int r,
double[] row)
Sets the
r th row of this matrix to the specified vector. |
static double[] |
solve(double[][] A,
double[] b)
Solve A*X = b
|
static double[][] |
solve(double[][] A,
double[][] B)
Solve A*X = B
|
static double |
squareSum(double[] v1)
Squared Euclidean length of the vector v1T v1 = v1·v1.
|
static double |
sum(double[] v1)
Sum of the vector components.
|
static double[][] |
times(double[][] m1,
double s1)
Multiply a matrix by a scalar component-wise, m3 = m1 * s1.
|
static double[] |
times(double[][] m1,
double[] v2)
Matrix with vector multiplication, m1 * v2.
|
static double[][] |
times(double[][] m1,
double[][] m2)
Matrix multiplication, m1 * m2.
|
static double[] |
times(double[] v1,
double s1)
Multiply component-wise v1 * s1.
|
static double[][] |
times(double[] v1,
double[][] m2)
Deprecated.
this is fairly inefficient memory layout, rewriting your code
|
static double[][] |
timesEquals(double[][] m1,
double s1)
Multiply a matrix by a scalar component-wise in place, m1 = m1 * s1,
overwriting the existing matrix m1.
|
static double[] |
timesEquals(double[] v1,
double s)
Multiply component-wise v1 = v1 * s1,
overwriting the vector v1.
|
static double[] |
timesMinus(double[] v1,
double s1,
double[] v2)
Computes component-wise v1 * s1 - v2.
|
static double[] |
timesMinusEquals(double[] v1,
double s1,
double[] v2)
Computes component-wise v1 = v1 * s1 - v2,
overwriting the vector v1.
|
static double[] |
timesMinusTimes(double[] v1,
double s1,
double[] v2,
double s2)
Computes component-wise v1 * s1 - v2 * s2.
|
static double[] |
timesMinusTimesEquals(double[] v1,
double s1,
double[] v2,
double s2)
Computes component-wise v1 = v1 * s1 - v2 * s2,
overwriting the vector v1.
|
static double[] |
timesPlus(double[] v1,
double s1,
double[] v2)
Computes component-wise v1 * s1 + v2.
|
static double[] |
timesPlusEquals(double[] v1,
double s1,
double[] v2)
Computes component-wise v1 = v1 * s1 + v2,
overwriting the vector v1.
|
static double[] |
timesPlusTimes(double[] v1,
double s1,
double[] v2,
double s2)
Computes component-wise v1 * s1 + v2 * s2.
|
static double[] |
timesPlusTimesEquals(double[] v1,
double s1,
double[] v2,
double s2)
Computes component-wise v1 = v1 * s1 + v2 * s2,
overwriting the vector v1.
|
static double[][] |
timesTranspose(double[][] m1,
double[][] m2)
Matrix multiplication, m1 * m2T
|
static double[][] |
timesTranspose(double[] v1,
double[] v2)
Vectors to matrix multiplication, v1 * v2T.
|
static double[][] |
timesTranspose(double[] v1,
double[][] m2)
Deprecated.
this is fairly inefficient memory layout, rewriting your code
|
static double[][] |
transpose(double[] v)
Transpose vector to a matrix without copying.
|
static double[][] |
transpose(double[][] m1)
Matrix transpose
|
static double[][] |
transposeDiagonalTimes(double[][] m1,
double[] d2,
double[][] m3)
Matrix multiplication with diagonal, m1^T * d2 * m3
|
static double[] |
transposeTimes(double[][] m1,
double[] v2)
Transposed matrix with vector multiplication, m1T * v2
|
static double[][] |
transposeTimes(double[][] m1,
double[][] m2)
Matrix multiplication, m1T * m2
|
static double |
transposeTimes(double[] v1,
double[] v2)
Vector scalar product (dot product),
v1T v2 = v1·v2 = <v1,v2>.
|
static double[][] |
transposeTimes(double[] v1,
double[][] m2)
Vector to matrix multiplication, v1T m2.
|
static double |
transposeTimesTimes(double[] v1,
double[][] m2,
double[] v3)
Matrix multiplication, v1T * m2 * v3
|
static double[][] |
transposeTimesTranspose(double[][] m1,
double[][] m2)
Matrix multiplication, m1T * m2T.
|
static double[][] |
unitMatrix(int dim)
Returns the unit / identity / "eye" matrix of the specified dimension.
|
static double[] |
unitVector(int dimensionality,
int i)
Returns the ith unit vector of the specified dimensionality.
|
static double[][] |
zeroMatrix(int dim)
Returns the zero matrix of the specified dimension.
|
private static final double DELTA
protected static final java.lang.String ERR_VEC_DIMENSIONS
protected static final java.lang.String ERR_MATRIX_DIMENSIONS
protected static final java.lang.String ERR_MATRIX_INNERDIM
protected static final java.lang.String ERR_DIMENSIONS
protected static final java.lang.String ERR_INVALID_RANGE
protected static final java.lang.String ERR_MATRIX_NONSQUARE
protected static final java.lang.String ERR_SINGULAR
protected static final java.lang.String ERR_MATRIX_NOT_SPD
protected static final java.lang.String ERR_MATRIX_RANK_DEFICIENT
public static double[] unitVector(int dimensionality, int i)
dimensionality
- the dimensionality of the vectori
- the indexpublic static double[] copy(double[] v)
v
- original vectorpublic static double[][] transpose(double[] v)
v
- Vectorpublic static double[] plus(double[] v1, double[] v2)
v1
- first vectorv2
- second vectorpublic static double[] plusTimes(double[] v1, double[] v2, double s2)
v1
- first vectorv2
- second vectors2
- the scalarpublic static double[] timesPlus(double[] v1, double s1, double[] v2)
v1
- first vectors1
- the scalar for v1v2
- second vectorpublic static double[] timesPlusTimes(double[] v1, double s1, double[] v2, double s2)
v1
- first vectors1
- the scalar for v1v2
- second vectors2
- the scalar for v2public static double[] plusEquals(double[] v1, double[] v2)
v1
- first vector (overwritten)v2
- second vectorpublic static double[] plusTimesEquals(double[] v1, double[] v2, double s2)
v1
- first vector (overwritten)v2
- another vectors2
- scalar factor for v2public static double[] timesPlusEquals(double[] v1, double s1, double[] v2)
v1
- first vector (overwritten)s1
- scalar factor for v1v2
- another vectorpublic static double[] timesPlusTimesEquals(double[] v1, double s1, double[] v2, double s2)
v1
- first vector (overwritten)s1
- scalar for v1v2
- another vectors2
- scalar for v2public static double[] plus(double[] v1, double s1)
v1
- vector to add tos1
- constant value to addpublic static double[] plusEquals(double[] v1, double s1)
v1
- vector to add to (overwritten)s1
- constant value to addpublic static double[] minus(double[] v1, double[] v2)
v1
- first vectorv2
- the vector to be subtracted from this vectorpublic static double[] minusTimes(double[] v1, double[] v2, double s2)
v1
- first vectorv2
- the vector to be subtracted from this vectors2
- the scaling factor for v2public static double[] timesMinus(double[] v1, double s1, double[] v2)
v1
- first vectors1
- the scaling factor for v1v2
- the vector to be subtracted from this vectorpublic static double[] timesMinusTimes(double[] v1, double s1, double[] v2, double s2)
v1
- first vectors1
- the scaling factor for v1v2
- the vector to be subtracted from this vectors2
- the scaling factor for v2public static double[] minusEquals(double[] v1, double[] v2)
v1
- vectorv2
- another vectorpublic static double[] minusTimesEquals(double[] v1, double[] v2, double s2)
v1
- vectorv2
- another vectors2
- scalar for v2public static double[] timesMinusEquals(double[] v1, double s1, double[] v2)
v1
- vectors1
- scalar for v1v2
- another vectorpublic static double[] timesMinusTimesEquals(double[] v1, double s1, double[] v2, double s2)
v1
- vectors1
- scalar for v1v2
- another vectors2
- Scalarpublic static double[] minus(double[] v1, double s1)
v1
- original vectors1
- Value to subtractpublic static double[] minusEquals(double[] v1, double s1)
v1
- original vectors1
- Value to subtractpublic static double[] times(double[] v1, double s1)
v1
- original vectors1
- the scalar to be multipliedpublic static double[] timesEquals(double[] v1, double s)
v1
- original vectors
- scalarpublic static double[] overwriteTimes(double[] v1, double[] v2, double s)
v1
- output vectorv2
- input vectors
- scalar@Deprecated public static double[][] times(double[] v1, double[][] m2)
Note: this is an unusual operation, m2 must be a costly column matrix.
This method is equivalent to the
timesTranspose(double[], double[])
method
with m2 being the second vector as matrix, but transposed.
v1
- vectorm2
- other matrix, must have one row.public static double[][] transposeTimes(double[] v1, double[][] m2)
v1
- vectorm2
- other matrixpublic static double transposeTimes(double[] v1, double[] v2)
v1
- vectorv2
- other vector@Deprecated public static double[][] timesTranspose(double[] v1, double[][] m2)
Note: this is an unusual operation, m2 must be a costly column matrix.
This method is equivalent to the
timesTranspose(double[], double[])
method
with m2 being the second vector as matrix.
v1
- vectorm2
- other matrixpublic static double[][] timesTranspose(double[] v1, double[] v2)
v1
- vectorv2
- other vectorpublic static double scalarProduct(double[] v1, double[] v2)
This is the same as transposeTimes(double[], double[])
.
v1
- vectorv2
- other vectorpublic static double dot(double[] v1, double[] v2)
This is the same as transposeTimes(double[], double[])
.
v1
- vectorv2
- other vectorpublic static double sum(double[] v1)
v1
- vectorpublic static double squareSum(double[] v1)
v1
- vectorpublic static double euclideanLength(double[] v1)
v1
- vectorpublic static int argmax(double[] v)
v
- Vectorpublic static double[] normalize(double[] v1)
v1
- vectorpublic static double[] normalizeEquals(double[] v1)
v1
- vector (overwritten)public static int hashCode(double[] v1)
v1
- elementspublic static boolean equals(double[] v1, double[] v2)
v1
- first vectorv2
- second vectorpublic static void clear(double[] v1)
v1
- vectorpublic static void clear(double[][] m)
m
- Matrixpublic static double[] rotate90Equals(double[] v1)
v1
- first vectorpublic static double[][] unitMatrix(int dim)
dim
- the dimensionality of the unit matrixpublic static double[][] zeroMatrix(int dim)
dim
- the dimensionality of the unit matrixpublic static double[][] identity(int m, int n)
m
- Number of rows.n
- Number of columns.public static double[][] diagonal(double[] v1)
v1
- the values on the diagonalpublic static double[][] copy(double[][] m1)
m1
- Input matrixpublic static double[] rowPackedCopy(double[][] m1)
m1
- Input matrixpublic static double[] columnPackedCopy(double[][] m1)
m1
- Input matrixpublic static double[][] getMatrix(double[][] m1, int r0, int r1, int c0, int c1)
m1
- Input matrixr0
- Initial row indexr1
- Final row index (exclusive)c0
- Initial column indexc1
- Final column index (exclusive)public static double[][] getMatrix(double[][] m1, int[] r, int[] c)
m1
- Input matrixr
- Array of row indices.c
- Array of column indices.public static double[][] getMatrix(double[][] m1, int[] r, int c0, int c1)
m1
- Input matrixr
- Array of row indices.c0
- Initial column indexc1
- Final column index (exclusive)public static double[][] getMatrix(double[][] m1, int r0, int r1, int[] c)
m1
- Input matrixr0
- Initial row indexr1
- Final row index (exclusive)c
- Array of column indices.public static void setMatrix(double[][] m1, int r0, int r1, int c0, int c1, double[][] m2)
m1
- Original matrixr0
- Initial row indexr1
- Final row index (exclusive)c0
- Initial column indexc1
- Final column index (exclusive)m2
- New values for m1(r0:r1-1,c0:c1-1)public static void setMatrix(double[][] m1, int[] r, int[] c, double[][] m2)
m1
- Original matrixr
- Array of row indices.c
- Array of column indices.m2
- New values for m1(r(:),c(:))public static void setMatrix(double[][] m1, int[] r, int c0, int c1, double[][] m2)
m1
- Input matrixr
- Array of row indices.c0
- Initial column indexc1
- Final column index (exclusive)m2
- New values for m1(r(:),c0:c1-1)public static void setMatrix(double[][] m1, int r0, int r1, int[] c, double[][] m2)
m1
- Input matrixr0
- Initial row indexr1
- Final row indexc
- Array of column indices.m2
- New values for m1(r0:r1-1,c(:))public static double[] getRow(double[][] m1, int r)
r
th row of this matrix as vector.m1
- Input matrixr
- the index of the row to be returnedr
th row of this matrixpublic static void setRow(double[][] m1, int r, double[] row)
r
th row of this matrix to the specified vector.m1
- Original matrixr
- the index of the column to be setrow
- the value of the column to be setpublic static double[] getCol(double[][] m1, int col)
m1
- Matrix to extract the column fromcol
- Column numberpublic static void setCol(double[][] m1, int c, double[] column)
c
th column of this matrix to the specified column.m1
- Input matrixc
- the index of the column to be setcolumn
- the value of the column to be setpublic static double[][] transpose(double[][] m1)
m1
- Input matrixpublic static double[][] plus(double[][] m1, double[][] m2)
m1
- Input matrixm2
- another matrixpublic static double[][] plusTimes(double[][] m1, double[][] m2, double s2)
m1
- Input matrixm2
- another matrixs2
- scalarpublic static double[][] plusEquals(double[][] m1, double[][] m2)
m1
- input matrix (overwritten)m2
- another matrixpublic static double[][] plusTimesEquals(double[][] m1, double[][] m2, double s2)
m1
- input matrix (overwritten)m2
- another matrixs2
- scalar for s2public static double[][] minus(double[][] m1, double[][] m2)
m1
- Input matrixm2
- another matrixpublic static double[][] minusTimes(double[][] m1, double[][] m2, double s2)
m1
- Input matrixm2
- another matrixs2
- Scalarpublic static double[][] minusEquals(double[][] m1, double[][] m2)
m1
- Input matrixm2
- another matrixpublic static double[][] minusTimesEquals(double[][] m1, double[][] m2, double s2)
m1
- Input matrixm2
- another matrixs2
- Scalarpublic static double[][] times(double[][] m1, double s1)
m1
- Input matrixs1
- scalarpublic static double[][] timesEquals(double[][] m1, double s1)
m1
- Input matrixs1
- scalarpublic static double[][] times(double[][] m1, double[][] m2)
m1
- Input matrixm2
- another matrixpublic static double[] times(double[][] m1, double[] v2)
m1
- Input matrixv2
- a vectorpublic static double[] transposeTimes(double[][] m1, double[] v2)
m1
- Input matrixv2
- another matrixpublic static double[][] transposeTimes(double[][] m1, double[][] m2)
m1
- Input matrixm2
- another matrixpublic static double transposeTimesTimes(double[] v1, double[][] m2, double[] v3)
v1
- vector on the leftm2
- matrixv3
- vector on the rightpublic static double[][] timesTranspose(double[][] m1, double[][] m2)
m1
- Input matrixm2
- another matrixpublic static double[][] transposeTimesTranspose(double[][] m1, double[][] m2)
m1
- Input matrixm2
- another matrixpublic static double[][] transposeDiagonalTimes(double[][] m1, double[] d2, double[][] m3)
m1
- Left matrixd2
- Diagonal entriesm3
- Right matrix@Reference(authors="P. C. Mahalanobis", title="On the generalized distance in statistics", booktitle="Proceedings of the National Institute of Sciences of India. 2 (1)", bibkey="journals/misc/Mahalanobis36") public static double mahalanobisDistance(double[][] B, double[] a, double[] c)
Note: it may (or may not) be more efficient to materialize (a-c), then use
transposeTimesTimes(a_minus_c, B, a_minus_c)
instead.
B
- matrixa
- First vectorc
- Center vectorpublic static double[] getDiagonal(double[][] m1)
m1
- Input matrixpublic static void normalizeColumns(double[][] m1)
m1
- Input matrixpublic static double[][] appendColumns(double[][] m1, double[][] m2)
m1
- Input matrixm2
- the columns to be appendedpublic static double[][] orthonormalize(double[][] m1)
m1
- Input matrixpublic static double[][] solve(double[][] A, double[][] B)
B
- right hand sidepublic static double[] solve(double[][] A, double[] b)
b
- right hand sidepublic static double[][] inverse(double[][] A)
A
- matrix to invertpublic static double normF(double[][] elements)
elements
- Matrixpublic static int hashCode(double[][] m1)
m1
- Input matrixpublic static boolean equals(double[][] m1, double[][] m2)
m1
- Input matrixm2
- Other matrixpublic static boolean almostEquals(double[][] m1, double[][] m2, double maxdelta)
m1
- Input matrixm2
- other matrix to compare withmaxdelta
- maximum delta allowedpublic static boolean almostEquals(double[][] m1, double[][] m2)
m1
- Input matrixm2
- other matrix to compare withDELTA
public static boolean almostEquals(double[] m1, double[] m2, double maxdelta)
m1
- Input matrixm2
- other matrix to compare withmaxdelta
- maximum delta allowedpublic static boolean almostEquals(double[] m1, double[] m2)
m1
- Input matrixm2
- other matrix to compare withDELTA
public static int getRowDimensionality(double[][] m1)
m1
- Input matrixpublic static int getColumnDimensionality(double[][] m1)
m1
- Input matrixpublic static double angle(double[] v1, double[] v2)
v1
- first vectorv2
- second vectorpublic static double angle(double[] v1, double[] v2, double[] o)
v1
- first vectorv2
- second vectoro
- OriginCopyright © 2019 ELKI Development Team. License information.