infomat.vectorspace.similarity
Class SparseCartesianSimilarity

java.lang.Object
  extended by infomat.vectorspace.similarity.ISimilarity
      extended by infomat.vectorspace.similarity.SparseISimilarity
          extended by infomat.vectorspace.similarity.SparseCartesianSimilarity
All Implemented Interfaces:
NeedsIMatrix, NeedsIMatrixDimension, HasProperties

public class SparseCartesianSimilarity
extends SparseISimilarity
implements NeedsIMatrix, NeedsIMatrixDimension

Cartesian Similarity is the inverse of the Cartesian distance: sim = 1/dist. If the distance is zero the similarity is set to infinity.


Field Summary
private  IMatrix matrix
           
private  boolean row
           
 
Fields inherited from class infomat.vectorspace.similarity.ISimilarity
properties
 
Constructor Summary
SparseCartesianSimilarity()
           
SparseCartesianSimilarity(IMatrix matrix, boolean row)
           
SparseCartesianSimilarity(IMatrix matrix, boolean row, Properties properties)
           
SparseCartesianSimilarity(SparseCartesianSimilarity sim)
           
 
Method Summary
<V extends IVectorIndex>
double
cartesianSquaredDistanceFromOrigo(IVector<V> vec1)
           
 Properties getDefaultProperties()
           
 IVector<IVectorIndex> getGroupRepresentation(IObjectGroup iog)
           
 IMatrix getIMatrix()
          Returns the actual IMatrix.
 boolean getIMatrixDimension()
          Returns a boolean that indicates wether the algorithm should consider rows or columns of a matrix.
 java.lang.String getName()
           
 Properties getProperties()
           
 java.lang.Object getPropertyValue(java.lang.String name)
           
 java.util.Vector getPropertyVector()
           
 IVector<IVectorIndex> getRepresentation(IObject io)
          Returns the representation in the form of a IVector.
 void setIMatrix(IMatrix matrix)
          Sets the IMatrix.
 void setIMatrixDimension(boolean row)
          Sets a boolean that indicates wether the algorithm should consider rows or columns of a matrix.
 void setProperties(Properties properties)
           
 void setProperty(java.lang.String name, java.lang.Object value)
           
 float sim(IObjectGroup iog1, IObjectGroup iog2)
          Calculates the similarity between two IObjectGroup:s.
 float sim(IObject io1, IObject io2)
          Calculates the similarity between two IObject:s.
 float sim(IObject io, IObjectGroup iog)
          Calculates the similarity between IObject and a IObjectGroup.
<U extends IVectorIndex,V extends IVectorIndex>
float
sim(IVector<U> vec1, IVector<V> vec2)
          Calculates the similarity between two representations.
<U extends IVectorIndex,V extends IVectorIndex>
float
sim(IVector<U> vec1, IVector<V> vec2, double sqDist)
          Calculates the similarity between two representations, using the distance from origo for the second.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

matrix

private IMatrix matrix

row

private boolean row
Constructor Detail

SparseCartesianSimilarity

public SparseCartesianSimilarity()

SparseCartesianSimilarity

public SparseCartesianSimilarity(SparseCartesianSimilarity sim)

SparseCartesianSimilarity

public SparseCartesianSimilarity(IMatrix matrix,
                                 boolean row)

SparseCartesianSimilarity

public SparseCartesianSimilarity(IMatrix matrix,
                                 boolean row,
                                 Properties properties)
Method Detail

getDefaultProperties

public Properties getDefaultProperties()
Specified by:
getDefaultProperties in interface HasProperties

getName

public java.lang.String getName()
Specified by:
getName in class ISimilarity

getPropertyVector

public java.util.Vector getPropertyVector()

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String name)
Specified by:
getPropertyValue in interface HasProperties

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
                 throws PropertyNotFoundException
Specified by:
setProperty in interface HasProperties
Throws:
PropertyNotFoundException

getProperties

public Properties getProperties()
Specified by:
getProperties in interface HasProperties

setProperties

public void setProperties(Properties properties)
Specified by:
setProperties in interface HasProperties

sim

public float sim(IObject io1,
                 IObject io2)
Calculates the similarity between two IObject:s. Extracts the representation from the matrix.

Specified by:
sim in class ISimilarity

sim

public float sim(IObject io,
                 IObjectGroup iog)
Calculates the similarity between IObject and a IObjectGroup. Extracts the representation from the matrix. Uses the group representation for IObjectGroup:s of all kinds. This takes more time to extract. Therefore it might be better to use the #getGroupRepresentation-method instead...

Specified by:
sim in class ISimilarity

sim

public float sim(IObjectGroup iog1,
                 IObjectGroup iog2)
Calculates the similarity between two IObjectGroup:s. Extracts the representation from the matrix. Uses the group representation for IObjectGroup:s of all kinds. This takes more time to extract. Therefore it might be better to use the #getGroupRepresentation-method instead...

Specified by:
sim in class ISimilarity

sim

public <U extends IVectorIndex,V extends IVectorIndex> float sim(IVector<U> vec1,
                                                                 IVector<V> vec2)
Calculates the similarity between two representations.

Specified by:
sim in class SparseISimilarity

sim

public <U extends IVectorIndex,V extends IVectorIndex> float sim(IVector<U> vec1,
                                                                 IVector<V> vec2,
                                                                 double sqDist)
Calculates the similarity between two representations, using the distance from origo for the second.


cartesianSquaredDistanceFromOrigo

public <V extends IVectorIndex> double cartesianSquaredDistanceFromOrigo(IVector<V> vec1)

getRepresentation

public IVector<IVectorIndex> getRepresentation(IObject io)
Returns the representation in the form of a IVector.

Specified by:
getRepresentation in class SparseISimilarity

getGroupRepresentation

public IVector<IVectorIndex> getGroupRepresentation(IObjectGroup iog)
Specified by:
getGroupRepresentation in class SparseISimilarity

setIMatrix

public void setIMatrix(IMatrix matrix)
Description copied from interface: NeedsIMatrix
Sets the IMatrix.

Specified by:
setIMatrix in interface NeedsIMatrix

getIMatrix

public IMatrix getIMatrix()
Description copied from interface: NeedsIMatrix
Returns the actual IMatrix. (Not a copy.)

Specified by:
getIMatrix in interface NeedsIMatrix

setIMatrixDimension

public void setIMatrixDimension(boolean row)
Description copied from interface: NeedsIMatrixDimension
Sets a boolean that indicates wether the algorithm should consider rows or columns of a matrix. true - rows, false - columns

Specified by:
setIMatrixDimension in interface NeedsIMatrixDimension

getIMatrixDimension

public boolean getIMatrixDimension()
Description copied from interface: NeedsIMatrixDimension
Returns a boolean that indicates wether the algorithm should consider rows or columns of a matrix. true - rows, false - columns

Specified by:
getIMatrixDimension in interface NeedsIMatrixDimension