I would like to have a matrix in ndarray
as a constant available for other modules. Unfortunately, the construction function itself is not a constant function. Is there any way around that restriction?
Code:
extern crate ndarray;
use ndarray::prelude::*;
const foo: Array2<f32> = arr2(&[
[1.26, 0.09], [0.79, 0.92]
]);
fn main() {
println!("{}", foo);
}
Error:
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> src\main.rs:5:26
|
5 | const foo: Array2<f32> = arr2(&[
| __________________________^
6 | | [1.26, 0.09], [0.79, 0.92]
7 | | ]);
| |__^