rust-ndarray / ndarray-stats

Statistical routines for ndarray
https://docs.rs/ndarray-stats
Apache License 2.0
201 stars 25 forks source link

Can we improve speed of `argmin`/`min` by removing the `Result` part? #85

Closed fzyzcjy closed 2 years ago

fzyzcjy commented 3 years ago

Hi thanks for the lib! When looking at code:

https://github.com/rust-ndarray/ndarray-stats/blob/b6628c6a1c143532673213c56d46da5fda80cbe8/src/quantile/mod.rs#L289-L304

I see some error handling. IMHO this may make the code much slower. Since I am only working with f32 or i32 or similar primitive numbers, can we remove such error handling? Thanks!

nilgoyette commented 2 years ago

You realize that this library exists for all kinds of programmers with different needs? Asking to remove something because you don't need it is not useful. In fact, you might need that "slow" error handling... it's checking for NaN which you might have because you're using f32.

By the way, you can use argmin_skipnan. It does the same thing but it ignore NaN.

fzyzcjy commented 2 years ago

Well I should say "adding a new function without this functionality to speed up".

Anyway now I know argmin_skipnan, thanks!