Java Array Multiply multiply(final double[] v1, final double[] v2)

Here you can find the source of multiply(final double[] v1, final double[] v2)

Description

multiply

License

Open Source License

Declaration

public static double[] multiply(final double[] v1, final double[] v2) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 Vienna University of Technology.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from ww w. j  a  v  a  2s.  com*/
 * Martin Fleck (Vienna University of Technology) - initial API and implementation
 *
 * Initially developed in the context of ARTIST EU project www.artist-project.eu
 *******************************************************************************/

public class Main {
    private static final String VECTORS_DIFFERENT_LENGTHS = "Vector v1 and v2 have different lengths";

    public static double[] multiply(final double[] v1, final double[] v2) {
        if (v1.length != v2.length) {
            throw new RuntimeException(VECTORS_DIFFERENT_LENGTHS);
        }

        final double[] result = new double[v1.length];
        for (int i = 0; i < result.length; i++) {
            result[i] = v1[i] * v2[i];
        }

        return result;
    }
}

Related

  1. multiply(double[] source, double num)
  2. multiply(double[] values, int offset, int stride, int length, double multiplier)
  3. multiply(final double[] a, double b, final double[] dest, int n)
  4. multiply(final double[] inout, final double[] in)
  5. multiply(final double[] lhs, final double[] rhs)
  6. multiply(final double[] x, final double[] y)
  7. multiply(final float[] complexA, final float[] complexB, final boolean overwriteA)
  8. multiply(final int[] numbers)
  9. multiply(float[] array, float factor)