Running into what seems like an odd issue when trying to multiply a square matrix A with X rows and X columns by a vector x with X rows, constructed from a struct with generic sizing. Just a basic A*x = b operation. The end goal is to have a struct type with a generic size X that can be declared when the struct is created, rather than use a static sizing.
The data struct
and associated methods are as follows:
struct Foo<T, const X: usize>{
A: na::base::SMatrix<T, X, X>,
x: na::base::SVector<T, X>
}
impl<T, const X: usize> Foo<T, X> {
fn b(&self) > na::base::SVector<T, X> {
self.A*self.x
}
}
However, the compiler throws an error when trying to multiply the two, that A and x are incompatible:
error[E0369]: cannot multiply `Matrix<T, Const<X>, Const<X>, ArrayStorage<T, X, X>>` by `Matrix<T, Const<X>, Const<1_usize>, ArrayStorage<T, X, 1_usize>>`
> src\main.rs:989:15

989  self.A*self.x
 ^ Matrix<T, Const<X>, Const<1_usize>, ArrayStorage<T, X, 1_usize>>
 
 Matrix<T, Const<X>, Const<X>, ArrayStorage<T, X, X>>
What am I doing wrong here? I'm still learning Rust's generic type system, is there something in the impl declaration I should change? Would appreciate any feedback on implementation.