sprs: Compilation error with CsMat and generic Float
I am new to sprs library, I do not understand why the following program does not compile:
use num_traits::Float;
use sprs::CsMat;
fn test<F: Float>(val: F) -> CsMat<F> {
let a = CsMat::new_csc(
(3, 3),
vec![0, 2, 4, 5],
vec![0, 1, 0, 2, 2],
vec![val, val, val, val, val],
);
let b = &a + &a;
b
}
fn main() {
let a = test(1.);
}
with the following dependencies
[dependencies] sprs = "0.10" num-traits = "0.2"
and when I try to build I get:
error[E0369]: cannot add `&CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>` to `&CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>`
--> src\main.rs:11:16
|
11 | let b = &a + &a;
| -- ^ -- &CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>
| |
| &CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>
error: aborting due to previous error
For more information about this error, try `rustc --explain E0369`.
error: could not compile `test-sprs`
To learn more, run the command again with --verbose.
I cannot see what is missing to enable the addition. Thanks for your help.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 26
I think the original compilation error is gone with the following extra bounds:
Thanks @vbarrielle,
0.9.4
should be uploaded now.