Here you can find the source of multiplyVectorAndMatrix(double[] vector, double[][] matrix)
Parameter | Description |
---|---|
vector | Vector of integers. |
matrix | Matrix of integers. |
public static double[] multiplyVectorAndMatrix(double[] vector, double[][] matrix)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w . j a v a 2 s . c o m*/ * Multiplies a vector and a matrix. The multiplication order is: vector * * matrix. The result of multiplication is a vector. * * @param vector Vector of integers. * @param matrix Matrix of integers. * @return Vector result of multiplication of the vector and matrix. */ public static double[] multiplyVectorAndMatrix(double[] vector, double[][] matrix) { double[] res = new double[matrix.length]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < vector.length; j++) { res[i] += matrix[i][j] * vector[j]; } } return res; } /** * Multiplies a vector and a matrix. The multiplication order is: vector * * matrix. The result of multiplication is a vector. * * @param vector Vector of integers. * @param matrix Matrix of integers. * @return Vector result of multiplication of the vector and matrix. */ public static double[] multiplyVectorAndMatrix(int[] vector, int[][] matrix) { double[] res = new double[matrix.length]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < vector.length; j++) { res[i] += (double) matrix[i][j] * (double) vector[j]; } } return res; } }