www.sdmetrics.com

com.sdmetrics.math
Class IntegerMatrix

java.lang.Object
  extended by com.sdmetrics.math.IntegerMatrix

public class IntegerMatrix
extends java.lang.Object

Realizes a sparse matrix of integers.

This implementation stores the coordinates and values of non-null entries in a hash map. Hence, memory consumption depends on the number of non-null entries in the matrix rather than the dimension of the matrix.


Constructor Summary
IntegerMatrix()
          Creates a new null matrix.
 
Method Summary
 java.lang.Integer get(int row, int col)
          Retrieves the integer at the given coordinates.
 java.lang.Integer increment(int row, int col)
          Increments the integer value at the given coordinates by one.
 boolean isEmpty()
          Tests whether this matrix is a null matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegerMatrix

public IntegerMatrix()
Creates a new null matrix.

Method Detail

increment

public java.lang.Integer increment(int row,
                                   int col)
Increments the integer value at the given coordinates by one.

Parameters:
row - Matrix row number. Must not be negative.
col - Matrix column number. Must not be negative.
Returns:
The new value at the given coordinates.

get

public java.lang.Integer get(int row,
                             int col)
Retrieves the integer at the given coordinates.

Parameters:
row - Matrix row number. Must not be negative.
col - Matrix column number. Must not be negative.
Returns:
Value at those coordinates.

isEmpty

public boolean isEmpty()
Tests whether this matrix is a null matrix.

Returns:
false if the matrix has any non-zero entries, else true.

www.sdmetrics.com