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:
- cargo new norman-test
- cd norman-test
- cargo add ndarray
- cargo add norman
- replace
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