diff --git a/examples/convolution.rs b/examples/convolution.rs index 5290440c..d23ed389 100644 --- a/examples/convolution.rs +++ b/examples/convolution.rs @@ -1,5 +1,17 @@ -fn main(){ - let (x,y) = (1,2); +extern crate nalgebra; +use nalgebra::{Vector2,Vector3,Vector4,Vector5,convolve_full,convolve_same,convolve_valid}; - println!("{}", x); +fn main(){ + let vec = Vector4::new(1.0,2.0,3.0,4.0); + let ker = Vector3::new(1.0,2.0,2.1); + + let actual = Vector5::from_vec(vec![1.0,4.0,7.0,10.0,8.0]); + + let expected = convolve_full(vec,ker); + let expected2 = convolve_same(vec,ker); + // let expected3 = convolve_valid(vec,ker); + println!("{}", actual); + println!("{}", expected); + println!("{}", expected2); + // println!("{}", expected3); } \ No newline at end of file diff --git a/src/linalg/convolution.rs b/src/linalg/convolution.rs index c587f8f2..69ae3f5e 100644 --- a/src/linalg/convolution.rs +++ b/src/linalg/convolution.rs @@ -12,18 +12,10 @@ use {zero, Real, Vector, VectorN, U1}; /// * `vector` - A Vector with size > 0 /// * `kernel` - A Vector with size > 0 /// -/// # Note: -/// This function is commutative. If kernel > vector, -/// they will swap their roles as in -/// (self, kernel) = (kernel,self) +/// This function is commutative. If kernel > vector, +/// they will swap their roles as in +/// (self, kernel) = (kernel,self) /// -/// # Example -/// -/// ``` -/// let vec = Vector3::new(1.0,2.0,3.0); -/// let ker = Vector2::new(0.4,0.6); -/// let convolve = convolve_full(vec,ker); -/// ``` pub fn convolve_full( vector: Vector, kernel: Vector, @@ -77,19 +69,11 @@ where /// /// * `vector` - A Vector with size > 0 /// * `kernel` - A Vector with size > 0 +/// +/// This function is commutative. If kernel > vector, +/// they will swap their roles as in +/// (self, kernel) = (kernel,self) /// -/// # Note: -/// This function is commutative. If kernel > vector, -/// they will swap their roles as in -/// (self, kernel) = (kernel,self) -/// -/// # Example -/// -/// ``` -/// let vec = Vector3::new(1.0,2.0,3.0); -/// let ker = Vector2::new(0.4,0.6); -/// let convolve = convolve_valid(vec,ker); -/// ``` pub fn convolve_valid( vector: Vector, kernel: Vector, @@ -133,18 +117,10 @@ where /// * `vector` - A Vector with size > 0 /// * `kernel` - A Vector with size > 0 /// -/// # Note: -/// This function is commutative. If kernel > vector, -/// they will swap their roles as in -/// (self, kernel) = (kernel,self) +/// This function is commutative. If kernel > vector, +/// they will swap their roles as in +/// (self, kernel) = (kernel,self) /// -/// # Example -/// -/// ``` -/// let vec = Vector3::new(1.0,2.0,3.0); -/// let ker = Vector2::new(0.4,0.6); -/// let convolve = convolve_same(vec,ker); -/// ``` pub fn convolve_same( vector: Vector, kernel: Vector,