Java Array Multiply multiplyRange(double[] accumulator, int offset, double[] modulator)

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

Description

Multiplies all the elements in an array of doubles by the elements of an equally sized array of doubles.

License

Open Source License

Parameter

Parameter Description
accumulator The array of <code>double</code>s that is to have its elements scaled (the elements of this array will be modified).
offset The index into <code>accumulator</code> at which to start multiplying by elements of <code>modulator</code>.
modulator The array of <code>double</code>s by which to multiply each corresponding element of <code>accumulator</code>.

Return

A reference to accumulator.

Declaration

public static double[] multiplyRange(double[] accumulator, int offset, double[] modulator) 

Method Source Code

//package com.java2s;
/**/* ww  w  .  j  ava 2  s.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 {
    /**
     * Multiplies all the elements in an array of <code>double</code>s by the
     * elements of an equally sized array of <code>double</code>s.
     * @param accumulator The array of <code>double</code>s that is to have its
     *     elements scaled (the elements of this array will be modified).
     * @param offset The index into <code>accumulator</code> at which to start
     *     multiplying by elements of <code>modulator</code>.
     * @param modulator The array of <code>double</code>s by which to multiply
     *     each corresponding element of <code>accumulator</code>.
     * @return A reference to <code>accumulator</code>.
     */
    public static double[] multiplyRange(double[] accumulator, int offset, double[] modulator) {
        assert (accumulator.length >= offset + modulator.length);
        for (int i = offset, j = 0; j < modulator.length; i++, j++) {
            accumulator[i] *= modulator[j];
        }
        return accumulator;
    }

    /**
     * Multiplies all the elements in an array of <code>int</code>s by the
     * elements of an equally sized array of <code>int</code>s.
     * @param accumulator The array of <code>int</code>s that is to have its
     *     elements scaled (the elements of this array will be modified).
     * @param offset The index into <code>accumulator</code> at which to start
     *     multiplying by elements of <code>modulator</code>.
     * @param modulator The array of <code>int</code>s by which to multiply
     *     each corresponding element of <code>accumulator</code>.
     * @return A reference to <code>accumulator</code>.
     */
    public static int[] multiplyRange(int[] accumulator, int offset, int[] modulator) {
        assert (accumulator.length >= offset + modulator.length);
        for (int i = offset, j = 0; j < modulator.length; i++, j++) {
            accumulator[i] *= modulator[j];
        }
        return accumulator;
    }

    /**
     * Multiplies all the elements in an array of <code>long</code>s by the
     * elements of an equally sized array of <code>long</code>s.
     * @param accumulator The array of <code>long</code>s that is to have its
     *     elements scaled (the elements of this array will be modified).
     * @param offset The index into <code>accumulator</code> at which to start
     *     multiplying by elements of <code>modulator</code>.
     * @param modulator The array of <code>long</code>s by which to multiply
     *     each corresponding element of <code>accumulator</code>.
     * @return A reference to <code>accumulator</code>.
     */
    public static long[] multiplyRange(long[] accumulator, int offset, long[] modulator) {
        assert (accumulator.length >= offset + modulator.length);
        for (int i = offset, j = 0; j < modulator.length; i++, j++) {
            accumulator[i] *= modulator[j];
        }
        return accumulator;
    }
}

Related

  1. multiplyP(int[] x)
  2. multiplyP(int[] x)
  3. multiplyP8(int[] x)
  4. multiplyP8(int[] x)
  5. MultiplyPointSimilarityInhomogenous(double[] xp, int idx, double[] H, double[] x, int idx2)
  6. multiplyScalar(double[] a, double value)
  7. multiplyScalarInPlace(double[] a, double value)
  8. multiplySelf(double[] dest, double source)
  9. multiplySparse(int[][][] as, int A, int[][][] bs, int B, int[][][] cs)