Java Array Subtract subtract(double[] a, double[] b)

Here you can find the source of subtract(double[] a, double[] b)

Description

Returns the array-wise difference between two vectors.

License

Open Source License

Parameter

Parameter Description
a - the first vector of doubles.
b - the second vector of doubles.

Return

the result of subtracting the first vector of doubles from the second.

Declaration


public static double[] subtract(double[] a, double[] b) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from w  w w.j  a  va  2 s . c o m
     * Returns the array-wise difference between two vectors.
     * @param a - the first vector of doubles.
     * @param b - the second vector of doubles.
     * @return the result of subtracting the first vector of doubles from the second.
     */

    public static double[] subtract(double[] a, double[] b) {
        double[] out = new double[a.length];
        for (int i = 0; i < a.length; i++) {
            out[i] = a[i] - b[i];
        }
        return out;
    }
}

Related

  1. arraySubtract(double[] x1, double[] x2)
  2. arraySubtract(final Double[] first, final Double[] second)
  3. subtract(byte[] a, byte[] b)
  4. subtract(double[] a, double[] b)
  5. subtract(double[] a, double[] b)
  6. subtract(double[] a, double[] b)
  7. subtract(double[] accumulator, double[] values)