com.aliasi.matrix

## Class ProximityMatrix

• All Implemented Interfaces:
Matrix

```public class ProximityMatrix
extends AbstractMatrix```
A `ProximityMatrix` provides a pseudo-metric of proximities between points. As a matrix, proximity matrices are symmetric, contain only non-negative values and have `0.0` values on the diagonal.

Implementation Note: Proximity matrices are implemented as a wrapper around a triangular matrix of primitive double values without the diagonal values.

Since:
LingPipe2.0
Version:
3.0
Author:
Bob Carpenter
• ### Constructor Summary

Constructors
Constructor and Description
`ProximityMatrix(int numDimensions)`
Construct a square proximity matrix of the specified dimensionality, with all values initially zero.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`int` `numColumns()`
Returns the number of columns for this matrix.
`int` `numRows()`
Returns the number of rows for this matrix.
`void` ```setValue(int row, int column, double value)```
Sets the value for the specified row and column to the specified non-negative value as well as swapping row for column for symmetry.
`double` ```value(int row, int column)```
Returns the value in this proximity matrix for 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

• #### ProximityMatrix

`public ProximityMatrix(int numDimensions)`
Construct a square proximity matrix of the specified dimensionality, with all values initially zero.
Parameters:
`numDimensions` - Number of dimensions.
• ### Method Detail

• #### numColumns

`public int numColumns()`
Returns the number of columns for this matrix. The number of rows is the same as the number of columns.
Specified by:
`numColumns` in interface `Matrix`
Specified by:
`numColumns` in class `AbstractMatrix`
Returns:
The number of columns for this matrix.
• #### numRows

`public int numRows()`
Returns the number of rows for this matrix. The number of rows is the same as the number of columns.
Specified by:
`numRows` in interface `Matrix`
Specified by:
`numRows` in class `AbstractMatrix`
Returns:
The number of rows for this matrix.
• #### setValue

```public void setValue(int row,
int column,
double value)```
Sets the value for the specified row and column to the specified non-negative value as well as swapping row for column for symmetry. Thus `setValue(i,j,x)` sets the value for row `i` and column `j` to `x` as well as setting the value for row `j` and column `i` to `x`.
Specified by:
`setValue` in interface `Matrix`
Overrides:
`setValue` in class `AbstractMatrix`
Parameters:
`row` - Matrix row.
`column` - Matrix column.
`value` - Value to set for row and column and reverse.
Throws:
`IllegalArgumentException` - If the row and column are the same or if the value is negative or not a number.
`IndexOutOfBoundsException` - If the row or column are less than 0 or greater than the dimensionality of this proximity matrix.
• #### value

```public double value(int row,
int column)```
Returns the value in this proximity matrix for the specified row and column.
Specified by:
`value` in interface `Matrix`
Specified by:
`value` in class `AbstractMatrix`
Parameters:
`row` - Specified row.
`column` - Specified column.
Returns:
Value for the specified row and column.
Throws:
`IndexOutOfBoundsException` - If the row or column are negative or greater than or equal to the dimensionality of this matrix.