O - Object typepublic class PrecomputedSimilarityMatrix<O> extends AbstractIndex<O> implements SimilarityIndex<O>, SimilarityRangeIndex<O>
This class uses a linear memory layout (not a ragged array), and assumes symmetry as well as strictness. This way, it only stores the upper triangle matrix with double precision. It has to store (n-1) * (n-2) similarity values in memory, requiring 8 * (n-1) * (n-2) bytes. Since Java has a size limit of arrays of 31 bits (signed integer), we can store at most \(2^16\) objects (precisely, 65536 objects) in a single array, which needs about 16 GB of RAM.
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
PrecomputedSimilarityMatrix.Factory<O>
Factory for the index. 
 | 
private class  | 
PrecomputedSimilarityMatrix.PrecomputedSimilarityQuery
Similarity query using the precomputed matrix. 
 | 
private class  | 
PrecomputedSimilarityMatrix.PrecomputedSimilarityRangeQuery
Range query using the distance matrix. 
 | 
| Modifier and Type | Field and Description | 
|---|---|
private DBIDRange | 
ids
DBID range. 
 | 
private static Logging | 
LOG
Class logger. 
 | 
private double[] | 
matrix
Similarity matrix. 
 | 
protected SimilarityFunction<? super O> | 
similarityFunction
Nested similarity function. 
 | 
protected SimilarityQuery<O> | 
similarityQuery
Nested similarity query. 
 | 
private int | 
size
Size of DBID range. 
 | 
relation| Constructor and Description | 
|---|
PrecomputedSimilarityMatrix(Relation<O> relation,
                           SimilarityFunction<? super O> similarityFunction)
Constructor. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
java.lang.String | 
getLongName()
A "pretty" name for the result, for use in titles, captions and menus. 
 | 
private int | 
getOffset(int x,
         int y)
Array offset computation. 
 | 
java.lang.String | 
getShortName()
A short name for the result, useful for file names. 
 | 
SimilarityQuery<O> | 
getSimilarityQuery(SimilarityFunction<? super O> similarityFunction,
                  java.lang.Object... hints)
Get a similarity query object for the given similarity function. 
 | 
RangeQuery<O> | 
getSimilarityRangeQuery(SimilarityQuery<O> simQuery,
                       java.lang.Object... hints)
Get a range query object for the given distance query and k. 
 | 
void | 
initialize()
Initialize the index. 
 | 
void | 
logStatistics()
Send statistics to the logger, if enabled. 
 | 
protected static int | 
triangleSize(int x)
Compute the size of a complete x by x triangle (minus diagonal) 
 | 
private static final Logging LOG
protected final SimilarityFunction<? super O> similarityFunction
protected SimilarityQuery<O> similarityQuery
private double[] matrix
private DBIDRange ids
private int size
public PrecomputedSimilarityMatrix(Relation<O> relation, SimilarityFunction<? super O> similarityFunction)
relation - Data relationsimilarityFunction - Similarity functionpublic void initialize()
Indexinitialize in interface Indexprotected static int triangleSize(int x)
x - Offsetprivate int getOffset(int x,
                      int y)
x - X parametery - Y parameterpublic void logStatistics()
IndexlogStatistics in interface Indexpublic java.lang.String getLongName()
ResultgetLongName in interface ResultgetLongName in class AbstractIndex<O>public java.lang.String getShortName()
ResultgetShortName in interface ResultgetShortName in class AbstractIndex<O>public SimilarityQuery<O> getSimilarityQuery(SimilarityFunction<? super O> similarityFunction, java.lang.Object... hints)
SimilarityIndexgetSimilarityQuery in interface SimilarityIndex<O>similarityFunction - Similarity function to use.hints - Hints for the optimizernullpublic RangeQuery<O> getSimilarityRangeQuery(SimilarityQuery<O> simQuery, java.lang.Object... hints)
SimilarityRangeIndexgetSimilarityRangeQuery in interface SimilarityRangeIndex<O>simQuery - Similarity queryhints - Hints for the optimizernullCopyright © 2019 ELKI Development Team. License information.