File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1750,6 +1750,7 @@ where
17501750
17511751 #[ inline]
17521752 fn abs_diff_eq ( & self , other : & Self , epsilon : Self :: Epsilon ) -> bool {
1753+ assert ! ( self . shape( ) == other. shape( ) ) ;
17531754 self . iter ( )
17541755 . zip ( other. iter ( ) )
17551756 . all ( |( a, b) | a. abs_diff_eq ( b, epsilon. clone ( ) ) )
Original file line number Diff line number Diff line change @@ -1342,3 +1342,26 @@ fn parallel_column_iteration_mut() {
13421342 assert_eq ! ( first, second) ;
13431343 assert_eq ! ( second, DMatrix :: identity( 400 , 300 ) ) ;
13441344}
1345+
1346+ #[ test]
1347+ fn abs_diff_eq_basic_test ( ) {
1348+ use approx:: AbsDiffEq ;
1349+ use nalgebra_macros:: dvector;
1350+
1351+ let a = dvector ! [ 1.0 , 2.0 ] ;
1352+ let b = dvector ! [ 1.0 , 2.0 ] ;
1353+
1354+ assert ! ( a. abs_diff_eq( & b, 1e-6 ) ) ;
1355+ }
1356+
1357+ #[ test]
1358+ #[ should_panic]
1359+ fn abs_diff_eq_nonmatching_shapes ( ) {
1360+ use approx:: AbsDiffEq ;
1361+ use nalgebra_macros:: dvector;
1362+
1363+ let a = dvector ! [ 1.0 , 2.0 , 3.0 ] ;
1364+ let b = dvector ! [ 1.0 , 2.0 ] ;
1365+
1366+ a. abs_diff_eq ( & b, 1e-6 ) ;
1367+ }
You can’t perform that action at this time.
0 commit comments