infomat.vectorspace
Class IMatrix

java.lang.Object
  extended by infomat.vectorspace.IMatrix

public class IMatrix
extends java.lang.Object

IMatrix represents the relations between two IObjectSet:s. The IMatrixCell class represents the elements of this IMatrix. This is implemented considering sparse matrices. The IMatrixCells are stored in a DoubleHashMap and are the non zero matrix elements.

Version:
070314
Author:
Magnus Rosell

Constructor Summary
IMatrix(java.lang.String columnLabel, java.lang.String rowLabel)
           
 
Method Summary
 void addCell(int ri, int ci, double w)
          Add the value of a column in a row
 boolean addCell(int ri, int ci, float weight)
          Add the value of a column in a row
 void addDocument(java.lang.String d, int di)
          adds a Document as a Row to the matrix
 void addWord(java.lang.String w, int ws)
          adds a Word as Column to the matrix
 java.util.Vector getAllCells()
          Returns the DoubleHashMap containing all non zero elements of the IMatrix.
 IMatrixCell getCell(IObject row, IObject col)
          Returns the IMatrixCell for the IObject "row" in the "row" IObjectSet and the IObject "col" in the "column" IObjectSet
 DoubleHashMap getCellMap()
          Returns the DoubleHashMap containing all non zero elements of the IMatrix.
 java.util.HashSet getColumnIMatrixCellsForRowObject(IObject rowObject)
           
 IObjectSet getColumnIObjectSet()
          Returns the "column" IObjectSet.
 IObjectGrouping getCurrentColumnGrouping()
          Returns the current IObjectGrouping for the columns.
 IObjectGrouping getCurrentRowGrouping()
          Returns the current IObjectGrouping for the rows.
 java.awt.Dimension getCurrentSize()
          Returns a Dimension with x-size as the number of "columns" and y-size as the number of "rows" of the IMatrix.
 java.util.HashSet getRowIMatrixCellsForColumnObject(IObject colObject)
           
 IObjectSet getRowIObjectSet()
          Returns the "row" IObjectSet.
 java.awt.Dimension getSize()
          Returns a Dimension with x-size as the number of "columns" and y-size as the number of "rows" of the IMatrix.
 void invertMatrix()
           
 void purgeMatrixToCurrentGroupings()
          Removes all IObjects that's not in the current IObjectGroupings from the sets and all their IObjectGroupings.
 void removeAllCells()
          Revmove all IMatrixCell from the IMatrix.
 void removeCell(IMatrixCell mc)
          Removes a IMatrixCell from the IMatrix.
 void resort()
          Resorts the IObjectSet:s "rows" and "cols" according to their current IObjectGroupings.
 void saveIMatrix(java.io.File file)
           
 void saveIObjectGroupingFile(IObjectGrouping grouping, java.io.File file)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IMatrix

public IMatrix(java.lang.String columnLabel,
               java.lang.String rowLabel)
Method Detail

addWord

public void addWord(java.lang.String w,
                    int ws)
adds a Word as Column to the matrix

Parameters:
w - The Word as a string
ws - A unique identifier of the word

addDocument

public void addDocument(java.lang.String d,
                        int di)
adds a Document as a Row to the matrix

Parameters:
d - The source of the document
di - A unique identifier of the document

addCell

public boolean addCell(int ri,
                       int ci,
                       float weight)
Add the value of a column in a row

Parameters:
ri - The unique identifier of the row
ci - The unique identifier of the column
weight - The value of the column in the row
Returns:
true if row and column exists, false otherwise

addCell

public void addCell(int ri,
                    int ci,
                    double w)
Add the value of a column in a row

Parameters:
ri - The unique identifier of the row
ci - The unique identifier of the column
w - The weight of the column in the row

purgeMatrixToCurrentGroupings

public void purgeMatrixToCurrentGroupings()
Removes all IObjects that's not in the current IObjectGroupings from the sets and all their IObjectGroupings. Also removes all corresponding IMatrixCells.


invertMatrix

public void invertMatrix()

getRowIObjectSet

public IObjectSet getRowIObjectSet()
Returns the "row" IObjectSet.


getColumnIObjectSet

public IObjectSet getColumnIObjectSet()
Returns the "column" IObjectSet.


getCurrentRowGrouping

public IObjectGrouping getCurrentRowGrouping()
Returns the current IObjectGrouping for the rows.


getCurrentColumnGrouping

public IObjectGrouping getCurrentColumnGrouping()
Returns the current IObjectGrouping for the columns.


getCellMap

public DoubleHashMap getCellMap()
Returns the DoubleHashMap containing all non zero elements of the IMatrix.


getAllCells

public java.util.Vector getAllCells()
Returns the DoubleHashMap containing all non zero elements of the IMatrix.


getCell

public IMatrixCell getCell(IObject row,
                           IObject col)
Returns the IMatrixCell for the IObject "row" in the "row" IObjectSet and the IObject "col" in the "column" IObjectSet


removeCell

public void removeCell(IMatrixCell mc)
Removes a IMatrixCell from the IMatrix. Does not remove the corresponding IObjects from the IObjectSet:s.

Parameters:
mc - An IMatrixCell

removeAllCells

public void removeAllCells()
Revmove all IMatrixCell from the IMatrix. Does not remove the corresponding IObjects from the IObjectSet:s.


getSize

public java.awt.Dimension getSize()
Returns a Dimension with x-size as the number of "columns" and y-size as the number of "rows" of the IMatrix.


getCurrentSize

public java.awt.Dimension getCurrentSize()
Returns a Dimension with x-size as the number of "columns" and y-size as the number of "rows" of the IMatrix. This is the size of the matrix seen through the current row and column groupings.


resort

public void resort()
Resorts the IObjectSet:s "rows" and "cols" according to their current IObjectGroupings.


getRowIMatrixCellsForColumnObject

public java.util.HashSet getRowIMatrixCellsForColumnObject(IObject colObject)

getColumnIMatrixCellsForRowObject

public java.util.HashSet getColumnIMatrixCellsForRowObject(IObject rowObject)

saveIMatrix

public void saveIMatrix(java.io.File file)

saveIObjectGroupingFile

public void saveIObjectGroupingFile(IObjectGrouping grouping,
                                    java.io.File file)