Here you can find the source of matrix_x_vectorMatrix(double[][] mat, double[][] vector, int vectorCol)
Parameter | Description |
---|---|
mat | The matrix (m x n). |
vector | The matrix that only contains one column. It is a two-dimensional array, the parameter vectorCol determines which column holds the vector. |
vectorCol | The column that holds the vector data. |
public static double[] matrix_x_vectorMatrix(double[][] mat, double[][] vector, int vectorCol)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w . j a v a 2s.com * 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; } }