org.knime.base.util
Class HalfFloatMatrix

java.lang.Object
  extended by org.knime.base.util.HalfFloatMatrix

public final class HalfFloatMatrix
extends Object

This stores half a matrix of floats efficiently in just one array. The access function get(int, int) works symmetrically. Upon creating the matrix you can choose if place for the diagonal should be reserved or not. It is also possible to save the contents of the matrix into a node settings object and load it again from there afterwards.

Author:
Thorsten Meinl, University of Konstanz

Constructor Summary
HalfFloatMatrix(ConfigRO config)
          Loads a half int matrix from the given node settings object.
HalfFloatMatrix(int rows, boolean withDiagonal)
          Creates a new half-matrix of floats.
 
Method Summary
 void fill(float value)
          Fills the matrix with the given value.
 float get(int row, int col)
          Returns a value in the matrix.
 int getRowCount()
          Returns the number of rows the half matrix has.
 void permute(int[] permutation)
          Permutes the matrix based on the permutation given in the parameter.
 void save(ConfigWO config)
          Saves the matrix directly into the passed node settings object.
 void set(int row, int col, float value)
          Sets a value in the matrix.
 boolean storesDiagonal()
          Returns if the half matrix also stores the diagonal or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HalfFloatMatrix

public HalfFloatMatrix(int rows,
                       boolean withDiagonal)
Creates a new half-matrix of floats.

Parameters:
rows - the number of rows (and columns) in the matrix
withDiagonal - true if the diagonal should be stored too, false otherwise

HalfFloatMatrix

public HalfFloatMatrix(ConfigRO config)
                throws InvalidSettingsException
Loads a half int matrix from the given node settings object.

Parameters:
config - a node settings object
Throws:
InvalidSettingsException - if the passed node settings do not contain valid settings
Method Detail

set

public void set(int row,
                int col,
                float value)
Sets a value in the matrix. This function works symmetrically, i.e. set(i, j, 1) is the same as set(j, i, 1).

Parameters:
row - the value's row
col - the value's column
value - the value

get

public float get(int row,
                 int col)
Returns a value in the matrix. This function works symmetrically, i.e. get(i, j) is the same as get(j, i).

Parameters:
row - the value's row
col - the value's column
Returns:
the value

fill

public void fill(float value)
Fills the matrix with the given value.

Parameters:
value - any value

save

public void save(ConfigWO config)
Saves the matrix directly into the passed node settings object.

Parameters:
config - a node settings object.

storesDiagonal

public boolean storesDiagonal()
Returns if the half matrix also stores the diagonal or not.

Returns:
true if the diagonal is stored, false otherwise

getRowCount

public int getRowCount()
Returns the number of rows the half matrix has.

Returns:
the number of rows

permute

public void permute(int[] permutation)
Permutes the matrix based on the permutation given in the parameter.

Parameters:
permutation - an array in which at position i is the index where the old row i is moved to, i.e. { 2, 3, 0, 1 } means that rows (and columns) 0 and 2 are swapped and rows 1 and 3


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.