T - Type of object being compared.public class ObjectNearestNeighboursExact<T> extends ObjectNearestNeighbours<T> implements IncrementalNearestNeighbours<T,float[],IntFloatPair>
DistanceComparator.| Modifier and Type | Class and Description |
|---|---|
static class |
ObjectNearestNeighboursExact.Factory<T>
NearestNeighboursFactory for producing
ObjectNearestNeighboursExacts. |
| Modifier and Type | Field and Description |
|---|---|
protected List<T> |
pnts |
distance| Constructor and Description |
|---|
ObjectNearestNeighboursExact(DistanceComparator<T> distance)
Construct any empty
ObjectNearestNeighboursExact with the given
distance function. |
ObjectNearestNeighboursExact(List<T> pnts,
DistanceComparator<? super T> distance)
Construct the
ObjectNearestNeighboursExact over the provided
dataset with the given distance function. |
ObjectNearestNeighboursExact(T[] pnts,
DistanceComparator<? super T> distance)
Construct the
ObjectNearestNeighboursExact over the provided
dataset with the given distance function. |
| Modifier and Type | Method and Description |
|---|---|
int |
add(T o)
Add a single data item
|
int[] |
addAll(List<T> d)
Insert all the given data
|
void |
searchKNN(List<T> qus,
int K,
int[][] indices,
float[][] distances)
Search for the K nearest neighbours to each of the N queries, and return
the indices of each nearest neighbour and their respective distances.
|
void |
searchKNN(T[] qus,
int K,
int[][] indices,
float[][] distances)
Search for the K nearest neighbours to each of the N queries, and return
the indices of each nearest neighbour and their respective distances.
|
List<IntFloatPair> |
searchKNN(T query,
int K)
Search for the K nearest neighbours to the given query and return an
ordered list of pairs containing the distance and index of each
neighbour.
|
void |
searchNN(List<T> qus,
int[] indices,
float[] distances)
Search for the nearest neighbour to each of the N queries, and return the
index of each nearest neighbour and the respective distance.
|
IntFloatPair |
searchNN(T query)
Search for the nearest neighbour to the given query and return a pair
containing the distance and index of that neighbour.
|
void |
searchNN(T[] qus,
int[] indices,
float[] distances)
Search for the nearest neighbour to each of the N queries, and return the
index of each nearest neighbour and the respective distance.
|
int |
size()
Get the size of the dataset
|
distanceComparator, distanceFuncpublic ObjectNearestNeighboursExact(List<T> pnts, DistanceComparator<? super T> distance)
ObjectNearestNeighboursExact over the provided
dataset with the given distance function.
Note: If the distance function provides similarities rather than distances they are automatically inverted.
pnts - the datasetdistance - the distance functionpublic ObjectNearestNeighboursExact(T[] pnts, DistanceComparator<? super T> distance)
ObjectNearestNeighboursExact over the provided
dataset with the given distance function.
Note: If the distance function provides similarities rather than distances they are automatically inverted.
pnts - the datasetdistance - the distance functionpublic ObjectNearestNeighboursExact(DistanceComparator<T> distance)
ObjectNearestNeighboursExact with the given
distance function.
Note: If the distance function provides similarities rather than distances they are automatically inverted.
distance - the distance functionpublic void searchNN(T[] qus, int[] indices, float[] distances)
NearestNeighboursFor efficiency, to use this method, you need to pre-construct the arrays for storing the results outside of the method and pass them in as arguments.
If a nearest-neighbour cannot be determined, it will have an index value of -1
searchNN in interface NearestNeighbours<T,float[],IntFloatPair>qus - An array of N query vectorsindices - The return N-dimensional array for holding the indices of the
nearest neighbour of each respective query.distances - The return N-dimensional array for holding the distances of
the nearest neighbour to each respective query.public void searchKNN(T[] qus, int K, int[][] indices, float[][] distances)
NearestNeighboursFor efficiency, to use this method, you need to pre-construct the arrays for storing the results outside of the method and pass them in as arguments.
If a k-th nearest-neighbour cannot be determined, it will have an index value of -1
searchKNN in interface NearestNeighbours<T,float[],IntFloatPair>qus - An array of N query vectorsK - the number of neighbours to findindices - The return N*K-dimensional array for holding the indices of
the K nearest neighbours of each respective query.distances - The return N*K-dimensional array for holding the distances of
the nearest neighbours of each respective query.public void searchNN(List<T> qus, int[] indices, float[] distances)
NearestNeighboursFor efficiency, to use this method, you need to pre-construct the arrays for storing the results outside of the method and pass them in as arguments.
If a nearest-neighbour cannot be determined, it will have an index value of -1
searchNN in interface NearestNeighbours<T,float[],IntFloatPair>qus - An array of N query vectorsindices - The return N-dimensional array for holding the indices of the
nearest neighbour of each respective query.distances - The return N-dimensional array for holding the distances of
the nearest neighbour to each respective query.public void searchKNN(List<T> qus, int K, int[][] indices, float[][] distances)
NearestNeighboursFor efficiency, to use this method, you need to pre-construct the arrays for storing the results outside of the method and pass them in as arguments.
If a k-th nearest-neighbour cannot be determined, it will have an index value of -1
searchKNN in interface NearestNeighbours<T,float[],IntFloatPair>qus - An array of N query vectorsK - the number of neighbours to findindices - The return N*K-dimensional array for holding the indices of
the K nearest neighbours of each respective query.distances - The return N*K-dimensional array for holding the distances of
the nearest neighbours of each respective query.public List<IntFloatPair> searchKNN(T query, int K)
NearestNeighboursIf k neighbours cannot be determined, then the resultant list might have fewer than k elements.
searchKNN in interface NearestNeighbours<T,float[],IntFloatPair>query - the query vectorK - the number of neighbours to search forpublic IntFloatPair searchNN(T query)
NearestNeighbours
If the nearest-neighbour cannot be determined null will be
returned.
searchNN in interface NearestNeighbours<T,float[],IntFloatPair>query - the query vectorpublic int size()
NearestNeighbourssize in interface NearestNeighbours<T,float[],IntFloatPair>public int[] addAll(List<T> d)
IncrementalNearestNeighboursaddAll in interface IncrementalNearestNeighbours<T,float[],IntFloatPair>d - the datapublic int add(T o)
IncrementalNearestNeighboursadd in interface IncrementalNearestNeighbours<T,float[],IntFloatPair>o - the object to add