Not all the functionality of EJML is exposed to Basic4android This library exposes SimpleMatrix which is an interface that provides an easy to use object oriented way of doing linear algebra. SimpleMatrix
Simplified ways to use popular matrix decompositions are provided. These decompositions should meet most people needs. SVD : Computes the singular value decomposition of 'this' matrix. EIG : Computes the eigen value decomposition of 'this' matrix.
EJML and therefore also this library is licensed under the GNU Lesser General Public License. http://www.gnu.org/licenses/lgpl.html Copies of both the General Public License and Lesser General Public License are in the provided archive.
This object holds the Eigendecomposition of a matrix. Eigenvalues and eigenvectors have the following property: A*v=λ*v where A is a square matrix and v is an eigenvector associated with the eigenvalue λ.
In general, both eigenvalues and eigenvectors can be complex numbers. For symmetric matrices the eigenvalues and eigenvectors are always real numbers. EJML does not support complex matrices but it does have minimal support for complex numbers. As a result complex eigenvalues are found, but only the real eigenvectors are computed.
SimpleMatrix is an interface that provides an easy to use object oriented way of doing linear algebra. It is a wrapper around the operation interface in EJML and was originally inspired by Jama. When using SimpleMatrix memory management is automatically handled and it allows commands to be chained together as many of the operations return the SimpleMatrix itself.
For example A.Transpose().Mult(B).Scale(12).Invert. Such expressions are evaluated left to right.
The typical method in SimpleMatrix takes at least one SimpleMatrix as an input and returns a SimpleMatrix. None of the input matrices are modified during function calls, a new matrix is always returned.
The names of the methods in this library are as far as possible the names in the original EJML libray.
The EJML documentation should be studied for more information on SimpleMatrix. SimpleMatrix
Creates a new matrix that is a combination of this matrix and matrix B. B is written into A at the specified location if needed the size of A is increased by growing it. A is grown by padding the new area with zeros. While useful when adding data to a matrix which will be solved for it is also much less efficient than predeclaring a matrix and inserting data into it. If insertRow or insertCol is set to SimpleMatrix.END then it will be combined at the last row or column respectively.
ConditionP2AsDouble
The condition p = 2 number of a matrix is used to measure the sensitivity of the linear system Ax=b. A value near one indicates that it is a well conditioned matrix.
CopyAsSimpleMatrix
Creates and returns a matrix which is idential to this one.
Data() AsDouble
Gets or sets a reference to the underlying Double array of data for the matrix.
DeterminantAsDouble
Computes and returns the determinant of the matri.x
Divide (valAsDouble) AsSimpleMatrix
Returns a new matrix, the result of dividing each element of 'this' by 'val': Bi,j = Ai,j/val
Dot (VAsSimpleMatrix) AsDouble
Computes the dot product (a.k.a. inner product) between this vector and vector 'V'.
EIGAsSimpleEVD
Computes the Eigendecomposition of a matrix. Eigenvalues and eigenvectors have the following property: A*v=λ*v where A is a square matrix and v is an eigenvector associated with the eigenvalue λ.
In general, both eigenvalues and eigenvectors can be complex numbers. For symmetric matrices the eigenvalues and eigenvectors are always real numbers. EJML does not support complex matrices but it does have minimal support for complex numbers. As a result complex eigenvalues are found, but only the real eigenvectors are computed.
Returns a SimpleEVD for assignment to a SimpleEVD variable.
ElementMaxAbsAsDouble
Returns the maximum absolute value of all the elements in this matrix. This is equivalent the the infinite p-norm of the matrix.
ElementMult (BAsSimpleMatrix) AsSimpleMatrix
Returns a matrix which is the result of an element by element multiplication of 'this' and 'B' Ci,j = Ai,j*Bi,j
ElementSumAsDouble
Returns the sum of all the elements in the matrix.
ENDAsInt
Constant for defining the last row or column of a SimpleMatrix.
ExtractDiagAsSimpleMatrix
Extracts the diagonal from this matrix and returns the values inside a column vector.
Extracts a row or column from this matrix. The returned vector will either be a row or column vector depending on the input type. extractRow - If true a row will be extracted. element - The row or column the vector is contained in.
GetElement (rowAsInt, colAsInt) AsDouble
Returns the value of the specified matrix element. Performs a bounds check to make sure the requested element is part of the matrix.
GetElement1D (indexAsInt) AsDouble
GetIndex (rowAsInt, colAsInt) AsInt
GetNumElementsAsInt
Returns the number of elements in this matrix which is equal to the number of rows times the number of columns.
HasUncountableAsBoolean
Checks to see if any of the elements in this matrix are either NaN or infinite. Returns True if an element is NaN or infinite, False otherwise.
Initialize (numRowsAsInt, numColsAsInt)
Creates a new matrix that is initially set to zero with the specified dimensions.
Initialize2 (double2Darray(,) AsDouble)
Creates a matrix with the values and shape defined by the 2D array 'data'. It is assumed that 'data' has a row-major formatting: data[ row ][ column ]
Initialize3 (simplematrixAsSimpleMatrix)
Creats a new copy of a SimpleMatrix which is identical to the original. Note that DimNewMatrixAsSimpleMatrix NewMatrix.Initialize3(OldMatrix)
Copy matrix B into this matrix at location (insertRow, insertCol). This method is one of the few that changes this matrix rather returning a new one.
InvertAsSimpleMatrix
Returns the inverse of this matrix: B = A^-1 If the matrix could not be inverted then SingularMatrixException is thrown. Even if no exception is thrown the matrix could still be singular or nearly singular.
Returns a new matrix loaded from a serialized binary file.
LoadCSV (pathandfileNameAsString) AsSimpleMatrix
Returns a new matrix loaded from a CSV file.
Minus (BAsSimpleMatrix) AsSimpleMatrix
Returns a matrix which is the result of matrix subtraction: C = A - B where C is the returned matrix, A is this matrix, and B is the passed in matrix.
Mult (BAsSimpleMatrix) AsSimpleMatrix
Returns a matrix which is the result of matrix multiplication: C = A * B where C is the returned matrix, A is this matrix, and B is the passed in matrix.
NegativeAsSimpleMatrix
Returns a new matrix whose elements are the negative of 'this' matrix's elements
NormFAsDouble
Computes the Frobenius normal of the matrix: normF = Sqrt{ ∑i=1:m ∑j=1:n { aij2} }
NumColsAsInt
Returns the number of columns in this matrix.
NumRowsAsInt
Returns the number of rows in this matrix.
Plus (BAsSimpleMatrix) AsSimpleMatrix
Returns a new matrix, the result of matrix addition: C = A + B where C is the returned matrix, A is this matrix, and B is the passed in matrix.
Returns a new matrix, the result of matrix addition and scaling: C = A + beta*B where C is the returned matrix, Z is this matrix, and B is the passed in matrix.
Computes the Moore-Penrose pseudo-inverse matrix of this and returns a new matrix.
Reshape (numRowsAsInt, numColsAsInt)
Reshapes the matrix to the specified number of rows and columns. If the total number of elements is <= number of elements it had before the data is saved. Otherwise a new internal array is declared and the old data lost. This method is one of the few that changes this matrix rather returning a new one.
SaveToFileBinary (pathandfileNameAsString)
Saves this matrix to a file as a serialized binary object.
SaveToFileCSV (pathandfileNameAsString)
Saves this matrix to a file in a CSV format. For the file format see MatrixIO in the original EJML documentation.
Scale (valAsDouble) AsSimpleMatrix
Returns a new matrix, the result of scaling each element by 'val': Bi,j = val*Ai,j
Assigns consecutive elements inside a column to the provided array. A(offset:(offset + values.length),column) = values
SetDouble (valAsDouble)
Sets all the elements in this matrix equal to the specified value.
SetElement (rowAsInt, colAsInt, valueAsDouble)
Assigns the pscified element in the Matrix to the specified value
SetElement1D (indexAsInt, valueAsDouble)
SetMatrix (AAsSimpleMatrix)
Sets the elements in this matrix to be equal to the elements in the passed in matrix. Both matrix must have the same dimension.
SetRow (rowAsInt, offsetAsInt, values() AsDouble)
Assigns consecutive elements inside a row to the provided array. A(offset:(offset + values.length),row) = values
Solve (BAsSimpleMatrix) AsSimpleMatrix
Solves for X in the following equation: x = A^-1 * B where 'A' is this matrix and 'B' is an n by p matrix.
If the system could not be solved then a SingularMatrixException is thrown. Even if no exception is thrown 'A' could still be singular or nearly singular.
SVD (iscompactAsBoolean) AsSimpleSVD
Computes the Singular Value Decomposition (SVD) of this matrix, which is defined as A = U * W * V^T where A is m by n, and U and V are orthogonal matrices, and W is a diagonal matrix. The eigenvalues are ordered from largest to smallest.
Returns a SimpleSVD for assignment to a SimpleSVD variable.
If compact is True then compact matrices will be returned from the SVD. See the help for SimpleSVD for a definition of compact matrices.
ToStringAsString
Converts the array into a string format for display purposes.
TraceAsDouble
Computes and returns the trace of the matrix.
TransposeAsSimpleMatrix
Returns a new matrix which is the transpose of this matrix
VersionAsDouble [read only]
Returns the version of the library.
Zero
Sets all the elements in this matrix equal to zero.
This object holds the Singular Value Decomposition (SVD) of a matrix, which is defined as A = U * W * V^T where A is m by n, and U and V are orthogonal matrices, and W is a diagonal matrix.
The dimension of U,W,V depends if it is a compact SVD or not. If not compact then U is m by m, *W is m by n, V is n by n. If compact then let s be the number of singular values, U is m by s, W is s by s, and V is n by s.
Returns all the singular values as a Double array.
GetUAsSimpleMatrix
Returns the orthogonal 'U' m x m matrix as a SimpleMatrix
GetVAsSimpleMatrix
Returns the orthogonal 'V' n x n matrix as a SimpleMatrix
GetWAsSimpleMatrix
Returns a diagonal matrix with the singular values along the diagonal as a SimpleMatrix. The singular values are ordered from largest to smallest.
IsCompactAsBoolean
If true then compact matrices are returned.
NullityAsInt
Returns the nullity of the decomposed matrix.
NullSpaceAsSimpleMatrix
Returns the computed null space of the decomposed matrix as a SimpleMatrix. The null space is a set of non-zero vectors that when multiplied by the original matrix return zero. The null space is found by extracting the columns in V that are associated singular values less than or equal to the threshold. In some situations a non-compact SVD is required.
NumberOfSingularValuesAsInt
Returns the number of singular values in the decomposed matrix.
NumColsAsInt
Returns the number of columns in the decomposed matrix.
NumRowsAsInt
Returns the number of rows in the decomposed matrix.