List of usage examples for org.apache.commons.math.linear RealMatrix multiplyEntry
void multiplyEntry(int row, int column, double factor) throws MatrixIndexException;
From source file:org.mitre.math.linear.RealMatrixUtils.java
/** * Multiply a matrix by a scalar, C = s*A * @param s scalar// w w w.j a v a 2 s . c om * @return s*A */ public RealMatrix times(RealMatrix A, double s) { int m = A.getRowDimension(); int n = A.getColumnDimension(); RealMatrix C = getNewRealMatrix(m, n); //double[][] C = X.getArray(); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { C.multiplyEntry(i, j, s); //C[i][j] = s*A[i][j]; } } return C; }
From source file:org.mitre.math.linear.RealMatrixUtils.java
/** * Multiply a matrix by a scalar in place, A = s*A * @param s scalar/* w w w.j a v a 2 s . co m*/ * @return replace A by s*A */ public void timesEquals(RealMatrix A, double s) { int m = A.getRowDimension(); int n = A.getColumnDimension(); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { //A[i][j] = s*A[i][j]; A.multiplyEntry(i, j, s); } } }