Example usage for org.apache.commons.math3.linear MatrixUtils checkRowIndex

List of usage examples for org.apache.commons.math3.linear MatrixUtils checkRowIndex

Introduction

In this page you can find the example usage for org.apache.commons.math3.linear MatrixUtils checkRowIndex.

Prototype

public static void checkRowIndex(final AnyMatrix m, final int row) throws OutOfRangeException 

Source Link

Document

Check if a row index is valid.

Usage

From source file:com.datumbox.framework.core.common.dataobjects.MapRealMatrix.java

/** {@inheritDoc} */
@Override/*from w w w  .j a  v a2 s  .  com*/
public double getEntry(int row, int column) throws OutOfRangeException {
    MatrixUtils.checkRowIndex(this, row);
    MatrixUtils.checkColumnIndex(this, column);
    return entries.getOrDefault(computeKey(row, column), 0.0);
}

From source file:com.datumbox.framework.core.common.dataobjects.MapRealMatrix.java

/** {@inheritDoc} */
@Override//from w  w w . j  a v a2 s.  com
public void setEntry(int row, int column, double value) throws OutOfRangeException {
    MatrixUtils.checkRowIndex(this, row);
    MatrixUtils.checkColumnIndex(this, column);
    if (value == 0.0) {
        entries.remove(computeKey(row, column)); //if it is exactly 0.0 don't store it. Also make sure you remove any previous key.
    } else {
        entries.put(computeKey(row, column), value);
    }
}

From source file:lirmm.inria.fr.math.BigSparseRealMatrix.java

/**
 * {@inheritDoc}/*from   w w w  .j  av a 2s. c  o m*/
 */
@Override
public double getEntry(int row, int column) throws OutOfRangeException {
    int rowIndex, columnIndex;
    if (isTransposed) {
        rowIndex = column;
        columnIndex = row;
    } else {
        rowIndex = row;
        columnIndex = column;
    }
    MatrixUtils.checkRowIndex(this, row);
    MatrixUtils.checkColumnIndex(this, column);
    return entries.get(computeKey(rowIndex, columnIndex));
}

From source file:lirmm.inria.fr.math.BigSparseRealMatrix.java

/**
 * {@inheritDoc}/*from www. ja v  a  2 s  . co  m*/
 */
@Override
public void addToEntry(int row, int column, double increment) throws OutOfRangeException {
    MatrixUtils.checkRowIndex(this, row);
    MatrixUtils.checkColumnIndex(this, column);
    int rowIndex, columnIndex;
    if (isTransposed) {
        rowIndex = column;
        columnIndex = row;
    } else {
        rowIndex = row;
        columnIndex = column;
    }
    final long key = computeKey(rowIndex, columnIndex);
    final double value = entries.get(key) + increment;
    if (value == 0.0) {
        entries.remove(key);
    } else {
        entries.put(key, value);
    }
}

From source file:lirmm.inria.fr.math.BigSparseRealMatrix.java

/**
 * {@inheritDoc}//from  w ww  . jav  a 2s  . co  m
 */
@Override
public void multiplyEntry(int row, int column, double factor) throws OutOfRangeException {
    MatrixUtils.checkRowIndex(this, row);
    MatrixUtils.checkColumnIndex(this, column);
    int rowIndex, columnIndex;
    if (isTransposed) {
        rowIndex = column;
        columnIndex = row;
    } else {
        rowIndex = row;
        columnIndex = column;
    }
    final long key = computeKey(rowIndex, columnIndex);
    final double value = entries.get(key) * factor;
    if (value == 0.0) {
        entries.remove(key);
    } else {
        entries.put(key, value);
    }
}