Schur decomposition and trait bound `Const<R>: ToTypenum` is not satisfied
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I'm getting this error mesage for my function matrixfunc (full code further below):
> error[E0277]: the trait bound `Const: ToTypenum` is not satisfied
--> src/bin/schur2.rs:25:22
|
25 | let A_decomp = A.schur();
| ^^^^^ the trait `ToTypenum` is not implemented for `Const`
|
= help: the following implementations were found:
as ToTypenum>
as ToTypenum>
as ToTypenum>
as ToTypenum>
and 124 others
= note: required because of the requirements on the impl of `DimSub>` for `Const`
I've been able to write simple functions that take matrices, but I don't understand what is going wrong when I want to take the Schur decomposition. If all my code is in main(), getting the Schur decomposition works fine. Should I be using a specific sub-type of matrix, like OMatrix or DMatrix? What do I need to do to fix this?
Thanks.
Here's the full code:
```rust
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
extern crate nalgebra as na;
use na::*;
use std::fmt::Display;
pub type Matrix5x5 = SMatrix;
pub type Matrix3x3 = SMatrix;
pub type Matrix5x3 = SMatrix;
fn matrixfunc
( A : SMatrix,
B : SMatrix,
D : SMatrix
) -> SMatrix
{
let A_decomp = A.schur();
let (U, A_schur) = A_decomp.unpack();
let B_decomp = B.schur();
let (V, B_schur) = B_decomp.unpack();
let result = U.transpose() * D * V;
println!("{}", result);
result
}
fn main() {
let A = Matrix5x5::from_row_slice(&[
-5.0, 2.0, 7.0, 1.0, -8.0,
3.0, -6.0, 2.0, -2.0, -4.0,
-1.0, 4.0, -2.0, 6.0, 3.0,
-4.0, -7.0, -1.0, 5.0, -2.0,
-2.0, 3.0, 1.0, 0.0, 9.0]);
let B = Matrix3x3::from_row_slice(&[
-5.0, 2.0, 7.0,
3.0, -6.0, 2.0,
-1.0, 4.0, -2.0]);
let D = Matrix5x3::from_row_slice(&[
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0,
1.0, 2.0, 3.0,
4.0, 5.0, 6.0]);
let E = matrixfunc(A,B, D);
println!("{}", E);
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.