pub type VecD = OVector<i32, Dyn>;
let a = VecD::from_vec(vec![0, 1, 2, 3]);
let b = a.view((0, 0), (2, 1)).clone_owned();
this works and I get b
with Matrix<i32, Dyn, Dyn, VecStorage<i32, Dyn, Dyn>>
type.
In contrast,
let b: VecD = a.view((0, 0), (2, 1)).clone_owned();
does not work and throws:
Type mismatch [E0308] expected `VecD`, but found `OMatrix<i32, Dyn, Dyn>`
How can I clone the matrix view into Matrix<i32, Dyn, Const<1>, VecStorage<i32, Dyn, Const<1>>>
type?
Looks like generic_view()
is what you want:
let b = a.generic_view((0, 0), (Dyn(2), Const::<1>)).clone_owned();