Closed ghost closed 3 years ago
The diff looks a bit wild, but I would say that this is mainly due to indentation changes when the unmodified implementation of each function is moved into the inner function imaginatively named inner
.
Wow, that is so awesome! I see that I still got a lot to learn. Also, your commits are very well defined, which helps keeping track of your changes.
I didn't even get to look at Rust macros yet.
And I definitely have to get used to the differences in ArrayX
and ArrayViewX
:-)
The implementation of the estimators is really elegant, I would have never thought of something like that in Cython.
As the
impl Fn(...) -> ...
opaque type will resolve tofn(...) -> ...
, the estimator and distance functions will be called via function pointers, i.e. via dynamic dispatch.To avoid this, two traits -
Estimator
andDistance
- are defined and the various algorithms are parametrized on those traits using type-level parameters. This way, the actual implementations will be monomorphized for the relevant combinations of estimator and distance function.The static dispatch over the trait types is factored out using two rule-based helper macros.
Finally, the
Estimator
is converted to use array views instead of references to arrays so that the implementation ofnormalize_vec
becomes independent of the estimator and can be parallelized usingZip::par_for_each
.