I am trying to get a P-norm for my simple 1D Vec in Rust, but I am failing with every norman example. Error states that there is no method named `norm` found for struct `ArrayBase` in the current scope
.
What I did:
main.rs
with:use ndarray::Array1;
use norman::Norm;
use norman::desc::{Sup, PNorm};
fn main() {
let a = Array1::from(vec![2.0f32, -4.0, -2.0]);
assert_eq!(a.norm(Sup::new()), 4.0);
assert_eq!(a.norm(PNorm::new(2)), (2.0f32*2.0 + 4.0*4.0 + 2.0*2.0).sqrt());
assert_eq!(a.norm(PNorm::new(1)), 2.0f32 + 4.0 + 2.0);
}
I feel like I am missing something obvious, but I cannot find any other examples or some answers on how to properly use crates with dependencies. I'm not even sure what to ask. Thanks
The latest version of norman
, 0.0.4
, depends on ndarray ^0.12.0
, but your cargo add
will have gotten ndarray 0.15.16
, which is not a semver-compatible version, so cargo
compiles the 0.12.*
and 0.15.*
versions separately.
So, norman
is implementing Norm
for ndarray::ArrayBase
version 0.12 but not for ndarray::ArrayBase
version 0.15.
Things you can do about this situation:
ndarray = "^0.12"
(edit your Cargo.toml
) so you're using the same version as norman
is.norman
to publish an updated version.norman
and patch it to work with ndarray ^0.15
.norman
(license permitting).