Here you can find the source of multiplyScalarInPlace(double[] a, double value)
Parameter | Description |
---|---|
a | input array |
value | value to multiply with each element of input array |
public static final void multiplyScalarInPlace(double[] a, double value)
//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; } } }