public abstract class KDTreePositions extends Object
Currently, there are two implementations:
Nested stores the positions as a double[][] where positions[d][i] is dimension d of the i-th point. This
allows for a total of 2^31-8 nodes but doesn't keep the positions
contiguous in memory.Flat stores the positions as a double[] where positions[d + i*n] is dimension d of the i-th point, with
n the number of dimensions. This means that the positions are
contiguous in memory but the number of nodes is limited to (2^31-8)/n.asNestedArray() returns positions in nested double[][]
(which is created if class is Flat). asFlatArray()
returns flat double[] if class is Flat, otherwise null.| Modifier and Type | Class and Description |
|---|---|
static class |
KDTreePositions.PositionsLayout
With
NESTED layout, positions are stored as a nested double[][] array where positions[d][i] is dimension d of
the i-th point. |
| Modifier and Type | Method and Description |
|---|---|
abstract double[] |
asFlatArray()
Get positions of points in the tree as a flat
double[] array
where positions[d + i*n] is dimension d of the i-th
point. |
abstract double[][] |
asNestedArray()
Get positions of points in the tree as a nested
double[][] array
where positions[d][i] is dimension d of the i-th
point. |
static KDTreePositions |
createFlat(double[] positions,
int numDimensions)
Create
KDTreePositions with FLAT layout(). |
static KDTreePositions |
createNested(double[][] positions)
Create
KDTreePositions with NESTED layout(). |
abstract double |
get(int i,
int d)
Get the coordinates of the node
i in dimension d. |
abstract KDTreePositions.PositionsLayout |
layout()
Get the internal layout of positions.
|
int |
numDimensions() |
int |
numPoints() |
public abstract double get(int i,
int d)
i in dimension d.public abstract double[] asFlatArray()
double[] array
where positions[d + i*n] is dimension d of the i-th
point.
For serialisation and usage by the tree.
Internal storage may be a NESTED double[][] array. In
this case, flatPositions() returns null.
public abstract double[][] asNestedArray()
double[][] array
where positions[d][i] is dimension d of the i-th
point.
For serialisation and usage by the tree.
Internal storage may be flattened into single double[] array. In
this case, the nested double[][] array is created here.
public abstract KDTreePositions.PositionsLayout layout()
Positions are stored in either FLAT or NESTED layout. With NESTED layout, positions are stored
as a nested double[][] array where positions[d][i] is
dimension d of the i-th point. With FLAT layout,
positions are stored as a flat double[] array, where positions[d + i*n] is dimension d of the i-th point,
with n the number of dimensions.
public int numDimensions()
public int numPoints()
public static KDTreePositions createNested(double[][] positions)
KDTreePositions with NESTED layout().public static KDTreePositions createFlat(double[] positions, int numDimensions)
KDTreePositions with FLAT layout().Copyright © 2009–2024 ImgLib2. All rights reserved.