Java Matrix Multiply matrixmultiply(final double[][] A, final double[] b)

Here you can find the source of matrixmultiply(final double[][] A, final double[] b)

Description

Multiply matrix A with vector b.

License

Open Source License

Parameter

Parameter Description
A the matrix
b the vector

Return

A b

Declaration

public static double[] matrixmultiply(final double[][] A, final double[] b) 

Method Source Code

//package com.java2s;
/**// w w w . j  av  a  2  s  . c om
*  This program is free software; you can
*  redistribute it and/or modify it under the terms of the GNU General Public
*  License as published by the Free Software Foundation (version 2). This
*  program is distributed in the hope that it will be useful, but WITHOUT ANY
*  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
*  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
*  details. You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

public class Main {
    /**
     *  Multiply matrix A with vector b.
     *
     *@param  A  the matrix
     *@param  b  the vector
     *@return    A b
     */
    public static double[] matrixmultiply(final double[][] A, final double[] b) {
        double[] answer = new double[b.length];
        // this assumes A is a square matrix
        for (int row = 0; row < answer.length; ++row)
            for (int col = 0; col < b.length; ++col)
                answer[row] += A[row][col] * b[col];

        return answer;
    }
}

Related

  1. matrixMultiplication(double[][] w, double[][] v)
  2. matrixMultiply(double[][] A, double[][] B, int aHeight, int bWidth, int comm, int bz, double[][] C)
  3. matrixMultiply(double[][] A, double[][] B, int n)
  4. matrixMultiply(double[][] M, float[] V)
  5. matrixMultiply(double[][] M1, double[][] M2)
  6. matrixMultiplyTwo(final double[][] first, final double[][] second)
  7. matrixMultiplyWithThreadOffset(double[] A, double[] Adiag, double[] B, int aHeight, int bWidth, int comm, int bz, int threadRowOffset, int rowOffset, double[] C)
  8. matrixScalarMultiplication(double[][] w, double v)
  9. multiply(boolean[][] m1, boolean[][] m2)