multiplies two passed double arrays element by element - Android java.lang

Android examples for java.lang:array calculation

Description

multiplies two passed double arrays element by element

Demo Code


//package com.java2s;

public class Main {
    /**// ww  w.  j av a 2s. com
     * multiplies two passed double arrays element by element
     * @param _a the first array
     * @param _b the second array
     * @return an array containing the element wise multiplication
     * of the passed arrays
     */
    public static double[] multiply(double[] _a, double[] _b) {
        double[] res = new double[_a.length];
        for (int i = 0; i < res.length; i++) {
            res[i] = _a[i] * _b[i];
        }
        return res;
    }
}

Related Tutorials