From 7af509ee8d76e4710b4deab652f32047aa61d8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crozet=20S=C3=A9bastien?= Date: Sun, 25 Oct 2020 16:02:43 +0100 Subject: [PATCH] Reformat the reshaping example. --- examples/reshaping.rs | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/examples/reshaping.rs b/examples/reshaping.rs index bf02e769..f164e192 100644 --- a/examples/reshaping.rs +++ b/examples/reshaping.rs @@ -1,11 +1,20 @@ +#![cfg_attr(rustfmt, rustfmt_skip)] + extern crate nalgebra as na; use na::{DMatrix, Dynamic, Matrix2x3, Matrix3x2, U2, U3}; fn main() { // Matrices can be reshaped in-place without moving or copying values. - let m1 = Matrix2x3::new(1.1, 1.2, 1.3, 2.1, 2.2, 2.3); - let m2 = Matrix3x2::new(1.1, 2.2, 2.1, 1.3, 1.2, 2.3); + let m1 = Matrix2x3::new( + 1.1, 1.2, 1.3, + 2.1, 2.2, 2.3 + ); + let m2 = Matrix3x2::new( + 1.1, 2.2, + 2.1, 1.3, + 1.2, 2.3 + ); let m3 = m1.reshape_generic(U3, U2); assert_eq!(m3, m2); @@ -14,15 +23,23 @@ fn main() { //let m4 = m3.reshape_generic(U3, U3); // If dynamically sized matrices are used, the reshaping is checked at run-time. - let dm1 = DMatrix::from_vec( + let dm1 = DMatrix::from_row_slice( 4, 3, - vec![1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0], + &[ + 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, + 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0 + ], ); - let dm2 = DMatrix::from_vec( + let dm2 = DMatrix::from_row_slice( 6, 2, - vec![1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0], + &[ + 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, + 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 + ], ); let dm3 = dm1.reshape_generic(Dynamic::new(6), Dynamic::new(2));