statrs-dev / statrs

Statistical computation library for Rust
https://docs.rs/statrs/latest/statrs/
MIT License
546 stars 78 forks source link

[request] Update nalgebra dependency #194

Closed saona-raimundo closed 2 months ago

saona-raimundo commented 8 months ago

I was using the MultivariateNormal. Specifically, the continuous trait.

In my case, I had the data in ndarray, so I passed it to nalgebra. But the nalgebra has a new version of 1d arrays.

For reference, this is the extract from rustc

                              gaussians[i].pdf(&nalgebra::base::DVector::from(point.to_vec())))
    |                                                --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&Matrix<f64, Dynamic, ..., ...>`, found `&Matrix<f64, Dyn, Const<1>, ...>`
    |                                                |
    |                                                arguments to this method are incorrect
    |
    = note: `Matrix<f64, Dyn, Const<1>, ...>` and `Matrix<f64, Dynamic, Const<1>, ...>` have similar names, but are actually distinct types
note: `Matrix<f64, Dyn, Const<1>, ...>` is defined in crate `nalgebra`
   --> ...\nalgebra-0.32.3\src\base\matrix.rs:175:1
    |
175 | pub struct Matrix<T, R, C, S> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `Matrix<f64, Dynamic, Const<1>, ...>` is defined in crate `nalgebra`
   --> ...\nalgebra-0.29.0\src\base\matrix.rs:157:1
    |
157 | pub struct Matrix<T, R, C, S> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `nalgebra` are being used?
saona-raimundo commented 8 months ago

As a second thought, would it not be better to impl<'a> Continuous<&'a [f64]> for MultivariateNormal?

Heeten commented 5 months ago

I'm running into friction due to the older nalgebra version as well. Just curious what the best way to get traction on this is? It looks like there's already PR #187 and multiple other PRs to upgrade the version.

saona-raimundo commented 2 months ago

The implementation of impl Continuous<Vec<f64>> for MultivariateNormal solves the issue.