Java Array Scale arrayScale(final Double[] first, final double scale)

Here you can find the source of arrayScale(final Double[] first, final double scale)

Description

Scales the elements of the arrays with a contstant.

License

Apache License

Parameter

Parameter Description
first First array: a
scale constant: c

Return

new array with elements e: e_i = a_i *c

Declaration

public static Double[] arrayScale(final Double[] first, final double scale) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from  w  ww  .ja va 2s . co m*/
     * Scales the elements of the arrays with a contstant.
     *
     * @param first First array: a
     * @param scale constant: c
     * @return new array with elements e: e_i = a_i *c
     */
    public static Double[] arrayScale(final Double[] first, final double scale) {
        final Double[] toret = new Double[first.length];
        for (int i = 0; i < first.length; i++) {
            toret[i] = first[i] * scale;
        }
        return toret;
    }
}

Related

  1. expandToLength16(byte scaledValue[], final boolean isNegative)
  2. minMaxScale(final double[] x)
  3. scale(double[][] as)
  4. scale(final double[] a, double scale)