fr.lip6.jkernelmachines.util.algebra contains some classes to perform basic operations on vectors and matrices. To avoid defining new datatypes, all operations are performed on arrays of double:
double vector; double matrix;
The matrix format follows the classical algebra notation (first index are the lines, and second are the columns), and not the column vector format encountered in hardware optimized libraries.
The package provides both in place and allocating operations. For example, a multiplication between 2 matrices can be performed by allocating the destination matrix:
double in1, in2; ... double out = MatrixOperations.mul(in1, in2);
Or in place as in
double out, int1, in2; ... MatrixOperations.mul(out, in1, in2);
In that case
out has to be allocated by the user before the call to
A eigen decomposition can be performed like this
double X; double ei = MatrixOperations.eig(X); // reconstructing the original matrix // from the eignvectors ei and the eigenvalues ei double Xrec = MatrixOperations.mul(ei, MatrixOperations.mul(ei, MatrixOperations.trans(ei)));
While all operations provided by the package are available thanks to internal routines, they can be replace by the more efficient routines of EJML at no cost. In fact, all you have to do is to ensure 'ejml.jar' is in the JkernelMachines folder before compiling, and then in the classpath of your application. That is, you must launch the application using
java -cp jkernelmachines.jar:ejml.jar
JKernelMachines automatically checks for the availability of EJML, and uses its routines for the eig decomposition.