Java Matrix to Vector matrixVector(double[][] w, double[] v)

Here you can find the source of matrixVector(double[][] w, double[] v)

Description

matrix Vector

License

Open Source License

Declaration

public static double[] matrixVector(double[][] w, double[] v) 

Method Source Code

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

public class Main {
    public static double[] matrixVector(double[][] w, double[] v) {
        int w1 = w.length;
        int w2 = w[0].length;
        int v1 = v.length;

        if (w2 != v1) {
            System.out.println("Matrix dimensions do not agree...");
            System.exit(-1);//w w w. j a  v a  2s. co m
        }

        double[] result = new double[w1];
        for (int w_i1 = 0; w_i1 < w1; w_i1++) {
            double sum = 0;
            for (int w_i2 = 0; w_i2 < w2; w_i2++) {
                sum += w[w_i1][w_i2] * v[w_i2];
            }
            result[w_i1] = sum;
        }
        return result;
    }
}

Related

  1. matrix2Vector(double[][] m)
  2. matrix2vector(int[][] matrix)
  3. matrixToVectorArray(int M, int N, float[][] a, float[] b)
  4. matrixToVectorArray(int M, int N, float[][] a, float[] b)
  5. matrixVectorProductVDw(final double[][] V, final double[] d, final double[] w, final double[] a, int l1, int l2)