Java examples for java.lang:Math Matrix
Multiplies a matrix with another matrix that only has one column.
//package com.java2s; public class Main { /**// w ww .j a va2 s . c om * Multiplies a matrix with another matrix that only has one column. * @param mat The matrix (m x n). * @param vector The matrix that only contains one column. It is a * two-dimensional array, the parameter vectorCol determines which column * holds the vector. * @param vectorCol The column that holds the vector data. * @return The resulting matrix of size m x 1. */ public static double[] matrix_x_vectorMatrix(double[][] mat, double[][] vector, int vectorCol) { final int m = mat.length; final int n = mat[0].length; double[] res = new double[m]; for (int row = 0; row < m; row++) { for (int col = 0; col < n; col++) { res[col] += mat[row][col] * vector[col][vectorCol]; } } return res; } }