public class DoubleKDTree extends Object
DoubleKDTree.SplitChooser
. Supports efficient range, radius and
nearest-neighbour search for relatively low dimensional spaces.Modifier and Type | Class and Description |
---|---|
static class |
DoubleKDTree.ApproximateBBFMedianSplit
Approximate best-bin-first median splitting.
|
static class |
DoubleKDTree.BasicMedianSplit
Basic median split.
|
static class |
DoubleKDTree.BBFMedianSplit
Best-bin-first median splitting.
|
static class |
DoubleKDTree.KDTreeNode
An internal node of the KDTree
|
static class |
DoubleKDTree.RandomisedBBFMeanSplit
Randomised best-bin-first splitting strategy:
Nodes with less than a set number of items become leafs.
|
static interface |
DoubleKDTree.SplitChooser
Interface for describing how a branch in the KD-Tree should be created
|
Modifier and Type | Field and Description |
---|---|
double[][] |
data
The underlying data array
|
DoubleKDTree.KDTreeNode |
root
The tree roots
|
Constructor and Description |
---|
DoubleKDTree(double[][] data)
Construct with the given data and default splitting strategy (
DoubleKDTree.BBFMedianSplit ) |
DoubleKDTree(double[][] data,
DoubleKDTree.SplitChooser split)
Construct with the given data and splitting strategy
|
Modifier and Type | Method and Description |
---|---|
double[][] |
coordinateRadiusSearch(double[] centre,
double radius)
Find all the points within the given radius of the given point.
|
void |
coordinateRadiusSearch(double[] centre,
double radius,
gnu.trove.procedure.TObjectDoubleProcedure<double[]> proc)
Find all the points within the given radius of the given point.
|
double[][] |
coordinateRangeSearch(double[] lowerExtreme,
double[] upperExtreme)
Search the tree for all points contained within the hyperrectangle
defined by the given upper and lower extremes.
|
int[] |
indexRadiusSearch(double[] centre,
double radius)
Search the tree for the indexes of all points contained within the
hypersphere defined by the given centre and radius.
|
int[] |
indexRangeSearch(double[] lowerExtreme,
double[] upperExtreme)
Search the tree for all points contained within the hyperrectangle
defined by the given upper and lower extremes.
|
List<int[]> |
leafIndices()
Find all the indices seperated by leaves
|
IntDoublePair |
nearestNeighbour(double[] qu)
Nearest-neighbour search
|
List<IntDoublePair> |
nearestNeighbours(double[] qu,
int n)
Nearest-neighbour search
|
void |
radiusSearch(double[] centre,
double radius,
gnu.trove.procedure.TIntObjectProcedure<double[]> proc)
Find all the points within the given radius of the given point.
|
void |
rangeSearch(double[] lowerExtreme,
double[] upperExtreme,
gnu.trove.procedure.TIntObjectProcedure<double[]> proc)
Search the tree for all points contained within the hyperrectangle
defined by the given upper and lower extremes.
|
public final DoubleKDTree.KDTreeNode root
public final double[][] data
public DoubleKDTree(double[][] data)
DoubleKDTree.BBFMedianSplit
)data
- the datapublic DoubleKDTree(double[][] data, DoubleKDTree.SplitChooser split)
data
- the datasplit
- the splitting strategypublic double[][] coordinateRangeSearch(double[] lowerExtreme, double[] upperExtreme)
lowerExtreme
- the lower extreme of the hyperrectangleupperExtreme
- the upper extreme of the hyperrectanglepublic int[] indexRangeSearch(double[] lowerExtreme, double[] upperExtreme)
lowerExtreme
- the lower extreme of the hyperrectangleupperExtreme
- the upper extreme of the hyperrectanglepublic int[] indexRadiusSearch(double[] centre, double radius)
centre
- the centre pointradius
- the radiuspublic void radiusSearch(double[] centre, double radius, gnu.trove.procedure.TIntObjectProcedure<double[]> proc)
The search can be stopped early by returning false from the
TIntObjectProcedure.execute(int, Object)
method.
centre
- the centre pointradius
- the radiusproc
- the processpublic void rangeSearch(double[] lowerExtreme, double[] upperExtreme, gnu.trove.procedure.TIntObjectProcedure<double[]> proc)
The search can be stopped early by returning false from the
TIntObjectProcedure.execute(int, Object)
method.
lowerExtreme
- the lower extreme of the hyperrectangleupperExtreme
- the upper extreme of the hyperrectangleproc
- the processorpublic List<IntDoublePair> nearestNeighbours(double[] qu, int n)
qu
- the query pointn
- the number of neighbours to findpublic IntDoublePair nearestNeighbour(double[] qu)
qu
- the query pointpublic double[][] coordinateRadiusSearch(double[] centre, double radius)
centre
- the centre pointradius
- the radiuspublic void coordinateRadiusSearch(double[] centre, double radius, gnu.trove.procedure.TObjectDoubleProcedure<double[]> proc)
The search can be stopped early by returning false from the
TIntObjectProcedure.execute(int, Object)
method.
centre
- the centre pointradius
- the radiusproc
- the processpublic List<int[]> leafIndices()