Java Array Multiply multiplyScalarInPlace(double[] a, double value)

Here you can find the source of multiplyScalarInPlace(double[] a, double value)

Description

Multiplies the specified value with each element of the input array and returns the result in place.

License

Apache License

Parameter

Parameter Description
a input array
value value to multiply with each element of input array

Declaration

public static final void multiplyScalarInPlace(double[] a, double value) 

Method Source Code

//package com.java2s;
/*//from  w ww  .  j a v  a  2  s.c o m
 * Copyright 2014 Jon N. Marsh.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * Multiplies the specified value with each element of the input array and
     * returns the result in place.
     *
     * @param a     input array
     * @param value   value to multiply with each element of input array
     */
    public static final void multiplyScalarInPlace(double[] a, double value) {
        multiplyScalarInPlace(a, 0, a.length, value);
    }

    /**
     * Multiplies the specified value with each element of the input array in
     * place, within the specified range of indices. No error checking is
     * performed on range limits; if the values are negative or outside the
     * range of the array, a runtime exception may be thrown.
     *
     * @param a     input array
     * @param from  initial index of the range to perform the multiplication,
     *              inclusive
     * @param to    final index of the range to perform the multiplication,
     *              exclusive
     * @param value   value to multiply with each element of input array {@code a}
     */
    public static final void multiplyScalarInPlace(double[] a, int from, int to, double value) {
        for (int i = from; i < to; i++) {
            a[i] *= value;
        }
    }

    /**
     * Multiplies the specified value with each element of the input array and
     * returns the result in place.
     *
     * @param a     input array
     * @param value   value to multiply with each element of input array
     */
    public static final void multiplyScalarInPlace(float[] a, float value) {
        multiplyScalarInPlace(a, 0, a.length, value);
    }

    /**
     * Multiplies the specified value with each element of the input array in
     * place, within the specified range of indices. No error checking is
     * performed on range limits; if the values are negative or outside the
     * range of the array, a runtime exception may be thrown.
     *
     * @param a     input array
     * @param from  initial index of the range to perform the multiplication,
     *              inclusive
     * @param to    final index of the range to perform the multiplication,
     *              exclusive
     * @param value   value to multiply with each element of input array {@code a}
     */
    public static final void multiplyScalarInPlace(float[] a, int from, int to, float value) {
        for (int i = from; i < to; i++) {
            a[i] *= value;
        }
    }
}

Related

  1. multiplyP8(int[] x)
  2. multiplyP8(int[] x)
  3. MultiplyPointSimilarityInhomogenous(double[] xp, int idx, double[] H, double[] x, int idx2)
  4. multiplyRange(double[] accumulator, int offset, double[] modulator)
  5. multiplyScalar(double[] a, double value)
  6. multiplySelf(double[] dest, double source)
  7. multiplySparse(int[][][] as, int A, int[][][] bs, int B, int[][][] cs)
  8. multiplySquares(float[] mat1, float[] mat2, int sidelength)
  9. multiplyValues(byte[] array, int multiplier)