Java Vector Multiply vectorMult(final float[] result, final float[] m, final float[] v)

Here you can find the source of vectorMult(final float[] result, final float[] m, final float[] v)

Description

vector Mult

License

Open Source License

Declaration

public static void vectorMult(final float[] result, final float[] m, final float[] v) 

Method Source Code

//package com.java2s;
/*//from w w  w  . j  a  v  a  2 s  . co m
This file is part of jpcsp.
    
Jpcsp 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.
    
Jpcsp 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 Jpcsp.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static void vectorMult(final float[] result, final float[] m, final float[] v) {
        for (int i = 0; i < result.length; i++) {
            float s = v[0] * m[i];
            int k = i + 4;
            for (int j = 1; j < v.length; j++) {
                s += v[j] * m[k];
                k += 4;
            }
            result[i] = s;
        }
    }
}

Related

  1. vectorMatrixMultiply(double[][] matrix, double[] vector)
  2. vectorMult3D(float[] array, int vectorIndex, float scale)
  3. vectorMultiply(double s, double[] v)