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

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

Description

set c = a - b.

License

Open Source License

Parameter

Parameter Description
a a parameter
b a parameter
c a parameter

Declaration

public static void subtract(final double[] a, final double[] b,
        final double[] c) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   www  . j  av a  2 s.  c  o  m*/
     * set c = a - b. Dimensions of a, b, and c must match. In place subtraction
     * (c==a) is permitted.
     * 
     * @param a
     * @param b
     * @param c
     */
    public static void subtract(final double[] a, final double[] b,
            final double[] c) {
        assert (rows(a) == rows(b)) && (rows(a) == rows(c));

        final int rows = rows(a);

        for (int i = 0; i < rows; ++i)
            c[i] = a[i] - b[i];
    }

    public static int rows(final double[] a) {
        return a.length;
    }

    public static int rows(final double[][] A) {
        return A.length;
    }
}

Related

  1. subtract(double[] values, double value)
  2. subtract(double[] x, double c)
  3. subtract(double[][] a, double[][] b)
  4. subtract(double[][] a, double[][] b)
  5. subtract(double[][] dest, double[][] a, double[][] b)
  6. subtract(final double[] first, final double[] second)
  7. subtract(final double[] v1, final double[] v2)
  8. subtract(final double[] vector1, final double[] vector2)
  9. subtract(float a[][][], float b[][][])