nalgebra icon indicating copy to clipboard operation
nalgebra copied to clipboard

additional means of construction for constants

Open sed-i opened this issue 3 years ago • 1 comments

This compiles with nalgebra 0.29.0:

const ZERO: Vector3<f64> = Vector3::new(0.0, 0.0, 0.0);

but these do not:

const ZERO: Vector3<f64> = Vector3::zeros();
const ZERO: Vector3<f64> = Vector3::from_row_slice(&[0.0, 0.0, 0.0]);

// error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants

It would be handy if additional means of construction (e.g. zeros) could be used for constants.

sed-i avatar Jan 03 '22 05:01 sed-i

Unfortunately the user guide has not yet been updated, but the macros vector! and matrix! should do what you want:

const ZERO: Vector3<f64> = vector![0.0, 0.0, 0.0];

Hope that helps!

Andlon avatar Jan 03 '22 07:01 Andlon