|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object comirva.data.DataMatrix
public class DataMatrix
This class implements a data matrix containing double values. The data structure is created using a Vector of Vectors.
Constructor Summary | |
---|---|
DataMatrix()
Creates an empty DataMatrix-instance and initializes rows- and columns-Vectors. |
|
DataMatrix(int rows,
int cols,
Double initValue)
Creates an empty DataMatrix-instance and with rows rows and
cols cols. |
|
DataMatrix(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(Vector<Double> data,
int row)
Adds the values of the Vector data
to the row-values of the matrix indicated by the argument row . |
void |
addValue(Double value)
Inserts the Double-instance value into the DataMatrix-instance at the current row. |
void |
addValue(Double value,
boolean boolNewRow)
Inserts the Double-instance value into the DataMatrix-instance. |
void |
addValue(Double value,
int row)
Inserts the Double-instance value into the DataMatrix-instance
at row row. |
Object |
clone()
Implements the clone() function, so we can easily produce copies of DataMatrices. vecColCurrent set to the Vector which represents the first row. |
static Jama.Matrix |
dataMatrixToJamaMatrix(DataMatrix dm)
Converts a DataMatrix to a Jama Matrix. |
static DataMatrix |
doubleArrayToDataMatrix(double[][] data)
Converts a double[][] into a DataMatrix. |
Vector<Double> |
getColumn(int col)
Returns the Vector of the column given by the argument col . |
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. |
Vector<Double> |
getRow(int row)
Returns the Vector of the row given by the argument row . |
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. |
void |
insertRow(Vector<Double> data,
int index)
Inserts a row at the given index. |
boolean |
isBooleanMatrix()
Checks whether the DataMatrix contains only the values 0 and 1. |
static DataMatrix |
jamaMatrixToDataMatrix(Jama.Matrix m)
Converts a Jama Matrix into a DataMatrix. |
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(String name)
Sets the name of DataMatrix to the value of the parameter name . |
void |
setRowValues(Vector<Double> data,
int row)
Sets a specific row in the DataMatrix. |
void |
setValueAtPos(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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DataMatrix()
public DataMatrix(String name)
name
argument.
name
- a String representing the name of the DataMatrixpublic DataMatrix(int rows, int cols, Double initValue)
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 |
---|
public static DataMatrix doubleArrayToDataMatrix(double[][] data)
data
- the input as double[][]
public static DataMatrix jamaMatrixToDataMatrix(Jama.Matrix m)
data
- a Matrix holding the input data
public static Jama.Matrix dataMatrixToJamaMatrix(DataMatrix dm)
dm
- a DataMatrix holding the input data
public void addValue(Double value)
value
into the DataMatrix-instance at the current row.
value
- the Double-instance which should be inserted into the matrixpublic void addValue(Double value, boolean boolNewRow)
value
into the DataMatrix-instance.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.
value
- the Double-instance which should be inserted into the matrixboolNewRow
- a boolean indicating if value
should be inserted into a new row or into the current rowpublic void addValue(Double value, int row)
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
public void startNewRow()
public void startNewRow(int count)
count
new rows in the DataMatrix.
count
- the number of new rows to be inserted into the DataMatrix
created by MSpublic void removeLastAddedElement()
MatrixDataFileLoaderThread
.
public double[][] toDoubleArray()
public void printMatrix()
java.lang.System.out
.
public Double getValueAtPos(int row, int col)
col
and row row
in the DataMatrix-instance.
row
- the row of the requested value in the matrixcol
- the column of the requested value in the matrix
public Vector<Double> getRow(int row)
row
.
row
- the row in the matrix that should be returned as a Vector
public Vector<Double> getColumn(int col)
col
.
col
- the column in the matrix that should be returned as a Vector
public void setValueAtPos(Double value, int row, int col) throws SizeMismatchException
value
- a Double representing the valuerow
- the row within the DataMatrix of the value that should be setcol
- the column within the DataMatrix of the value that should be set
SizeMismatchException
public void setRowValues(Vector<Double> data, int row) throws SizeMismatchException
data
is inserted at row row
.
The original data is discarded.
data
- a Vector containing the data to be insertedrow
- the row where the data is inserted
SizeMismatchException
public void addRowValues(Vector<Double> data, int row) throws SizeMismatchException
data
to the row-values of the matrix indicated by the argument row
.
data
- a Vector containing the values to be addedrow
- the row indicating the position where the values are added
SizeMismatchException
public void normalize(double lowerBound, double upperBound)
lowerBound
- the lower bound of the projection rangeupperBound
- the upper bound of the projection rangepublic void normalize(double lowerBound, double upperBound, boolean isLinear)
lowerBound
- the lower bound of the projection rangeupperBound
- the upper bound of the projection rangeisLinear
- linear or logarithmic normalizationpublic void normalize(double lowerBound, double upperBound, boolean isLinear, int scope)
lowerBound
- the lower bound of the projection rangeupperBound
- the upper bound of the projection rangeisLinear
- linear or logarithmic normalizationscope
- indicates whether the normalization scope is the complete data matrix, normalization is performed for every row, or for every column separatelypublic int getNumberOfRows()
public boolean isBooleanMatrix()
true
is returned, if not, false
.
true if the instance of DataMatrix only contains the values 0 and 1,
false otherwise
public int getNumberOfColumns()
public void setName(String name)
name
.
name
- the name that is to be given to the matrixpublic String getName()
public Object clone()
clone
in class Object
public void insertRow(Vector<Double> data, int index) throws SizeMismatchException
data
- index
- has to be equal or greater than 0, and less than
or equal to the number of rows.
SizeMismatchException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |