Java Matrix Multiply multiplyVectorByMatrix(double[] v, double[][] m)

Here you can find the source of multiplyVectorByMatrix(double[] v, double[][] m)

Description

multiply vector by matrix

License

Open Source License

Parameter

Parameter Description
v a parameter
m a parameter

Return

result

Declaration

public static double[] multiplyVectorByMatrix(double[] v, double[][] m) 

Method Source Code

//package com.java2s;
/*//from w ww  .j  av a2  s . c om
 * Scaffold Hunter
 * Copyright (C) 2006-2008 PG504
 * Copyright (C) 2010-2011 PG552
 * See README.txt in the root directory of the Scaffold Hunter source tree
 * for details.
 *
 * Scaffold Hunter 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; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Scaffold Hunter 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, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * multiply vector by matrix
     * @param v
     * @param m
     * @return
     *  result
     */
    public static double[] multiplyVectorByMatrix(double[] v, double[][] m) {
        double[] result = new double[3];
        multiplyVectorByMatrix(v, m, result);
        return result;
    }

    /**
     * @param v
     * @param m
     * @param result
     */
    public static void multiplyVectorByMatrix(double[] v, double[][] m, double[] result) {
        result[0] = v[0] * m[0][0] + v[1] * m[1][0] + v[2] * m[2][0];
        result[1] = v[0] * m[0][1] + v[1] * m[1][1] + v[2] * m[2][1];
        result[2] = v[0] * m[0][2] + v[1] * m[1][2] + v[2] * m[2][2];
    }
}

Related

  1. multiplyQuad(final double[][] A, final double[][] B, final double[][] dest, int n)
  2. multiplyScalars(float[][] x, float[][] y)
  3. multiplyScalars_optimizedByKnowingBothAreRectangle(float[][] x, float[][] y)
  4. multiplySparse2dense(int[][][] as, int A, int[][][] bs, int B, int[][] c)
  5. multiplyVectorAndMatrix(double[] vector, double[][] matrix)