slib.utils.impl
Class MatrixDouble<C,R>

java.lang.Object
  extended by slib.utils.impl.MatrixDouble<C,R>
Type Parameters:
C - Object to index Columns
R - Object to index Rows

public class MatrixDouble<C,R>
extends Object

Class used to represent a Matrix which can be used to store values associated to pairs of elements.

Author:
Sebastien Harispe

Constructor Summary
MatrixDouble(Set<C> columResources, Set<R> rowResources)
          Create a matrix filled with null values considering the given indexes.
MatrixDouble(Set<C> columResources, Set<R> rowResources, Double initValue)
          Create a matrix filled with null values considering the given indexes
 
Method Summary
 Double getAverage()
          Return the average of contained valued.
 Double[] getColumn(C r)
          Return the column associated to the given element
 Set<C> getColumnElements()
           
 Double[][] getMatrix()
           
 Double getMax()
           
 Double getMaxColumn(C v)
           
 Double getMaxRow(R v)
           
 Double getMin()
          Return the minimal value stored in the matrix
 int getNbColumns()
           
 int getNbRows()
           
 Double[] getRow(R r)
          Return the row associated to the given element
 Set<R> getRowElements()
           
 Double getSum()
          Compute the sum of the values contained in the matrix.
 Double getValue(C colResource, R rowResource)
           
 Double getValueCheckIndex(C colResource, R rowResource)
           
 boolean isInColumnIndex(C r)
           
 boolean isInRowIndex(R r)
           
 boolean isSquare()
           
 void setValue(C colResource, R rowResource, Double value)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MatrixDouble

public MatrixDouble(Set<C> columResources,
                    Set<R> rowResources)
Create a matrix filled with null values considering the given indexes.

Parameters:
columResources - the columns
rowResources - the rows

MatrixDouble

public MatrixDouble(Set<C> columResources,
                    Set<R> rowResources,
                    Double initValue)
Create a matrix filled with null values considering the given indexes

Parameters:
columResources -
rowResources -
initValue - default value
Method Detail

getColumn

public Double[] getColumn(C r)
Return the column associated to the given element

Parameters:
r - the element
Returns:
a tab corresponding to the values associated to the element

getRow

public Double[] getRow(R r)
Return the row associated to the given element

Parameters:
r -
Returns:

getValueCheckIndex

public Double getValueCheckIndex(C colResource,
                                 R rowResource)
Parameters:
colResource -
rowResource -
Returns:

getValue

public Double getValue(C colResource,
                       R rowResource)
                throws SLIB_Ex_Critic
Parameters:
colResource -
rowResource -
Returns:
Throws:
SLIB_Ex_Critic

setValue

public void setValue(C colResource,
                     R rowResource,
                     Double value)
Parameters:
colResource -
rowResource -
value -

isInRowIndex

public boolean isInRowIndex(R r)
Parameters:
r -
Returns:

isInColumnIndex

public boolean isInColumnIndex(C r)
Parameters:
r -
Returns:

getNbColumns

public int getNbColumns()
Returns:

getNbRows

public int getNbRows()
Returns:

isSquare

public boolean isSquare()
Returns:

getMax

public Double getMax()
Returns:
the maximal value stored in the matrix

getMaxColumn

public Double getMaxColumn(C v)
Returns:
the maximal value stored in the column of the given resource
Throws:
IllegalArgumentException - if the given value cannot be associated to a column

getMaxRow

public Double getMaxRow(R v)
Returns:
the maximal value stored in the row of the given resource
Throws:
IllegalArgumentException - if the given value cannot be associated to a row

getMin

public Double getMin()
Return the minimal value stored in the matrix

Returns:
null if the matrix is empty

getAverage

public Double getAverage()
Return the average of contained valued. Null values are excluded.

Returns:
null if the matrix is only composed of null value.

getMatrix

public Double[][] getMatrix()
Returns:
the underlying matrix

toString

public String toString()
Overrides:
toString in class Object

getColumnElements

public Set<C> getColumnElements()

getRowElements

public Set<R> getRowElements()

getSum

public Double getSum()
Compute the sum of the values contained in the matrix. null cells are skipped. If the matrix only contains null values, sum is equal to null.

Returns:
the sum of the values contained in the matrix.


Copyright © 2013. All Rights Reserved.