comirva.data
Class DataMatrix<T>

java.lang.Object
  extended by comirva.data.DataMatrix<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class DataMatrix<T>
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This class implements a data matrix containing double values. The data structure is created using a Vector of Vectors.

Author:
Markus Schedl
See Also:
Serialized Form

Constructor Summary
DataMatrix()
          Creates an empty DataMatrix-instance and initializes rows- and columns-Vectors.
DataMatrix(int rows, int cols)
          Creates an empty DataMatrix-instance and with rows rows and cols cols.
DataMatrix(java.lang.String name)
          Creates an empty DataMatrix-instance, initializes rows- and columns-Vectors, and sets the name of the DataMatrix to the name argument.
 
Method Summary
 void addRowValues(java.util.Vector data, int row)
          Adds the values of the Vector data to the row-values of the matrix indicated by the argument row.
 void addValue(T value)
          Inserts the Double-instance value into the DataMatrix-instance at the current row.
 void addValue(T value, boolean boolNewRow)
          Inserts the Double-instance value into the DataMatrix-instance.
 void addValue(T value, int row)
          Inserts the Double-instance value into the DataMatrix-instance at row row.
 java.lang.Object clone()
          Implements the clone() function, so we can easily produce copies of DataMatrices. vecColCurrent set to the Vector which represents the first row.
 java.util.Vector getColumn(int col)
          Returns the Vector of the column given by the argument col.
 java.lang.String getName()
          Returns the name of the DataMatrix.
 int getNumberOfColumns()
          Returns the number of columns in the DataMatrix.
 int getNumberOfRows()
          Returns the number of rows in the DataMatrix.
 java.util.Vector getRow(int row)
          Returns the Vector of the row given by the argument row.
 java.lang.Double getValueAtPos(int row, int col)
          Returns the value of the element that can be found at column col and row row in the DataMatrix-instance.
 boolean isBooleanMatrix()
          Checks whether the DataMatrix contains only the values 0 and 1.
 void normalize(double lowerBound, double upperBound)
          Normalizes the DataMatrix linearly using the complete data matrix as scope.
 void normalize(double lowerBound, double upperBound, boolean isLinear)
          Normalizes the DataMatrix using the complete data matrix as scope.
 void normalize(double lowerBound, double upperBound, boolean isLinear, int scope)
          Normalizes the DataMatrix.
 void printMatrix()
          Prints the DataMatrix-instance to java.lang.System.out.
 void removeLastAddedElement()
          Removes the latest added Vector in the DataMatrix.
 void setName(java.lang.String name)
          Sets the name of DataMatrix to the value of the parameter name.
 void setRowValues(java.util.Vector data, int row)
          Sets a specific row in the DataMatrix.
 void setValueAtPos(java.lang.Double value, int row, int col)
          Sets the value at a specific position of the DataMatrix-instance.
 void startNewRow()
          Starts a new row in the DataMatrix.
 void startNewRow(int count)
          Starts count new rows in the DataMatrix.
 double[][] toDoubleArray()
          Returns a double[][] representation of the DataMatrix.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataMatrix

public DataMatrix()
Creates an empty DataMatrix-instance and initializes rows- and columns-Vectors.


DataMatrix

public DataMatrix(java.lang.String name)
Creates an empty DataMatrix-instance, initializes rows- and columns-Vectors, and sets the name of the DataMatrix to the name argument.

Parameters:
name - a String representing the name of the DataMatrix

DataMatrix

public DataMatrix(int rows,
                  int cols)
Creates an empty DataMatrix-instance and with rows rows and cols cols. So after the creation of the DataMatrix you can easily fill the matrix with several setValueAtPos()s. created by MSt

Method Detail

addValue

public void addValue(T value)
Inserts the Double-instance value into the DataMatrix-instance at the current row.

Parameters:
value - the Double-instance which should be inserted into the matrix

addValue

public void addValue(T value,
                     boolean boolNewRow)
Inserts the Double-instance value into the DataMatrix-instance.
If boolNewRow is true, a new row is created and value is inserted as first element into the new row. If boolNewRow is false, value is inserted into the current row.

Parameters:
value - the Double-instance which should be inserted into the matrix
boolNewRow - a boolean indicating if value should be inserted into a new row or into the current row

addValue

public void addValue(T value,
                     int row)
Inserts the Double-instance value into the DataMatrix-instance at row row. It is inserted in the Row-Vector.

Parameters:
row - the row into which the value is inserted created by MSt

startNewRow

public void startNewRow()
Starts a new row in the DataMatrix.


startNewRow

public void startNewRow(int count)
Starts count new rows in the DataMatrix.

Parameters:
count - the number of new rows to be inserted into the DataMatrix created by MS

removeLastAddedElement

public void removeLastAddedElement()
Removes the latest added Vector in the DataMatrix.
It is necessary in order to delete the empty element which is added by the MatrixDataFileLoaderThread.


toDoubleArray

public double[][] toDoubleArray()
Returns a double[][] representation of the DataMatrix.

Returns:
a double[][] containing the values of the DataMatrix

printMatrix

public void printMatrix()
Prints the DataMatrix-instance to java.lang.System.out.


getValueAtPos

public java.lang.Double getValueAtPos(int row,
                                      int col)
Returns the value of the element that can be found at column col and row row in the DataMatrix-instance.

Parameters:
row - the row of the requested value in the matrix
col - the column of the requested value in the matrix
Returns:
a Double containing the value of the requested element

getRow

public java.util.Vector getRow(int row)
Returns the Vector of the row given by the argument row.

Parameters:
row - the row in the matrix that should be returned as a Vector
Returns:
a Vector representing the requested row in the matrix

getColumn

public java.util.Vector getColumn(int col)
Returns the Vector of the column given by the argument col.

Parameters:
col - the column in the matrix that should be returned as a Vector
Returns:
a Vector representing the requested column in the matrix

setValueAtPos

public void setValueAtPos(java.lang.Double value,
                          int row,
                          int col)
                   throws SizeMismatchException
Sets the value at a specific position of the DataMatrix-instance.

Parameters:
value - a Double representing the value
row - the row within the DataMatrix of the value that should be set
col - the column within the DataMatrix of the value that should be set
Throws:
SizeMismatchException

setRowValues

public void setRowValues(java.util.Vector data,
                         int row)
                  throws SizeMismatchException
Sets a specific row in the DataMatrix. The Vector data is inserted at row row. The original data is discarded.

Parameters:
data - a Vector containing the data to be inserted
row - the row where the data is inserted
Throws:
SizeMismatchException

addRowValues

public void addRowValues(java.util.Vector data,
                         int row)
                  throws SizeMismatchException
Adds the values of the Vector data to the row-values of the matrix indicated by the argument row.

Parameters:
data - a Vector containing the values to be added
row - the row indicating the position where the values are added
Throws:
SizeMismatchException

normalize

public void normalize(double lowerBound,
                      double upperBound)
Normalizes the DataMatrix linearly using the complete data matrix as scope.

Parameters:
lowerBound - the lower bound of the projection range
upperBound - the upper bound of the projection range

normalize

public void normalize(double lowerBound,
                      double upperBound,
                      boolean isLinear)
Normalizes the DataMatrix using the complete data matrix as scope.

Parameters:
lowerBound - the lower bound of the projection range
upperBound - the upper bound of the projection range
isLinear - linear or logarithmic normalization

normalize

public void normalize(double lowerBound,
                      double upperBound,
                      boolean isLinear,
                      int scope)
Normalizes the DataMatrix.

Parameters:
lowerBound - the lower bound of the projection range
upperBound - the upper bound of the projection range
isLinear - linear or logarithmic normalization
scope - indicates whether the normalization scope is the complete data matrix, normalization is performed for every row, or for every column separately

getNumberOfRows

public int getNumberOfRows()
Returns the number of rows in the DataMatrix.

Returns:
the number of rows in the matrix

isBooleanMatrix

public boolean isBooleanMatrix()
Checks whether the DataMatrix contains only the values 0 and 1. If this is the case, true is returned, if not, false.

Returns:
true if the instance of DataMatrix only contains the values 0 and 1, false otherwise

getNumberOfColumns

public int getNumberOfColumns()
Returns the number of columns in the DataMatrix.

Returns:
the number of columns in the matrix

setName

public void setName(java.lang.String name)
Sets the name of DataMatrix to the value of the parameter name.

Parameters:
name - the name that is to be given to the matrix

getName

public java.lang.String getName()
Returns the name of the DataMatrix.

Returns:
a String containing the name of the DataMatrix

clone

public java.lang.Object clone()
Implements the clone() function, so we can easily produce copies of DataMatrices. vecColCurrent set to the Vector which represents the first row. created by MSt

Overrides:
clone in class java.lang.Object