Java Utililty Methods Array Subtract

List of utility methods to do Array Subtract

Description

The list of methods to do Array Subtract are organized into topic(s).

Method

double[]subtract(double[] first, double[] second)
Subtracts second array from the first
if (first.length != second.length) {
    throw new Exception("Lengths of arrays are not equal");
double[] returnValues = new double[first.length];
for (int i = 0; i < returnValues.length; i++) {
    returnValues[i] = first[i] - second[i];
return returnValues;
...
double[]subtract(double[] first, double[] second, double[] out)
Subtracts the values of the first vector from the second vector and puts the result into out.
if (out == null) {
    out = new double[first.length];
if (first.length != second.length || second.length != out.length || first.length != out.length) {
    throw new IllegalArgumentException(
            "Same size vectors expected: " + first.length + ", " + second.length + ", " + out.length);
for (int i = 0; i < first.length; i++) {
...
double[]subtract(double[] flowFrom, double[] flowTo)
subtract
if (flowFrom.length == flowTo.length) {
    double[] netFlow = new double[flowFrom.length];
    for (int i = 0; i < flowTo.length; i++) {
        netFlow[i] = flowFrom[i] - flowTo[i];
    return netFlow;
} else
    return null;
...
double[]subtract(double[] p1, double[] p2)
subtract
int nd = p1.length;
double[] out = new double[nd];
for (int d = 0; d < nd; d++) {
    out[d] = p1[d] - p2[d];
return out;
double[]subtract(double[] res, double[] subtractor)
Subtract two arrays
for (int i = 0; i < res.length; i++) {
    res[i] -= subtractor[i];
return res;
double[]subtract(double[] values, double value)
Subtracts a value from every value in the array
double[] result = new double[values.length];
for (int i = 0; i < values.length; i++) {
    result[i] = values[i] - value;
return result;
double[]subtract(double[] x, double c)
subtract
int n = x.length;
double[] y = new double[n];
for (int i = 0; i < n; i++) {
    y[i] = x[i] - c;
return y;
double[][]subtract(double[][] a, double[][] b)
Subtracts the two arrays.
int size = Math.min(a.length, b.length);
double[][] result = new double[size][];
for (int i = 0; i < size; i++)
    result[i] = subtract(a[i], b[i]);
return result;
double[][]subtract(double[][] a, double[][] b)
subtract
double[][] d = new double[a.length][a[0].length];
if (isIdenticalMatrix(a, b)) {
    for (int i = 0; i < a.length; i++) {
        for (int j = 0; j < a[0].length; j++) {
            d[i][j] = a[i][j] - b[i][j];
} else {
...
voidsubtract(double[][] dest, double[][] a, double[][] b)
subtract
for (int i = 0; i < dest.length; i++) {
    for (int j = 0; j < dest[i].length; j++) {
        dest[i][j] = a[i][j] - b[i][j];