@Beta public final class FixedKnnResultsImpl extends Object implements KnnResults
KnnResults
.
Note that query and target IDs might refer to the same or different sets. If they refer to the same set the nearest neighbor list does not contain self ID.
Constructor and Description |
---|
FixedKnnResultsImpl(int k,
int queryCount,
int[] targets,
double[] dissimilarities)
Construct.
|
Modifier and Type | Method and Description |
---|---|
int |
copyNeighborsTo(int queryIndex,
int[] neighbors,
double[] dissimilarities)
Copy neighbor data to an allocated array.
|
void |
copyTo(int k,
int startQueryIndex,
int[] t,
double[] d)
Low level array copy to target arrays.
|
int |
getAllNeighborCount()
All stored neighbor count.
|
double[] |
getDissimilarities(int index)
Dissimilarity.
|
double |
getDissimilarity(int queryIndex,
int neighborIndex)
Dissimilarity of a single neighbor.
|
int |
getK()
Value of k.
|
double |
getMaxDissimilarity()
Upper bound of dissimilarity values.
|
int |
getMaxNeighborCount()
Maximal neighbor count represented.
|
int |
getMaxNeighborIndex()
Upper bound of neighbor index values.
|
double |
getMinDissimilarity()
Lower bound of dissimilarity values.
|
int |
getMinNeighborCount()
Minimal neighbor count represented.
|
int |
getMinNeighborIndex()
Lower bound of neighbor index values.
|
double |
getMostSimilarDissimilarity(int queryIndex)
Dissimilarity of the most similar neighbor.
|
int |
getMostSimilarNeighbor(int queryIndex)
Index of most similar neighbor.
|
int |
getNeighbor(int queryIndex,
int neighborIndex)
Index of a single neighbor.
|
int[] |
getNeighborCountsOfAll()
Neighbor count of all queries.
|
double |
getNeighborDissimilaritiesMissingValue()
Missing value for results of
KnnResults.getNthNeighborDissimilaritiesOfAll(int) . |
int[] |
getNeighbors(int index)
ID of the nearest neighbors of query.
|
double[] |
getNthNeighborDissimilaritiesOfAll(int neighborIndex)
Get
n -th neighbor dissimilarities for all queries. |
int[] |
getNthNeighborIdsOfAll(int neighborIndex)
Get
n -th neighbor indices for all queries. |
int |
getQueryCount()
Number of queries stored.
|
String |
toString() |
public FixedKnnResultsImpl(int k, int queryCount, int[] targets, double[] dissimilarities)
k
- Number of nearest neighbors recorded for each queryqueryCount
- Query counttargets
- Concatenated lists of nearest neighbors for each querydissimilarities
- DissimilaritiesIllegalArgumentException
- when array sizes mismatch or dissimilarities array contains NaN or INF valuepublic int getK()
KnnResults
getK
in interface KnnResults
public int getMinNeighborCount()
KnnResults
getMinNeighborCount
in interface KnnResults
public int getMaxNeighborCount()
KnnResults
getMaxNeighborCount
in interface KnnResults
public int getAllNeighborCount()
KnnResults
getAllNeighborCount
in interface KnnResults
public int getQueryCount()
NnResults
getQueryCount
in interface NnResults
public int[] getNeighbors(int index)
KnnResults
NnResults.getMinNeighborIndex()
and NnResults.getMaxNeighborIndex()
are valid for all neighbors.
First element of the returned list is the same as NnResults.getMostSimilarNeighbor(int)
. The length of the list
might vary from query to query, but is non-empty and no longer than the value of KnnResults.getK()
. The length of
the list is the same as the length of KnnResults.getDissimilarities(int)
.
getNeighbors
in interface KnnResults
index
- Indexpublic double[] getDissimilarities(int index)
KnnResults
NnResults.getMinDissimilarity()
and NnResults.getMaxDissimilarity()
are valid for all neighbors.
First element of the returned list is the same as NnResults.getMostSimilarDissimilarity(int)
. The length of the
list might vary from query to query, but is non-empty and no longer than the value of KnnResults.getK()
. The length
of the list is the same as the length of KnnResults.getNeighbors(int)
.
getDissimilarities
in interface KnnResults
index
- Index of querypublic void copyTo(int k, int startQueryIndex, int[] t, double[] d)
k
- Target kstartQueryIndex
- First query index to writet
- concatenated knn listsd
- dissimilaritiesIllegalArgumentException
- when trivial consistency checks failpublic int copyNeighborsTo(int queryIndex, int[] neighbors, double[] dissimilarities)
KnnResults
copyNeighborsTo
in interface KnnResults
queryIndex
- Query indexneighbors
- Array to copy neighbor indicesdissimilarities
- Array to copy dissimilaritiespublic int getMinNeighborIndex()
NnResults
getMinNeighborIndex
in interface NnResults
public int getMaxNeighborIndex()
NnResults
getMaxNeighborIndex
in interface NnResults
public double getMinDissimilarity()
NnResults
getMinDissimilarity
in interface NnResults
public double getMaxDissimilarity()
NnResults
getMaxDissimilarity
in interface NnResults
public int getMostSimilarNeighbor(int queryIndex)
NnResults
getMostSimilarNeighbor
in interface NnResults
queryIndex
- Index of querypublic double getMostSimilarDissimilarity(int queryIndex)
NnResults
getMostSimilarDissimilarity
in interface NnResults
queryIndex
- Index of querypublic int[] getNeighborCountsOfAll()
KnnResults
getNeighborCountsOfAll
in interface KnnResults
public int getNeighbor(int queryIndex, int neighborIndex)
KnnResults
getNeighbor
in interface KnnResults
queryIndex
- QueryneighborIndex
- Neighbor indexpublic int[] getNthNeighborIdsOfAll(int neighborIndex)
KnnResults
n
-th neighbor indices for all queries.getNthNeighborIdsOfAll
in interface KnnResults
neighborIndex
- 0-based neigbbor indexpublic double getDissimilarity(int queryIndex, int neighborIndex)
KnnResults
getDissimilarity
in interface KnnResults
queryIndex
- QueryneighborIndex
- Neighbor indexKnnResults.getNeighborDissimilaritiesMissingValue()
public double getNeighborDissimilaritiesMissingValue()
KnnResults
KnnResults.getNthNeighborDissimilaritiesOfAll(int)
.getNeighborDissimilaritiesMissingValue
in interface KnnResults
public double[] getNthNeighborDissimilaritiesOfAll(int neighborIndex)
KnnResults
n
-th neighbor dissimilarities for all queries.getNthNeighborDissimilaritiesOfAll
in interface KnnResults
neighborIndex
- 0-based neigbbor indexKnnResults.getNeighborDissimilaritiesMissingValue()
when
given neighbor is not present