Java Matrix Multiply multiply(double[][] m, double[] x)

Here you can find the source of multiply(double[][] m, double[] x)

Description

Multiply a square matrix and a vector.

License

Open Source License

Declaration

public static double[] multiply(double[][] m, double[] x) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from  www  .  j  a v  a  2 s.co m
     *  Multiply a square matrix and a vector. 
    Note that matrix width and vector length have to be equal, otherwise null is returned.
     */
    public static double[] multiply(double[][] m, double[] x) {
        assert (m[0].length == x.length);
        double[] y = new double[m.length];
        for (int i = 0; i < m.length; i++)
            for (int j = 0; j < x.length; j++) {
                y[i] += m[i][j] * x[j];
            }

        return y;
    }
}

Related

  1. multiply(boolean[][] m1, boolean[][] m2)
  2. multiply(boolean[][] matrix, boolean[] vector)
  3. multiply(double[][] a, double[][] b)
  4. multiply(double[][] a, double[][] x)
  5. multiply(double[][] dest, double[][] a, double[][] b)
  6. multiply(double[][] m1, double[][] m2)
  7. multiply(double[][] p, double[][] q)
  8. multiply(double[][] x, double[][] y)
  9. multiply(final double[][] A, final double[][] B)