Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convolution with SVector #1466

Open
cgroves3 opened this issue Nov 17, 2024 · 0 comments
Open

Convolution with SVector #1466

cgroves3 opened this issue Nov 17, 2024 · 0 comments

Comments

@cgroves3
Copy link

cgroves3 commented Nov 17, 2024

I'm trying to use the convolve methods with SVector's, but it doesn't seem to work. Here is an example:

use nalgebra::{DVector, SVector};

mod image;

fn main() {
    let vec = vec![1.0,2.0,3.0,4.0];
    let kernel = vec![1.0,2.0];
    let vec_d = DVector::from_vec(vec.clone());
    let ker_d = DVector::from_vec(kernel.clone());

    let expected_d_full = vec_d.convolve_full(ker_d.clone());
    let expected_d_valid = vec_d.convolve_valid(ker_d.clone());
    let expected_d_same = vec_d.convolve_same(ker_d);

    println!("full d: {:?}",expected_d_full);
    println!("valid d: {:?}",expected_d_valid);
    println!("same d: {:?}",expected_d_same);

    let vec_s = SVector::from_vec(vec);
    let ker_s = SVector::from_vec(kernel);

    let expected_s_full = vec_s.convolve_full(ker_s.clone());
    let expected_s_valid = vec_s.convolve_valid(ker_s.clone());
    let expected_s_same = vec_s.convolve_same(ker_s);

    println!("full s: {:?}",expected_s_full);
    println!("valid s: {:?}",expected_s_valid);
    println!("same s: {:?}",expected_s_same);
}

This produces the following error:

error[E0599]: no method named `convolve_full` found for struct `Matrix<{float}, nalgebra::Const<_>, nalgebra::Const<1>, ArrayStorage<{float}, _, 1>>` in the current scope
  --> src/main.rs:33:33
   |
33 |     let expected_s_full = vec_s.convolve_full(ker_s.clone());
   |                                 ^^^^^^^^^^^^^ method not found in `Matrix<{float}, Const<_>, Const<1>, ArrayStorage<{float}, _, 1>>`
   |
   = note: the method was found for
           - `Matrix<T, D1, nalgebra::Const<1>, S1>`

Is there any way to make these methods abstract of the type of Vector? Or does there need to be a second set of methods for the SVector type?

@cgroves3 cgroves3 changed the title Convolultion with SVector Convolution with SVector Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant