JIU 0.12.0 Homepage

net.sourceforge.jiu.color.data
Class MemoryCoOccurrenceMatrix

java.lang.Object
  extended bynet.sourceforge.jiu.color.data.MemoryCoOccurrenceMatrix
All Implemented Interfaces:
CoOccurrenceMatrix

public class MemoryCoOccurrenceMatrix
extends Object
implements CoOccurrenceMatrix

This class stores a co-occurrence matrix, a two-dimensional array of int counters. The dimension is given to the constructor which allocates a corresponding array.

Author:
Marco Schmidt

Constructor Summary
MemoryCoOccurrenceMatrix(int dimension)
          Creates a new matrix that stores dimension times dimension int values in memory.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryCoOccurrenceMatrix

public MemoryCoOccurrenceMatrix(int dimension)
Creates a new matrix that stores dimension times dimension int values in memory. Given that array index values are of type int, this limits dimension to about 46000 (sqrt(Integer.MAX_VALUE). In practice, dimension leads to dimension times dimenstion times 4 bytes being allocated, so that memory available to the JVM may become a decisive factor.

Parameters:
dimension - the matrix' dimension, which is both the number of rows and columns
Method Detail

clear

public void clear()
Description copied from interface: CoOccurrenceMatrix
Sets all counters to zero.

Specified by:
clear in interface CoOccurrenceMatrix

getDimension

public int getDimension()
Description copied from interface: CoOccurrenceMatrix
Returns the dimension of this matrix. This is the number of rows and columns.

Specified by:
getDimension in interface CoOccurrenceMatrix
Returns:
matrix dimension (larger than zero)

getValue

public int getValue(int i,
                    int j)
Description copied from interface: CoOccurrenceMatrix
Returns the matrix value at a given position.

Specified by:
getValue in interface CoOccurrenceMatrix
Parameters:
i - column index, from 0 to CoOccurrenceMatrix.getDimension() - 1
j - row index, from 0 to CoOccurrenceMatrix.getDimension() - 1

incValue

public void incValue(int i,
                     int j)
              throws IllegalArgumentException
Description copied from interface: CoOccurrenceMatrix
Increases the counter for pair (i, j) by one. This method can be implemented by the call setValue(i, j, getValue(i, j) + 1);.

Specified by:
incValue in interface CoOccurrenceMatrix
Parameters:
i - column index, from 0 to CoOccurrenceMatrix.getDimension() - 1
j - row index, from 0 to CoOccurrenceMatrix.getDimension() - 1
Throws:
IllegalArgumentException - for invalid index pairs (i, j)

setValue

public void setValue(int i,
                     int j,
                     int newValue)
Description copied from interface: CoOccurrenceMatrix
Sets the counter for pair (i, j) to a new value.

Specified by:
setValue in interface CoOccurrenceMatrix
Parameters:
i - column index, from 0 to CoOccurrenceMatrix.getDimension() - 1
j - row index, from 0 to CoOccurrenceMatrix.getDimension() - 1

JIU 0.12.0 Homepage

Copyright © 2000, 2001, 2002, 2003, 2004 Marco Schmidt