Here you can find the source of matrixTrans_x_matrix(double[][] mat)
Parameter | Description |
---|---|
mat | The matrix (m x n). |
public static double[][] matrixTrans_x_matrix(double[][] mat)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w. j av a 2 s. c o m * First transposes a matrix, then multiplies it with the original matrix. * @param mat The matrix (m x n). * @return The resulting matrix of size n x n. */ public static double[][] matrixTrans_x_matrix(double[][] mat) { final int m = mat.length; final int n = mat[0].length; // result is a symetrical square matrix double[][] res = new double[n][n]; for (int r = 0; r < n; r++) { for (int c = r; c < n; c++) { for (int i = 0; i < m; i++) { res[r][c] += mat[i][r] * mat[i][c]; } // mirror result on diagonal axis res[c][r] = res[r][c]; } } return res; } }