Java Matrix matrixATrans_x_matrixB(double[][] matA, double[][] matB)

Here you can find the source of matrixATrans_x_matrixB(double[][] matA, double[][] matB)

Description

First transposes matrix matA, then multiplies it with matrix matB.

License

Open Source License

Parameter

Parameter Description
matA The matrix (m x n).
matB The matrix (m x r).

Return

The resulting matrix of size n x r.

Declaration

public static double[][] matrixATrans_x_matrixB(double[][] matA, double[][] matB) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from  w ww . j  a v a2s. com
     * First transposes matrix matA, then multiplies it with matrix matB.
     * @param matA The matrix (m x n).
     * @param matB The matrix (m x r).
     * @return The resulting matrix of size n x r.
     */
    public static double[][] matrixATrans_x_matrixB(double[][] matA, double[][] matB) {
        final int m = matA[0].length;
        final int n = matB[0].length;

        double[][] res = new double[m][n];

        for (int r = 0; r < m; r++) {
            for (int c = 0; c < n; c++) {
                for (int i = 0; i < matA.length; i++) {
                    res[r][c] += matA[i][r] * matB[i][c];
                }
            }
        }
        return res;
    }
}

Related

  1. matrix_x_matrix(double[][] A, double[][] B)
  2. matrix_x_vectorMatrix(double[][] mat, double[][] vector, int vectorCol)
  3. matrixAbsDiff(double m1[][], double m2[][])
  4. matrixConcatLR(double[][] LMatrix, double[][] RMatrix)
  5. matrixConcatUL(double[][] UMatrix, double[][] LMatrix)
  6. matrixDestructAdd(double[][] m1, double[][] m2)
  7. matrixDeterminant(final float[] m, final int m_offset)