com.aliasi.matrix
Class DenseMatrix

java.lang.Object
  extended by com.aliasi.matrix.AbstractMatrix
      extended by com.aliasi.matrix.DenseMatrix
All Implemented Interfaces:
Matrix

public class DenseMatrix
extends AbstractMatrix

A DenseMatrix is a matrix implementation suitable for matrices with primarily non-zero values. The dimensionality of a dense matrix is set at construction time and immutable afterwards. Values may be specified at construction time or given default values; they are mutable and may be reset after construction.

Implementation Note: A dense matrix represents the values with a two-dimensional array of primitive double values.

Since:
LingPipe2.0
Version:
2.4
Author:
Bob Carpenter

Constructor Summary
DenseMatrix(double[][] values)
          Construct a dense matrix with the specified values.
DenseMatrix(int numRows, int numColumns)
          Construct a dense matrix with the specified positive number of rows and columns.
 
Method Summary
 int numColumns()
          Returns the number of columns in the matrix.
 int numRows()
          Returns the number of rows in the matrix.
 void setValue(int row, int column, double value)
          Throw an unsupported operation exception.
 double value(int row, int column)
          Returns the value in the matrix at the specified row and column.
 
Methods inherited from class com.aliasi.matrix.AbstractMatrix
columnVector, equals, hashCode, rowVector
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DenseMatrix

public DenseMatrix(int numRows,
                   int numColumns)
Construct a dense matrix with the specified positive number of rows and columns. All values are initially 0.0.

Parameters:
numRows - Number of rows for this matrix.
numColumns - Number of columns for this matrix.
Throws:
IllegalArgumentException - If either the number of rows or columns is not positive.

DenseMatrix

public DenseMatrix(double[][] values)
Construct a dense matrix with the specified values. Row dimensionality is determined by the dimensionality of the specified array of values. Column dimensionality is specified as the maximum length of a row of specified values. Shorter rows in the specified values are filled with 0.0. All labels are initialized to null.

Parameters:
values - Two-dimensional array of values on which to base this matrix.
Throws:
IllegalArgumentException - If the either dimension of the values array is 0.
Method Detail

numRows

public final int numRows()
Description copied from interface: Matrix
Returns the number of rows in the matrix.

Specified by:
numRows in interface Matrix
Specified by:
numRows in class AbstractMatrix
Returns:
The number of rows in the matrix.

numColumns

public final int numColumns()
Description copied from interface: Matrix
Returns the number of columns in the matrix.

Specified by:
numColumns in interface Matrix
Specified by:
numColumns in class AbstractMatrix
Returns:
The number of columns in the matrix.

value

public double value(int row,
                    int column)
Description copied from interface: Matrix
Returns the value in the matrix at the specified row and column.

Specified by:
value in interface Matrix
Specified by:
value in class AbstractMatrix
Parameters:
row - The specified row.
column - The specified column.
Returns:
The value in the matrix at the specified row and column.

setValue

public void setValue(int row,
                     int column,
                     double value)
Description copied from class: AbstractMatrix
Throw an unsupported operation exception. This method should be overriden by value mutable subclasses.

Specified by:
setValue in interface Matrix
Overrides:
setValue in class AbstractMatrix
Parameters:
row - Ignored.
column - Ignored.
value - Ignored.