Here you can find the source of arrayMultiplication(double[] a, double[] b)
Parameter | Description |
---|---|
a | a parameter |
b | a parameter |
Parameter | Description |
---|---|
ArrayStoreException | an exception |
public static double[] arrayMultiplication(double[] a, double[] b) throws ArrayStoreException
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w . j a v a 2 s . c o m * Elementwise multiplication of arrays * * @param a * @param b * @return double array containing a[i] * b[i] * @throws ArrayStoreException */ public static double[] arrayMultiplication(double[] a, double[] b) throws ArrayStoreException { if (a == null || b == null) { return null; } if (a.length != b.length) { throw new ArrayStoreException("Array sizes do not match."); } if (a.length == 0) { throw new ArrayStoreException("Array of length zero."); } double[] ret = new double[a.length]; for (int i = 0; i < ret.length; i++) { ret[i] = a[i] * b[i]; } return ret; } }