Multiply a matrix by a scalar, C = s*A

@param s scalar
@return s*A
341033
public Matrix times(double s)
    {
        Matrix X = new Matrix(m, n);
        double[][] C = X.getArray();
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < n; j++)
            {
                C[i][j] = s * A[i][j];
            }
        }
        return X;
    }
912904
public static void multRow(Matrix A, int i, double[] c)
    {
        if(A.cols() != c.length)
            throw new ArithmeticException("Can not perform row update, length miss match " + A.cols() + " and " + c.length);
        multRow(A, i, 0, c.length, c);
    }
938346
public static double[] singularValues( DMatrixRMaj A ) {
        SingularValueDecomposition_F64<DMatrixRMaj> svd = DecompositionFactory_DDRM.svd(A.numRows,A.numCols,false,true,true);

        if( svd.inputModified() ) {
            A = A.copy();
        }
        if( !svd.decompose(A)) {
            throw new RuntimeException("SVD Failed!");
        }

        double sv[] = svd.getSingularValues();
        Arrays.sort(sv,0,svd.numberOfSingularValues());

        // change the ordering to ascending
        for (int i = 0; i < sv.length/2; i++) {
            double tmp = sv[i];
            sv[i] = sv[sv.length-i-1];
            sv[sv.length-i-1] = tmp;
        }

        return sv;
    }
489044
public IMatrix mul(Complex a) {
        IMatrix result = new IMatrix(rows, columns);
        mul(a, result);
        return result;
    }
576669
function flatten(matrix) {
    const res = [];

    // If the given matrix is not a matrix but a scalar.
    if (!Array.isArray(matrix)) {
        matrix = [
            [matrix]
        ];
    }

    matrix.forEach((row) => {
        // If the given matrix is a vector.
        if (!Array.isArray(row)) {
            row = [row];
        }

        row.forEach((elem) => {
            res.push(elem.real);
            res.push(elem.imag);
        });
    });
    return res;
}
409635
public Vec multiply(Vec b)
    {
        DenseVector result = new  DenseVector(rows());
        multiply(b, 1.0, result);
        return result;
    }
678890
public Vector2f mul(float scalar, Vector2f dest) {
        dest.x = x * scalar;
        dest.y = y * scalar;
        return dest;
    }
244015
public static void checkMatrixMultiplication() {

        DoubleMatrix A = new DoubleMatrix(new double[][]{
                    {1.0, 2.0, 3.0},
                    {4.0, 5.0, 6.0},
                    {7.0, 8.0, 9.0}
                });
        DoubleMatrix E = new DoubleMatrix(new double[][]{
                    {0.0, 0.0, 1.0},
                    {0.0, 1.0, 0.0},
                    {1.0, 0.0, 0.0}
                });
        DoubleMatrix B = new DoubleMatrix(new double[][]{
                    {3.0, 2.0, 1.0},
                    {6.0, 5.0, 4.0},
                    {9.0, 8.0, 7.0}
                });

        check("checking matrix multiplication", A.mmul(E).equals(B));
    }
120302
public static double elementSum( DMatrixSparseCSC A ) {
        if( A.nz_length == 0)
            return 0;

        double sum = 0;
        for(int i = 0; i < A.nz_length; i++ ) {
            sum += A.nz_values[i];
        }

        return sum;
    }
445042
public static DoubleMatrix getInstance(int rows, int cols, ItemSupplier s)
    {
        DoubleMatrix m = new DoubleMatrix(rows, cols);
        ItemConsumer c = m.consumer;
        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < cols; j++)
            {
                c.set(i, j, s.get(i, j));
            }
        }
        return m;
    }
732999
public static DenseCholesky factorize(Matrix A) {
        return new DenseCholesky(A.numRows(), true)
                .factor(new UpperSPDDenseMatrix(A));
    }
47097
public static double scalarProduct( double[] a, double[] b ) {
        double c = 0;
        for( int i = 0; i < a.length; i++ ) {
            c = c + a[i] * b[i];
        }
        return c;
    }
424762
public Matrix multiplyTranspose(final Matrix B, ExecutorService threadPool)
    {
        Matrix C = new DenseMatrix(this.rows(), B.rows());
        multiplyTranspose(B, C, threadPool);
        return C;
    }
1183896
public static <T extends Transform> T multiply (
        AffineTransform a, double m00, double m01, double m10, double m11, double tx, double ty, T into) {
        return multiply(a.m00, a.m01, a.m10, a.m11, a.tx, a.ty, m00, m01, m10, m11, tx, ty, into);
    }
1320237
function multiply_matrices(l, r) {
          var al = l[0];
          var cl = l[1];
          var el = l[2];
          var bl = l[3];
          var dl = l[4];
          var fl = l[5];

          var ar = r[0];
          var cr = r[1];
          var er = r[2];
          var br = r[3];
          var dr = r[4];
          var fr = r[5];

          var a = al * ar + cl * br;
          var c = al * cr + cl * dr;
          var e = al * er + cl * fr + el;
          var b = bl * ar + dl * br;
          var d = bl * cr + dl * dr;
          var f = bl * er + dl * fr + fl;

          return [a, c, e, b, d, f];
      }
4209
public Vector4d mul(double scalar, Vector4d dest) {
        dest.x = x * scalar;
        dest.y = y * scalar;
        dest.z = z * scalar;
        dest.w = w * scalar;
        return dest;
    }
11940
public static final DoubleMatrix2D fillSubdiagonalSymmetricMatrix(DoubleMatrix2D S){

		if(S.rows() != S.columns()){
			throw new IllegalArgumentException("Not square matrix");
		}

		boolean isSparse = S instanceof SparseDoubleMatrix2D;
		DoubleFactory2D F2D = (isSparse)? DoubleFactory2D.sparse: DoubleFactory2D.dense;
		final DoubleMatrix2D SFull = F2D.make(S.rows(), S.rows());

		if (isSparse) {
			S.forEachNonZero(new IntIntDoubleFunction() {
				@Override
				public double apply(int i, int j, double hij) {
					SFull.setQuick(i, j, hij);
					SFull.setQuick(j, i, hij);
					return hij;
				}
			});
		} else {
			for (int i = 0; i < S.rows(); i++) {
				for (int j = 0; j < i + 1; j++) {
					double sij = S.getQuick(i, j);
					SFull.setQuick(i, j, sij);
					SFull.setQuick(j, i, sij);
				}
			}
		}

		return SFull;
	}