Example usage for org.apache.commons.math.linear SparseRealMatrix setEntry

List of usage examples for org.apache.commons.math.linear SparseRealMatrix setEntry

Introduction

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

Prototype

void setEntry(int row, int column, double value) throws MatrixIndexException;

Source Link

Document

Set the entry in the specified row and column.

Usage

From source file:org.interpss.core.sparse.UCTE2000SparseMatrixCasesTest.java

private SparseRealMatrix sparseMatrix2Ary(SparseEqnMatrix2x2 eqn) {
    int n = eqn.getDimension();
    System.out.println("J-matrix Demension:" + n);
    //RealMatrix m = new Array2DRowRealMatrix( n, n );
    SparseRealMatrix m = new OpenMapRealMatrix(n, n);
    int n_2 = n / 2;
    for (int i = 0; i < n_2; i++) { // index 1-N
        for (int j = 0; j < n_2; j++) {//index 1-N
            Matrix_xy mxy = eqn.getA(i + 1, j + 1);
            if (mxy.xx != 0.0)
                m.setEntry(2 * i, 2 * j, mxy.xx);
            if (mxy.xy != 0.0)
                m.setEntry(2 * i, 2 * j + 1, mxy.xy);
            if (mxy.yx != 0.0)
                m.setEntry(2 * i + 1, 2 * j, mxy.yx);
            if (mxy.yy != 0.0)
                m.setEntry(2 * i + 1, 2 * j + 1, mxy.yy);
        }/*from   w ww . j av  a 2  s.c o m*/
    }
    return m;
}