#![allow(dead_code)] //! Test some nalgebra generic shape constraints do as expected. use nalgebra::base::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; use nalgebra::{allocator::Allocator, DefaultAllocator, U1, U2}; use nalgebra::{Const, Dim, DimName, Dyn}; use nalgebra::{OMatrix, RealField, Vector2}; trait GenericDim { fn dim(&self) -> D; } struct UseU1 {} struct UseU2 {} impl GenericDim for UseU1 { fn dim(&self) -> U1 { Const::<1> } } impl GenericDim for UseU2 { fn dim(&self) -> U2 { Const::<2> } } fn test_dimeq() where ShapeConstraint: DimEq, { } #[test] pub fn try_test_dimeq() { test_dimeq::(); test_dimeq::(); } fn new_copy( r: R, c: C, m: &OMatrix, ) -> OMatrix where DefaultAllocator: Allocator + Allocator + Allocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, { let mut zeroed = OMatrix::::zeros_generic(r, c); zeroed.copy_from(m); zeroed } fn xx() where DefaultAllocator: Allocator + Allocator + Allocator, { let z2 = Vector2::::zeros(); let mut vd = new_copy(Dyn(2), U1, &z2); vd.copy_from(&z2); let mut vn = new_copy(Const::<2>, Const::<1>, &z2); vn.copy_from(&z2); }