Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distance_fn with bigger return type? #32

Open
wentasah opened this issue May 10, 2023 · 2 comments
Open

distance_fn with bigger return type? #32

wentasah opened this issue May 10, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@wentasah
Copy link

I have a KdTree<FixedI32<U0>, usize, 2, 32, u32>. When I want to use squared_euclidean as distance_fn, I get an overflow. Would it be possible to support FixedI64 as distance_fn return type?

Currently, I work around it by using KdTree<FixedI64<U0>,...>, which seems wasteful.

@sdd
Copy link
Owner

sdd commented May 10, 2023

Hi Michael. That's a good point. When I used FixedU16 I was having to sacrifice some precision in order to ensure that the distance would not overflow, which is not ideal.

Getting this working generically will be interesting - I'll have a think about how it could be done. Any suggestions or PRs appreciated, if you have some ideas.

@sdd sdd added the enhancement New feature or request label Oct 9, 2023
@NeuralModder
Copy link

Hi Scott,

Again with the RGB color information. Since RGB values can be stored in a U8F0, I tried using that as coordinate type, but distances are frequently higher than 255 even with the Manhattan distance function, which forces me to use a U16F0 because of this issue.
I would say, to fix this, maybe just always set the distance type to a FixedU64 with the given bits of precision? Or calculate the maximum distance for the given coordinate type and distance function, and pick the smallest FixedUx that will fit; not sure if that's worth it though.

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

No branches or pull requests

3 participants