Mojo struct
KDTree
@memory_only
struct KDTree[sort_results: Bool = False, rearrange: Bool = True]
Aliases
bucketsize = 12__del__is_trivial = False__moveinit__is_trivial = False__copyinit__is_trivial = False
Parameters
- sort_results (
Bool) - rearrange (
Bool)
Fields
- N (
Int) - dim (
Int) - root (
UnsafePointer[KDTreeNode, MutAnyOrigin]) - ind (
List[Scalar[DType.index]]) - metric (
fn(Float32) -> Float32)
Implemented traits
AnyType, Copyable, ImplicitlyDestructible, Movable
Methods
__init__
fn __init__(out self, X: Matrix, metric: String = "euc", *, build: Bool = True)
Args:
- X (
Matrix) - metric (
String) - build (
Bool) - self (
Self)
Returns:
Self
Raises:
__moveinit__
@staticmethod
fn __moveinit__(out self, deinit existing: Self)
Args:
- existing (
Self) - self (
Self)
Returns:
Self
__del__
fn __del__(deinit self)
Args:
- self (
Self)
build_tree
fn build_tree(mut self)
Args:
- self (
Self)
Raises:
build_tree_for_range
fn build_tree_for_range(mut self, l: Int, u: Int, parent: UnsafePointer[KDTreeNode, MutAnyOrigin]) -> UnsafePointer[KDTreeNode, MutAnyOrigin]
Args:
- self (
Self) - l (
Int) - u (
Int) - parent (
UnsafePointer)
Returns:
UnsafePointer
spread_in_coordinate
fn spread_in_coordinate(self, c: Int, l: Int, u: Int, mut interv: interval)
Args:
- self (
Self) - c (
Int) - l (
Int) - u (
Int) - interv (
interval)
select_on_coordinate
fn select_on_coordinate(mut self, c: Int, k: Int, var l: Int, var u: Int)
Args:
- self (
Self) - c (
Int) - k (
Int) - l (
Int) - u (
Int)
select_on_coordinate_value
fn select_on_coordinate_value(mut self, c: Int, alpha: Float32, l: Int, u: Int) -> Int
Args:
- self (
Self) - c (
Int) - alpha (
Float32) - l (
Int) - u (
Int)
Returns:
Int
n_nearest
fn n_nearest(mut self, qv: Span[Float32, MutAnyOrigin], nn: Int, mut result: KDTreeResultVector)
Args:
- self (
Self) - qv (
Span) - nn (
Int) - result (
KDTreeResultVector)
n_nearest_around_point
fn n_nearest_around_point(mut self, idxin: Int, correltime: Int, nn: Int, mut result: KDTreeResultVector)
Args:
- self (
Self) - idxin (
Int) - correltime (
Int) - nn (
Int) - result (
KDTreeResultVector)
r_nearest
fn r_nearest(mut self, qv: Span[Float32, MutAnyOrigin], r2: Float32, mut result: KDTreeResultVector)
Args:
- self (
Self) - qv (
Span) - r2 (
Float32) - result (
KDTreeResultVector)
r_count
fn r_count(mut self, qv: Span[Float32, MutAnyOrigin], r2: Float32) -> Int
Args:
- self (
Self) - qv (
Span) - r2 (
Float32)
Returns:
Int
r_nearest_around_point
fn r_nearest_around_point(mut self, idxin: Int, correltime: Int, r2: Float32, mut result: KDTreeResultVector)
Args:
- self (
Self) - idxin (
Int) - correltime (
Int) - r2 (
Float32) - result (
KDTreeResultVector)
r_count_around_point
fn r_count_around_point(mut self, idxin: Int, correltime: Int, r2: Float32) -> Int
Args:
- self (
Self) - idxin (
Int) - correltime (
Int) - r2 (
Float32)
Returns:
Int