Java Array Subtract subtractRange(double[] accumulator, int offset, double[] values)

Here you can find the source of subtractRange(double[] accumulator, int offset, double[] values)

Description

Subtracts the elements of one array of doubles from another.

License

Open Source License

Parameter

Parameter Description
accumulator The array of <code>double</code>s to subtract the elements of <code>values</code> from (the elements of this array will be modified).
offset The index into <code>accumulator</code> at which to start subtracting the elements of <code>values</code>.
values The array of <code>double</code>s to subtract from each corresponding element of <code>accumulator</code>.

Return

A reference to accumulator.

Declaration

public static double[] subtractRange(double[] accumulator, int offset, double[] values) 

Method Source Code

//package com.java2s;
/**//w ww .java  2s  .c o m
 * Java Modular Image Synthesis Toolkit (JMIST)
 * Copyright (C) 2008-2013 Bradley W. Kimmel
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

public class Main {
    /**
     * Subtracts the elements of one array of <code>double</code>s from
     * another.
     * @param accumulator The array of <code>double</code>s to subtract the
     *     elements of <code>values</code> from (the elements of this array
     *     will be modified).
     * @param offset The index into <code>accumulator</code> at which to start
     *     subtracting the elements of <code>values</code>.
     * @param values The array of <code>double</code>s to subtract from each
     *     corresponding element of <code>accumulator</code>.
     * @return A reference to <code>accumulator</code>.
     */
    public static double[] subtractRange(double[] accumulator, int offset, double[] values) {
        assert (accumulator.length >= offset + values.length);
        for (int i = offset, j = 0; j < values.length; i++, j++) {
            accumulator[i] -= values[j];
        }
        return accumulator;
    }

    /**
     * Subtracts the elements of one array of <code>int</code>s from
     * another.
     * @param accumulator The array of <code>int</code>s to subtract the
     *     elements of <code>values</code> from (the elements of this array
     *     will be modified).
     * @param offset The index into <code>accumulator</code> at which to start
     *     subtracting the elements of <code>values</code>.
     * @param values The array of <code>int</code>s to subtract from each
     *     corresponding element of <code>accumulator</code>.
     * @return A reference to <code>accumulator</code>.
     */
    public static int[] subtractRange(int[] accumulator, int offset, int[] values) {
        assert (accumulator.length >= offset + values.length);
        for (int i = offset, j = 0; j < values.length; i++, j++) {
            accumulator[i] -= values[j];
        }
        return accumulator;
    }

    /**
     * Subtracts the elements of one array of <code>long</code>s from
     * another.
     * @param accumulator The array of <code>long</code>s to subtract the
     *     elements of <code>values</code> from (the elements of this array
     *     will be modified).
     * @param offset The index into <code>accumulator</code> at which to start
     *     subtracting the elements of <code>values</code>.
     * @param values The array of <code>long</code>s to subtract from each
     *     corresponding element of <code>accumulator</code>.
     * @return A reference to <code>accumulator</code>.
     */
    public static long[] subtractRange(long[] accumulator, int offset, long[] values) {
        assert (accumulator.length >= offset + values.length);
        for (int i = offset, j = 0; j < values.length; i++, j++) {
            accumulator[i] -= values[j];
        }
        return accumulator;
    }
}

Related

  1. subtractInPlace(double[] a, double[] b)
  2. subtractInPlace(double[] first, double[] second)
  3. subtractInPlace(final double[] a, final double[] b)
  4. subtractKeepPositiveValues(float[] dividend, float divisor)
  5. subtractMin(Double[] array)
  6. subtractSignals(double[] s1, double[] s2)
  7. subtractTo(double a[][][], double b[][][])
  8. subtractUnitsArray(int[] units1, int[] units2)
  9. SubtractVec2D(double[] vec2Ret, double[] vec2A, double[] vec2B)