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

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

Introduction

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

Prototype

public static void checkColumnIndex(final AnyMatrix m, final int column) throws OutOfRangeException 

Source Link

Document

Check if a column index is valid.

Usage

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

/** {@inheritDoc} */
@Override/*from   www.j  ava2 s. c  o  m*/
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// ww  w.j  a va2  s .  c om
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  .ja  v  a 2  s.c om
 */
@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  w ww . j  a  va2  s . c  o  m
 */
@Override
public void setEntry(int row, int column, double value) throws OutOfRangeException {
    int rowIndex, columnIndex;
    if (isTransposed) {
        rowIndex = column;
        columnIndex = row;
    } else {
        rowIndex = row;
        columnIndex = column;
    }
    //        MatrixUtils.checkRowIndex(this, row);
    MatrixUtils.checkColumnIndex(this, column);
    if (value == 0.0) {
        entries.remove(computeKey(rowIndex, columnIndex));
    } else {
        entries.put(computeKey(rowIndex, columnIndex), value);
    }
}

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

/**
 * {@inheritDoc}//w  w  w  .j a  v a2  s.c  om
 */
@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  w w.  j  a v  a2  s .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);
    }
}