## com.aliasi.matrix Interface Matrix

All Known Implementing Classes:
AbstractMatrix, DenseMatrix, ProximityMatrix, SvdMatrix

`public interface Matrix`

A `Matrix` represents a 2-dimensional matrix. Matrices provide a fixed number of rows and columns, with values for each row and column.

An optional operation `setValue(int,int,double)` allows values to be set.

Two matrices should be equal if they have the same number of rows and columns and every value is equal. Their hash codes should be defined as specified in the documentation for `hashCode()`.

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

Method Summary
` Vector` `columnVector(int column)`
Returns the vector of values in the specified column.
` boolean` `equals(Object that)`
Returns `true` if the specified object is a matrix with the same number of rows and columns and the same value in every cell as this matrix.
` int` `hashCode()`
Return the hash code for the matrix.
` int` `numColumns()`
Returns the number of columns in the matrix.
` int` `numRows()`
Returns the number of rows in the matrix.
` Vector` `rowVector(int row)`
Returns the vector of values in the specified row.
` void` ```setValue(int row, int column, double value)```
Sets the value for the specified row and column to be the specified value.
` double` ```value(int row, int column)```
Returns the value in the matrix at the specified row and column.

Method Detail

### numRows

`int numRows()`
Returns the number of rows in the matrix.

Returns:
The number of rows in the matrix.

### numColumns

`int numColumns()`
Returns the number of columns in the matrix.

Returns:
The number of columns in the matrix.

### value

```double value(int row,
int column)```
Returns the value in the matrix at the specified row and column.

Parameters:
`row` - The specified row.
`column` - The specified column.
Returns:
The value in the matrix at the specified row and column.
Throws:
`IndexOutOfBoundsException` - If the row or column index are out of bounds for this matrix.

### setValue

```void setValue(int row,
int column,
double value)```
Sets the value for the specified row and column to be the specified value.

This operation is optional. Implementations may throw unsupported operation exceptions.

Parameters:
`row` - Specified row.
`column` - Specified column.
`value` - New value for specified row and column.
Throws:
`UnsupportedOperationException` - If this operation is not supported.
`IndexOutOfBoundsException` - If the row or column index are out of bounds for this matrix.

### rowVector

`Vector rowVector(int row)`
Returns the vector of values in the specified row. The dimensionality of the returned vector will be the number of columns in this matrix.

Changes to the returned vector will affect this matrix and vice-versa. To circumvent this dependency, clone the result.

Parameters:
`row` - Index of row whose vector is returned.
Returns:
Row vector for specified row.
Throws:
`IndexOutOfBoundsException` - If the row index is out of bounds for this matrix.

### columnVector

`Vector columnVector(int column)`
Returns the vector of values in the specified column. The dimensionality of the returned vector will be the number of rows in this matrix.

Changes to the returned vector will affect this matrix and vice-versa. To circumvent this dependency, clone the result.

Parameters:
`column` - Index of column whose vector is returned.
Returns:
Column vector for specified column.
Throws:
`IndexOutOfBoundsException` - If the column index is out of bounds for this matrix.

### equals

`boolean equals(Object that)`
Returns `true` if the specified object is a matrix with the same number of rows and columns and the same value in every cell as this matrix.

Overrides:
`equals` in class `Object`
Parameters:
`that` - Object to test for equality with this matrix.
Returns:
`true` if the specified object is a matrix with the same values and number of rows and columns as this matrix.

### hashCode

`int hashCode()`
Return the hash code for the matrix. The hash code of a matrix is computed value-wise as if it were a `java.util.List` of `java.lang.Double` values ordered row by row:
```   int hashCode = 1;
for (int i = 0; i < numRows(); ++i) {
for (int j = 0; j < numColumns(); ++j) {
int v = Double.doubleToLongBits(value(i,j));
int valHash = (int) (v^(v>>>32));
hashCode = 31*hashCode + valHash;
}
}
```
Note that this definition is consistent with `equals(Object)`.

Overrides:
`hashCode` in class `Object`
Returns:
The hash code for this matrix.