Example usage for org.apache.commons.math.linear RealMatrix multiplyEntry

List of usage examples for org.apache.commons.math.linear RealMatrix multiplyEntry

Introduction

In this page you can find the example usage for org.apache.commons.math.linear RealMatrix multiplyEntry.

Prototype

void multiplyEntry(int row, int column, double factor) throws MatrixIndexException;

Source Link

Document

Change an entry in the specified row and column.

Usage

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);
        }
    }
}