Here you can find the source of multiply(final double[] x, final double[] y)
Parameter | Description |
---|---|
first | a parameter |
second | a parameter |
Parameter | Description |
---|---|
ArrayIndexOutOfBoundsException | if the arrays are of unequal length |
final public static double[] multiply(final double[] x, final double[] y)
//package com.java2s; /*//from ww w. java2s. c o m * ==================================================== * Copyright (C) 2013 by Idylwood Technologies, LLC. All rights reserved. * * Developed at Idylwood Technologies, LLC. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * The License should have been distributed to you with the source tree. * If not, it can be found at * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Author: Charles Cooper * Date: 2013 * ==================================================== */ public class Main { /** * Returns newly allocated array which is the result * of termwise multiplication of the input arrays * @param first * @param second * @throws ArrayIndexOutOfBoundsException if the arrays are of unequal length * @return * Side Effects: Allocation of the returned array */ final public static double[] multiply(final double[] x, final double[] y) { final int len = x.length; if (len != y.length) throw new ArrayIndexOutOfBoundsException("Tried to multiply two vectors of unequal length!"); final double ret[] = new double[len]; for (int i = 0; i < len; i++) ret[i] = x[i] * y[i]; return ret; } }