Mojo struct
KDTree
@memory_only
struct KDTree[sort_results: Bool = False, rearrange: Bool = True]
Aliases
bucketsize = 12
Parameters
- sort_results (
Bool) - rearrange (
Bool)
Fields
- N (
Int) - dim (
Int) - root (
Optional[Pointer[KDTreeNode, MutUntrackedOrigin]]) - ind (
List[Int]) - metric (
def(Float32) thin -> Float32)
Implemented traits
AnyType, Copyable, Deinitable, Movable
Methods
__init__
fn def __init__(out self, X: Matrix, metric: String = "euc", *, build: Bool = True)
Args:
- X (
Matrix) - metric (
String) - build (
Bool) - self (
Self)
Returns:
Self
Raises:
fn def __init__(out self, *, deinit move: Self)
Args:
- move (
Self) - self (
Self)
Returns:
Self
__deinit__
fn def __deinit__(deinit self)
Args:
- self (
Self)
build_tree
fn def build_tree(mut self)
Args:
- self (
Self)
Raises:
build_tree_for_range
fn def build_tree_for_range(mut self, l: Int, u: Int, parent: Optional[Pointer[KDTreeNode, MutUntrackedOrigin]]) -> Optional[Pointer[KDTreeNode, MutUntrackedOrigin]]
Args:
- self (
Self) - l (
Int) - u (
Int) - parent (
Optional[Pointer[KDTreeNode, MutUntrackedOrigin]])
Returns:
Optional[Pointer[KDTreeNode, MutUntrackedOrigin]]
Raises:
spread_in_coordinate
fn def 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 def 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 def 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 def n_nearest(self, qv: Span[Float32, MutUntrackedOrigin], nn: Int, mut result: KDTreeResultVector)
Args:
- self (
Self) - qv (
Span[Float32, MutUntrackedOrigin]) - nn (
Int) - result (
KDTreeResultVector)
Raises:
n_nearest_around_point
fn def n_nearest_around_point(self, idxin: Int, correltime: Int, nn: Int, mut result: KDTreeResultVector)
Args:
- self (
Self) - idxin (
Int) - correltime (
Int) - nn (
Int) - result (
KDTreeResultVector)
Raises:
r_nearest
fn def r_nearest(self, qv: Span[Float32, MutUntrackedOrigin], r2: Float32, mut result: KDTreeResultVector)
Args:
- self (
Self) - qv (
Span[Float32, MutUntrackedOrigin]) - r2 (
Float32) - result (
KDTreeResultVector)
Raises:
r_count
fn def r_count(self, qv: Span[Float32, MutUntrackedOrigin], r2: Float32) -> Int
Args:
- self (
Self) - qv (
Span[Float32, MutUntrackedOrigin]) - r2 (
Float32)
Returns:
Int
Raises:
r_nearest_around_point
fn def r_nearest_around_point(self, idxin: Int, correltime: Int, r2: Float32, mut result: KDTreeResultVector)
Args:
- self (
Self) - idxin (
Int) - correltime (
Int) - r2 (
Float32) - result (
KDTreeResultVector)
Raises:
r_count_around_point
fn def r_count_around_point(self, idxin: Int, correltime: Int, r2: Float32) -> Int
Args:
- self (
Self) - idxin (
Int) - correltime (
Int) - r2 (
Float32)
Returns:
Int
Raises: