Skip to content

Local Kriging Backend - #27

Draft
nafetsk wants to merge 4 commits into
GeoStat-Framework:mainfrom
nafetsk:main
Draft

nafetsk wants to merge 4 commits into
GeoStat-Framework:mainfrom
nafetsk:main

Conversation

@nafetsk

@nafetsk nafetsk commented Oct 14, 2026

Copy link
Copy Markdown

No description provided.

Comment thread src/local_krige.rs
Comment on lines +296 to +300
let mut tree: KdTree<f64, usize, Vec<f64>> = KdTree::new(dim);
for i in 0..cond_no {
tree.add(cond_pos.column(i).to_vec(), i)
.expect("cond_pos columns are finite and match `dim`");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kdtree crate is a somewhat involved implementation of the basic idea. You do not seem to actually require anything from the "bucket point-region implementation" or even mutability at all and hence could use a much simpler and likely more efficient implementation. For example, both kd-tree and sif-kdtree would seem to fit that bill.

Of course, the dimension is not strictly fixed by this interface and the simpler crates usually require a compile-time dimension. IIRC, GSTools do not really support arbitrary dimensions here anyway? Hence specialising the implementation for 2 and 3 dimensions (using const generics) and just dynamically dispatching into those entry points might generally be preferable as it avoids the overhead of many short Vec<f64>.

Comment thread src/local_krige.rs
Comment on lines +365 to +368
.num_threads(num_threads.unwrap_or(rayon::current_num_threads()))
.build()
.unwrap()
.install(|| {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why build a dedicated thread pool using the defaults here instead of relying on the ambient and/or global pool to parallelise as appropriate?

Comment thread src/local_krige.rs
fn euclidean_dist(a: ArrayView1<'_, f64>, b: ArrayView1<'_, f64>) -> f64 {
a.iter()
.zip(b.iter()) // (&f64, &f64)
.map(|(x, y)| (x - y) * (x - y)) // |(x, y)| is type for closure

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is usually preferable to zip array views directly instead of immediately falling down to standard iterators as this will mean ndarray's own iteration and loop unrolling idioms can be brought to bear which more closely target numeric code.

@LSchueler LSchueler added the enhancement New feature or request label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants