org.decisiondeck.xmcda_oo.utils.matrix
Class OneMinusInverseMatrix<PosType>

java.lang.Object
  extended by org.decisiondeck.xmcda_oo.utils.matrix.OneMinusInverseMatrix<PosType>
Type Parameters:
PosType - the type of object referencing the row and the column part of the positions.
All Implemented Interfaces:
IRdFloatMatrix<PosType,PosType>, IRdZeroToOneMatrix<PosType,PosType>

public class OneMinusInverseMatrix<PosType>
extends Object
implements IRdZeroToOneMatrix<PosType,PosType>

A fuzzy matrix based on an other fuzzy matrix (called 'base' matrix). When queried about it value for a given (row, column) position, this matrix replies by computing one minus the value at the position (column, row) (called inverted position) of the 'base' matrix.

This matrix contains a value at a given position if and only if the base matrix contains a value at the inverted position.

This kind of matrix is implemented only for the case where the positions are specified using the same type of objects for rows and columns (so that they can be exchanged by the user) because it is probably only useful in that case.

Note that this matrix's rows are the base matrix's columns and this matrix's columns are the base matrix's rows. (This is a consequence of this matrix's definition.)


Constructor Summary
OneMinusInverseMatrix(IRdZeroToOneMatrix<PosType,PosType> base)
          Sets this object to use the given matrix as base.
 
Method Summary
 boolean approxEquals(IRdFloatMatrix<PosType,PosType> m2, double imprecision)
          Two matrix are "approximately equal" to a given degree of precision iff they contain values for the same mappings and the value they contain for each mapping are not more different than the given allowed imprecision.
 boolean equals(Object obj)
          Two matrix are equal iff they are the same type and contain the same values at the same positions.
 Set<PosType> getColumns()
          Returns a read-only view of the columns existing in this matrix.
 Double getEntry(PosType row, PosType column)
          Returns the value at the position specified by the given row and column, of null if there is none.
 Set<PosType> getRows()
          Returns a view of the rows existing in this matrix.
 int getValueCount()
           Gets the number of values in this matrix.
 int hashCode()
           
 boolean isComplete()
           A matrix is complete iff it contains a value for every possible position (row, column) where row and column are rows and columns existing in this matrix (i.e. corresponding to at least one value).
 boolean isEmpty()
          Checks whether this matrix contains no value.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OneMinusInverseMatrix

public OneMinusInverseMatrix(IRdZeroToOneMatrix<PosType,PosType> base)
Sets this object to use the given matrix as base.

Parameters:
base - not null.
Method Detail

approxEquals

public boolean approxEquals(IRdFloatMatrix<PosType,PosType> m2,
                            double imprecision)
Description copied from interface: IRdFloatMatrix
Two matrix are "approximately equal" to a given degree of precision iff they contain values for the same mappings and the value they contain for each mapping are not more different than the given allowed imprecision.

Specified by:
approxEquals in interface IRdFloatMatrix<PosType,PosType>
Parameters:
m2 - the matrix to which to compare this object for approximate equality. If null, this method returns false.
imprecision - the maximal imprecision allowed.
Returns:
true iff the given matrix is approximately equal to this one.

equals

public boolean equals(Object obj)
Description copied from interface: IRdFloatMatrix
Two matrix are equal iff they are the same type and contain the same values at the same positions. Note that the values are compared exactly, thus a very small difference in one value will cause two matrixes to be unequal. See IRdFloatMatrix.approxEquals(IRdFloatMatrix, double) if this can be a problem.

Specified by:
equals in interface IRdFloatMatrix<PosType,PosType>
Overrides:
equals in class Object
Parameters:
obj - the object to compare. May be null.
Returns:
true iff the given object is equal to this matrix.
See Also:
Object.equals(java.lang.Object)

getColumns

public Set<PosType> getColumns()
Description copied from interface: IRdFloatMatrix
Returns a read-only view of the columns existing in this matrix. The returned set "read through" to the matrix, thus modifications of this matrix are reflected in the returned set.

Specified by:
getColumns in interface IRdFloatMatrix<PosType,PosType>
Returns:
the objects such that at least one value exists in this matrix at a position having the object as column. Not null. Empty iff this matrix is empty.

getEntry

public Double getEntry(PosType row,
                       PosType column)
Description copied from interface: IRdZeroToOneMatrix
Returns the value at the position specified by the given row and column, of null if there is none.

Specified by:
getEntry in interface IRdFloatMatrix<PosType,PosType>
Specified by:
getEntry in interface IRdZeroToOneMatrix<PosType,PosType>
Parameters:
row - not null.
column - not null.
Returns:
the double value at that position (between zero and one inclusive), or null.

getRows

public Set<PosType> getRows()
Description copied from interface: IRdFloatMatrix
Returns a view of the rows existing in this matrix. The returned set "read through" to the matrix, thus modifications of this matrix are reflected in the returned set. The view may be read-only (some objects may also support objects removal from the returned set).

Specified by:
getRows in interface IRdFloatMatrix<PosType,PosType>
Returns:
the objects such that at least one value exists in this matrix at a position having the object as row. Not null. Empty iff this matrix is empty.

getValueCount

public int getValueCount()
Description copied from interface: IRdFloatMatrix

Gets the number of values in this matrix.

Note that the word "size" is not used here because the size of the matrix could be understood as meaning its row count times its column count, which is the same as its value count only if it is complete.

Specified by:
getValueCount in interface IRdFloatMatrix<PosType,PosType>
Returns:
the count of values.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isComplete

public boolean isComplete()
Description copied from interface: IRdFloatMatrix

A matrix is complete iff it contains a value for every possible position (row, column) where row and column are rows and columns existing in this matrix (i.e. corresponding to at least one value). An empty matrix is complete.

Specified by:
isComplete in interface IRdFloatMatrix<PosType,PosType>
Returns:
true iff this matrix is complete.

isEmpty

public boolean isEmpty()
Description copied from interface: IRdFloatMatrix
Checks whether this matrix contains no value.

Specified by:
isEmpty in interface IRdFloatMatrix<PosType,PosType>
Returns:
true iff the matrix contains no value.


Copyright © 2011. All Rights Reserved.