public class MemoryCoOccurrenceMatrix extends java.lang.Object implements CoOccurrenceMatrix
| Modifier and Type | Field and Description |
|---|---|
private int[] |
data |
private int |
dimension |
private int |
dimSquare |
| Constructor and Description |
|---|
MemoryCoOccurrenceMatrix(int dimension)
Creates a new matrix that stores dimension times dimension int values in memory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Sets all counters to zero.
|
int |
getDimension()
Returns the dimension of this matrix.
|
int |
getValue(int i,
int j)
Returns the matrix value at a given position.
|
void |
incValue(int i,
int j)
Increases the counter for pair (i, j) by one.
|
void |
setValue(int i,
int j,
int newValue)
Sets the counter for pair (i, j) to a new value.
|
private final int dimension
private final int dimSquare
private final int[] data
public MemoryCoOccurrenceMatrix(int dimension)
dimension - the matrix' dimension, which is both the number of rows and columnspublic void clear()
CoOccurrenceMatrixclear in interface CoOccurrenceMatrixpublic int getDimension()
CoOccurrenceMatrixgetDimension in interface CoOccurrenceMatrixpublic int getValue(int i,
int j)
CoOccurrenceMatrixgetValue in interface CoOccurrenceMatrixi - column index, from 0 to CoOccurrenceMatrix.getDimension() - 1j - row index, from 0 to CoOccurrenceMatrix.getDimension() - 1public void incValue(int i,
int j)
throws java.lang.IllegalArgumentException
CoOccurrenceMatrixsetValue(i, j, getValue(i, j) + 1);.incValue in interface CoOccurrenceMatrixi - column index, from 0 to CoOccurrenceMatrix.getDimension() - 1j - row index, from 0 to CoOccurrenceMatrix.getDimension() - 1java.lang.IllegalArgumentException - for invalid index pairs (i, j)public void setValue(int i,
int j,
int newValue)
CoOccurrenceMatrixsetValue in interface CoOccurrenceMatrixi - column index, from 0 to CoOccurrenceMatrix.getDimension() - 1j - row index, from 0 to CoOccurrenceMatrix.getDimension() - 1