Java Utililty Methods Matrix

List of utility methods to do Matrix

Description

The list of methods to do Matrix are organized into topic(s).

Method

doublematrixKLDivergence(double m1[][], double m2[][])
matrix KL Divergence
if (m1.length != m2.length)
    return Double.MAX_VALUE;
double avgKL = 0.0;
for (int i = 0; i < m1.length; i++) {
    if (m1[i].length != m2[i].length)
        return Double.MAX_VALUE;
    avgKL += vectorKLDivergence(m1[i], m2[i]);
return avgKL / m1.length;
double[][]matrixModule(double[][] matrix, int module)
matrix Module
for (int x = 0; x < matrix.length; x++) {
    for (int y = 0; y < matrix[0].length; y++) {
        matrix[x][y] = matrix[x][y] % 256;
return matrix;
double[]matrixTimesVector(double[][] matrix, double[] vector)
matrix Times Vector
if (matrix[0].length != vector.length) {
    throw new IllegalArgumentException("matrix[0].length != vector.length");
double[] res = new double[matrix.length];
for (int i = 0; i < matrix.length; i++) {
    res[i] = 0;
    for (int j = 0; j < matrix[0].length; j++) {
        res[i] = res[i] + matrix[j][i] * vector[j];
...