Java Array Multiply multiplyByScalar(double scalar, double[] vector)

Here you can find the source of multiplyByScalar(double scalar, double[] vector)

Description

Returns a new vector which is the multiplication of the given vector by a scalar.

License

Open Source License

Parameter

Parameter Description
scalar a parameter
vector a parameter

Declaration

public static double[] multiplyByScalar(double scalar, double[] vector) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from  ww  w  .j  a v a  2s .  c  o m*/
     * Returns a new vector which is the multiplication of the given vector by a scalar.
     * @param scalar
     * @param vector
     * @return
     */
    public static double[] multiplyByScalar(double scalar, double[] vector) {
        double[] ret = new double[vector.length];
        for (int i = 0; i < vector.length; ++i) {
            ret[i] = scalar * vector[i];
        }
        return ret;
    }
}

Related

  1. multiply(long[] x, long[] y, long[] z)
  2. multiply(String[] strings, String placeholder, String[] replacements)
  3. multiplyAndSum(double[] r1, double[] r2)
  4. multiplyAndSum(final double[] d, final double scale)
  5. multiplyArray(float[] array, float num)
  6. multiplyBytes(byte[] in, int count, int mul)
  7. multiplyComplex(double[] one, double[] two)
  8. multiplyComplexVectors(float[] cA, float[] cB, long limit)
  9. multiplycst(int k, double[] t)