Java Utililty Methods Matrix Product

List of utility methods to do Matrix Product

Description

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

Method

double[]matrix_vector_product(double[][] a, double[] v)
matrivectoproduct
double[] r = new double[a.length];
for (int i = 0; i < a.length; i++)
    r[i] = dot_product(a[i], v);
return r;
doublematrixInnerProduct(int M, int N, double m1[][], double m2[][])
matrix Inner Product
double sum = 0.0D;
for (int i = M - 1; i >= 0; i--) {
    for (int j = N - 1; j >= 0; j--)
        sum += m1[i][j] * m2[i][j];
return sum;
double[][]matrixProduct(double[][] A, double[][] B)
Return the matrix product A x B
if (A[0].length != B.length) {
    throw new Exception("Number of columns of a " + A[0].length + " does not match the number of rows of b "
            + B.length);
double[][] result = new double[A.length][B[0].length];
for (int r = 0; r < result.length; r++) {
    for (int c = 0; c < result[r].length; c++) {
        result[r][c] = 0;
...
double[][]matrixProduct(double[][] m, double[][] n)
matrix Product
if (m[0].length != n.length)
    throw new Exception("Can't do the requested product");
double[][] p = new double[m.length][n.length];
for (int i = 0; i < m.length; i++) {
    for (int j = 0; j < n[0].length; j++) {
        p[i][j] = pointProduct(m[i], getColumn(n, j));
return p;
double[]matrixProduct(double[][] x, double[] y)
matrix Product
double[][] y2 = new double[y.length][1];
int i;
for (i = 0; i < y.length; i++)
    y2[i][0] = y[i];
y2 = matrixProduct(x, y2);
double[] y3 = new double[y2.length];
for (i = 0; i < y2.length; i++)
    y3[i] = y2[i][0];
...
voidmatrixProductVDVT(final double[][] V, final double[] d, final double[][] A, int n)
Multiplies the vector v (n) with diagonal matrix D (n-by-n) and then with v' (transposed).
assert hasShape(V, n, n);
assert d != null;
assert d.length >= n;
assert hasShape(A, n, n);
for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
        A[i][j] = V[i][0] * d[0] * V[j][0];
        for (int k = 1; k < n; k++) {
...
List>product(final T[][] args)
product
final int[] tmp = new int[args.length];
for (int i = 0; i < tmp.length; i++) {
    tmp[i] = args[i].length;
final int[][] solution = product(tmp);
final List<List<T>> results = new ArrayList<List<T>>(solution.length);
for (int i = 0; i < solution.length; i++) {
    final List<T> inner = new ArrayList<T>(args.length);
...