From e3e71c192072e9e255e5e058bfef0d844b6abeb6 Mon Sep 17 00:00:00 2001 From: conrad Date: Mon, 20 Sep 2021 13:30:46 +1000 Subject: [PATCH] use margin --- tests2/decomp_eig_pair.cpp | 28 ++-- tests2/decomp_eig_sym.cpp | 16 +- tests2/expr_elem.cpp | 48 +++--- tests2/expr_misc.cpp | 2 +- tests2/fn_abs.cpp | 22 +-- tests2/fn_accu.cpp | 12 +- tests2/fn_conj.cpp | 4 +- tests2/fn_conv.cpp | 2 +- tests2/fn_cor.cpp | 10 +- tests2/fn_cov.cpp | 10 +- tests2/fn_cross.cpp | 2 +- tests2/fn_cumprod.cpp | 10 +- tests2/fn_cumsum.cpp | 10 +- tests2/fn_diagmat.cpp | 18 +-- tests2/fn_diagvec.cpp | 8 +- tests2/fn_diff.cpp | 46 +++--- tests2/fn_dot.cpp | 8 +- tests2/fn_eigs_gen.cpp | 144 ++++++++--------- tests2/fn_eigs_sym.cpp | 16 +- tests2/fn_eps.cpp | 2 +- tests2/fn_expmat.cpp | 2 +- tests2/fn_find.cpp | 12 +- tests2/fn_find_unique.cpp | 4 +- tests2/fn_flip.cpp | 20 +-- tests2/fn_hess.cpp | 52 +++--- tests2/fn_interp1.cpp | 4 +- tests2/fn_mean.cpp | 36 ++--- tests2/fn_princomp.cpp | 20 +-- tests2/fn_spsolve.cpp | 54 +++---- tests2/fn_sum.cpp | 22 +-- tests2/fn_symmat.cpp | 16 +- tests2/fn_trace.cpp | 6 +- tests2/fn_trans.cpp | 318 ++++++++++++++++++------------------- tests2/fn_var.cpp | 24 +-- tests2/fn_vectorise.cpp | 6 +- tests2/gen_ones.cpp | 20 +-- tests2/gen_randu.cpp | 18 +-- tests2/gen_zeros.cpp | 24 +-- tests2/gmm.cpp | 12 +- tests2/init_misc.cpp | 6 +- tests2/mat_minus.cpp | 6 +- tests2/mat_mul_cx.cpp | 108 ++++++------- tests2/mat_mul_real.cpp | 284 ++++++++++++++++----------------- tests2/mat_neg.cpp | 2 +- tests2/mat_plus.cpp | 6 +- tests2/spmat.cpp | 166 +++++++++---------- tests2/spsubview.cpp | 138 ++++++++-------- 47 files changed, 902 insertions(+), 902 deletions(-) diff --git a/tests2/decomp_eig_pair.cpp b/tests2/decomp_eig_pair.cpp index ed339fa8..854df8b4 100644 --- a/tests2/decomp_eig_pair.cpp +++ b/tests2/decomp_eig_pair.cpp @@ -69,13 +69,13 @@ TEST_CASE("decomp_eig_pair_1") cx_mat Cr = A2 * reigvecs5 * diagmat(eigvals5) * inv(reigvecs5) ; REQUIRE( status == true ); - REQUIRE( accu(abs(eigvals2 - eigvals1)) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(eigvals3 - eigvals1)) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(eigvals4 - eigvals1)) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(eigvals5 - eigvals1)) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(A1 - B )) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(A1 - Cl )) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(A1 - Cr )) == Approx(0.0).epsilon(0.0001) ); + REQUIRE( accu(abs(eigvals2 - eigvals1)) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(eigvals3 - eigvals1)) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(eigvals4 - eigvals1)) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(eigvals5 - eigvals1)) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(A1 - B )) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(A1 - Cl )) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(A1 - Cr )) == Approx(0.0).margin(0.0001) ); } @@ -129,11 +129,11 @@ TEST_CASE("decomp_eig_pair_2") cx_mat Cr = A2 * reigvecs5 * diagmat(eigvals5) * inv(reigvecs5) ; REQUIRE( status == true ); - REQUIRE( accu(abs(eigvals2 - eigvals1)) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(eigvals3 - eigvals1)) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(eigvals4 - eigvals1)) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(eigvals5 - eigvals1)) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(A1 - B )) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(A1 - Cl )) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(A1 - Cr )) == Approx(0.0).epsilon(0.0001) ); + REQUIRE( accu(abs(eigvals2 - eigvals1)) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(eigvals3 - eigvals1)) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(eigvals4 - eigvals1)) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(eigvals5 - eigvals1)) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(A1 - B )) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(A1 - Cl )) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(A1 - Cr )) == Approx(0.0).margin(0.0001) ); } diff --git a/tests2/decomp_eig_sym.cpp b/tests2/decomp_eig_sym.cpp index 4973d7a4..68cdbcbf 100644 --- a/tests2/decomp_eig_sym.cpp +++ b/tests2/decomp_eig_sym.cpp @@ -54,10 +54,10 @@ TEST_CASE("decomp_eig_sym_1") mat B = eigvecs4 * diagmat(eigvals4) * eigvecs4.t(); REQUIRE( status == true ); - REQUIRE( accu(abs(eigvals2 - eigvals1)) == Approx(0.0) ); - REQUIRE( accu(abs(eigvals3 - eigvals1)) == Approx(0.0) ); - REQUIRE( accu(abs(eigvals4 - eigvals1)) == Approx(0.0) ); - REQUIRE( accu(abs(A - B )) == Approx(0.0) ); + REQUIRE( accu(abs(eigvals2 - eigvals1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(eigvals3 - eigvals1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(eigvals4 - eigvals1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(A - B )) == Approx(0.0).margin(0.001) ); } @@ -94,10 +94,10 @@ TEST_CASE("eig_sym_2") cx_mat B = eigvecs4 * diagmat(eigvals4) * eigvecs4.t(); REQUIRE( status == true ); - REQUIRE( accu(abs(eigvals2 - eigvals1)) == Approx(0.0) ); - REQUIRE( accu(abs(eigvals3 - eigvals1)) == Approx(0.0) ); - REQUIRE( accu(abs(eigvals4 - eigvals1)) == Approx(0.0) ); - REQUIRE( accu(abs(A - B )) == Approx(0.0) ); + REQUIRE( accu(abs(eigvals2 - eigvals1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(eigvals3 - eigvals1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(eigvals4 - eigvals1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(A - B )) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/expr_elem.cpp b/tests2/expr_elem.cpp index 87d9e40c..3e830639 100644 --- a/tests2/expr_elem.cpp +++ b/tests2/expr_elem.cpp @@ -94,43 +94,43 @@ TEST_CASE("expr_elem_1") 8.34776801552685 -4.66295029528133 -4.91457244448376 -6.87237990516116 -5.65342258203116 7.73084297111757;\ "; - REQUIRE( accu(abs(( A - A ))) == Approx(0.0) ); - REQUIRE( accu(abs((2*A - 2*A ))) == Approx(0.0) ); - REQUIRE( accu(abs((2*A - (A+A)))) == Approx(0.0) ); + REQUIRE( accu(abs(( A - A ))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((2*A - 2*A ))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((2*A - (A+A)))) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((A+0) - A )) == Approx(0.0) ); - REQUIRE( accu(abs((A-0) - A )) == Approx(0.0) ); + REQUIRE( accu(abs((A+0) - A )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((A-0) - A )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((A*1) - A )) == Approx(0.0) ); - REQUIRE( accu(abs((A/1) - A )) == Approx(0.0) ); + REQUIRE( accu(abs((A*1) - A )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((A/1) - A )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((A+2) - A_plus_2)) == Approx(0.0) ); - REQUIRE( accu(abs((2+A) - A_plus_2)) == Approx(0.0) ); + REQUIRE( accu(abs((A+2) - A_plus_2)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((2+A) - A_plus_2)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((A*2) - A_times_2)) == Approx(0.0) ); - REQUIRE( accu(abs((2*A) - A_times_2)) == Approx(0.0) ); - REQUIRE( accu(abs((A+A) - A_times_2)) == Approx(0.0) ); + REQUIRE( accu(abs((A*2) - A_times_2)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((2*A) - A_times_2)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((A+A) - A_times_2)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((A+A+A - A) - A_times_2)) == Approx(0.0) ); - REQUIRE( accu(abs((3*A - A) - A_times_2)) == Approx(0.0) ); + REQUIRE( accu(abs((A+A+A - A) - A_times_2)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((3*A - A) - A_times_2)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((A/2 ) - A_div_2)) == Approx(0.0) ); - REQUIRE( accu(abs((A*0.5) - A_div_2)) == Approx(0.0) ); + REQUIRE( accu(abs((A/2 ) - A_div_2)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((A*0.5) - A_div_2)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((2/A ) - two_div_A)) == Approx(0.0) ); + REQUIRE( accu(abs((2/A ) - two_div_A)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (A % A) - A_elem_mul_A )) == Approx(0.0) ); - REQUIRE( accu(abs( (A % A) - square(A) )) == Approx(0.0) ); + REQUIRE( accu(abs( (A % A) - A_elem_mul_A )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A % A) - square(A) )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(( (2/A) % (A/2) ) - ones(size(A)))) == Approx(0.0) ); + REQUIRE( accu(abs(( (2/A) % (A/2) ) - ones(size(A)))) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(( A - A(span::all,span::all) ))) == Approx(0.0) ); + REQUIRE( accu(abs(( A - A(span::all,span::all) ))) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((A(span::all,span::all)+2) - A_plus_2)) == Approx(0.0) ); - REQUIRE( accu(abs((2+A(span::all,span::all)) - A_plus_2)) == Approx(0.0) ); + REQUIRE( accu(abs((A(span::all,span::all)+2) - A_plus_2)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((2+A(span::all,span::all)) - A_plus_2)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(((A+A+A) / (3*A)) - ones(size(A)))) == Approx(0.0) ); + REQUIRE( accu(abs(((A+A+A) / (3*A)) - ones(size(A)))) == Approx(0.0).margin(0.001) ); REQUIRE_THROWS( A + randu(A.n_rows+1, A.n_cols ) ); REQUIRE_THROWS( A + randu(A.n_rows , A.n_cols+1) ); diff --git a/tests2/expr_misc.cpp b/tests2/expr_misc.cpp index 7e03aa12..cb5b9ee3 100644 --- a/tests2/expr_misc.cpp +++ b/tests2/expr_misc.cpp @@ -47,7 +47,7 @@ TEST_CASE("expr_misc_1") 0.425855872233481 -1.159439708059395 -1.540488679549322 -0.747036381125272 -1.722286962209877;\ "; - REQUIRE( accu(abs(B - C)) == Approx(0.0) ); + REQUIRE( accu(abs(B - C)) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } diff --git a/tests2/fn_abs.cpp b/tests2/fn_abs.cpp index e3864660..c5f0a3fa 100644 --- a/tests2/fn_abs.cpp +++ b/tests2/fn_abs.cpp @@ -80,11 +80,11 @@ TEST_CASE("fn_abs_1") REQUIRE( Y(3,5) == Approx(0.373833) ); REQUIRE( Y(4,5) == Approx(0.258704) ); - REQUIRE( accu( abs(A) - abs_A ) == Approx(0.0) ); - REQUIRE( accu( 2*abs(A) - 2*abs_A ) == Approx(0.0) ); + REQUIRE( accu( abs(A) - abs_A ) == Approx(0.0).margin(0.001) ); + REQUIRE( accu( 2*abs(A) - 2*abs_A ) == Approx(0.0).margin(0.001) ); - REQUIRE( accu( abs(-A) - abs_A ) == Approx(0.0) ); - REQUIRE( accu( 2*abs(-A) - 2*abs_A ) == Approx(0.0) ); + REQUIRE( accu( abs(-A) - abs_A ) == Approx(0.0).margin(0.001) ); + REQUIRE( accu( 2*abs(-A) - 2*abs_A ) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } @@ -133,7 +133,7 @@ TEST_CASE("fn_abs_2") REQUIRE( X(3,5) == Approx(0.502876) ); REQUIRE( X(4,5) == Approx(0.352603) ); - REQUIRE( accu( abs(C) - abs_C ) == Approx(0.0) ); + REQUIRE( accu( abs(C) - abs_C ) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } @@ -160,8 +160,8 @@ TEST_CASE("fn_abs_3") vec c = abs(a); - REQUIRE( accu(c - b) == Approx(0.0) ); - REQUIRE( accu(abs(a) - b) == Approx(0.0) ); + REQUIRE( accu(c - b) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(a) - b) == Approx(0.0).margin(0.001) ); } @@ -170,8 +170,8 @@ TEST_CASE("fn_abs_4") vec a = -2*linspace(1,5,6); vec b = +2*linspace(1,5,6); - REQUIRE( accu(abs(a) - b) == Approx(0.0) ); - REQUIRE( accu(abs(a(span::all)) - b(span::all)) == Approx(0.0) ); + REQUIRE( accu(abs(a) - b) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(a(span::all)) - b(span::all)) == Approx(0.0).margin(0.001) ); } @@ -180,8 +180,8 @@ TEST_CASE("fn_abs_5") { mat A = randu(5,6); - REQUIRE( accu(abs(-2*A) - (2*A)) == Approx(0.0) ); - REQUIRE( accu(abs(-2*A(span::all,span::all)) - (2*A(span::all,span::all))) == Approx(0.0) ); + REQUIRE( accu(abs(-2*A) - (2*A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(-2*A(span::all,span::all)) - (2*A(span::all,span::all))) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_accu.cpp b/tests2/fn_accu.cpp index 219ed8e9..728de696 100644 --- a/tests2/fn_accu.cpp +++ b/tests2/fn_accu.cpp @@ -73,15 +73,15 @@ TEST_CASE("fn_accu_2") cx_mat C = cx_mat(A, 2*fliplr(A)); cx_mat D = cx_mat(2*fliplr(A), A); - REQUIRE( abs(accu(C) - cx_double(0.240136, +0.480272)) == Approx(0.0) ); + REQUIRE( abs(accu(C) - cx_double(0.240136, +0.480272)) == Approx(0.0).margin(0.001) ); - REQUIRE( abs(accu(cx_double(2,3)*C) - cx_double(-0.960544000000001, +1.680951999999999)) == Approx(0.0) ); + REQUIRE( abs(accu(cx_double(2,3)*C) - cx_double(-0.960544000000001, +1.680951999999999)) == Approx(0.0).margin(0.001) ); - REQUIRE( abs(accu(C*D.t() ) - cx_double(-0.710872588088, +3.656114082498002)) == Approx(0.0) ); - REQUIRE( abs(accu(C*D.st()) - cx_double(0.0, +6.093523470830000)) == Approx(0.0) ); + REQUIRE( abs(accu(C*D.t() ) - cx_double(-0.710872588088, +3.656114082498002)) == Approx(0.0).margin(0.001) ); + REQUIRE( abs(accu(C*D.st()) - cx_double(0.0, +6.093523470830000)) == Approx(0.0).margin(0.001) ); - REQUIRE( abs(accu(C.t() *D) - cx_double(10.341858962800, -7.756394222100000)) == Approx(0.0) ); - REQUIRE( abs(accu(C.st()*D) - cx_double(0.0, +1.29273237035e+01)) == Approx(0.0) ); + REQUIRE( abs(accu(C.t() *D) - cx_double(10.341858962800, -7.756394222100000)) == Approx(0.0).margin(0.001) ); + REQUIRE( abs(accu(C.st()*D) - cx_double(0.0, +1.29273237035e+01)) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_conj.cpp b/tests2/fn_conj.cpp index 34569926..054c73bc 100644 --- a/tests2/fn_conj.cpp +++ b/tests2/fn_conj.cpp @@ -28,8 +28,8 @@ TEST_CASE("fn_conj_1") cx_vec a = cx_vec(re,im); cx_vec b = conj(a); - REQUIRE( accu(abs(real(b) - ( re))) == Approx(0.0) ); - REQUIRE( accu(abs(imag(b) - (-im))) == Approx(0.0) ); + REQUIRE( accu(abs(real(b) - ( re))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(imag(b) - (-im))) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_conv.cpp b/tests2/fn_conv.cpp index 3a9e87dc..0269ee9f 100644 --- a/tests2/fn_conv.cpp +++ b/tests2/fn_conv.cpp @@ -42,5 +42,5 @@ TEST_CASE("fn_conv_1") 60.00000000000000 }; - REQUIRE( accu(abs(c - d)) == Approx(0.0) ); + REQUIRE( accu(abs(c - d)) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_cor.cpp b/tests2/fn_cor.cpp index 46dafe8e..709658fd 100644 --- a/tests2/fn_cor.cpp +++ b/tests2/fn_cor.cpp @@ -26,8 +26,8 @@ TEST_CASE("fn_cor_1") vec b = 0.5*linspace(1,5,6); vec c = flipud(b); - REQUIRE( as_scalar(cor(a,b) - (+1.0)) == Approx(0.0) ); - REQUIRE( as_scalar(cor(a,c) - (-1.0)) == Approx(0.0) ); + REQUIRE( as_scalar(cor(a,b) - (+1.0)) == Approx(0.0).margin(0.001) ); + REQUIRE( as_scalar(cor(a,c) - (-1.0)) == Approx(0.0).margin(0.001) ); } @@ -69,7 +69,7 @@ TEST_CASE("fn_cor_2") 1.00000 0.38630 0.45559 -0.99459;\ "; - REQUIRE( accu(abs(cor(A) - AA)) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(cor(A,B) - AA)) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs(cor(A,C) - AC)) == Approx(0.0).epsilon(0.0001) ); + REQUIRE( accu(abs(cor(A) - AA)) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(cor(A,B) - AA)) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs(cor(A,C) - AC)) == Approx(0.0).margin(0.0001) ); } diff --git a/tests2/fn_cov.cpp b/tests2/fn_cov.cpp index 07a93f34..c8fec441 100644 --- a/tests2/fn_cov.cpp +++ b/tests2/fn_cov.cpp @@ -26,8 +26,8 @@ TEST_CASE("fn_cov_1") vec b = 0.5*linspace(1,5,6); vec c = flipud(b); - REQUIRE( as_scalar(cov(a,b) - (+1.12)) == Approx(0.0) ); - REQUIRE( as_scalar(cov(a,c) - (-1.12)) == Approx(0.0) ); + REQUIRE( as_scalar(cov(a,b) - (+1.12)) == Approx(0.0).margin(0.001) ); + REQUIRE( as_scalar(cov(a,c) - (-1.12)) == Approx(0.0).margin(0.001) ); } @@ -69,7 +69,7 @@ TEST_CASE("fn_cov_2") 0.033635 0.025627 0.025320 -0.105637;\ "; - REQUIRE( accu(abs(cov(A) - AA)) == Approx(0.0) ); - REQUIRE( accu(abs(cov(A,B) - AB)) == Approx(0.0) ); - REQUIRE( accu(abs(cov(A,C) - AC)) == Approx(0.0) ); + REQUIRE( accu(abs(cov(A) - AA)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cov(A,B) - AB)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cov(A,C) - AC)) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_cross.cpp b/tests2/fn_cross.cpp index 81649b55..56828ad3 100644 --- a/tests2/fn_cross.cpp +++ b/tests2/fn_cross.cpp @@ -27,7 +27,7 @@ TEST_CASE("fn_cross_1") vec c = {-17.050, 29.150, -14.520 }; - REQUIRE( accu(abs(cross(a,b) - c)) == Approx(0.0) ); + REQUIRE( accu(abs(cross(a,b) - c)) == Approx(0.0).margin(0.001) ); vec x; diff --git a/tests2/fn_cumprod.cpp b/tests2/fn_cumprod.cpp index 9259629a..e71d8571 100644 --- a/tests2/fn_cumprod.cpp +++ b/tests2/fn_cumprod.cpp @@ -27,8 +27,8 @@ TEST_CASE("fn_cumprod_1") colvec c = { 1.0000, 1.8000, 4.6800, 15.9120, 66.8304, 334.1520 }; - REQUIRE( accu(abs(cumprod(a) - c )) == Approx(0.0) ); - REQUIRE( accu(abs(cumprod(b) - c.t())) == Approx(0.0) ); + REQUIRE( accu(abs(cumprod(a) - c )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cumprod(b) - c.t())) == Approx(0.0).margin(0.001) ); REQUIRE_THROWS( b = cumprod(a) ); } @@ -59,9 +59,9 @@ TEST_CASE("fn_cumprod_2") { 0.735730, 0.383345, -0.085344, -0.034277 } }; - REQUIRE( accu(abs(cumprod(A) - B)) == Approx(0.0) ); - REQUIRE( accu(abs(cumprod(A,0) - B)) == Approx(0.0) ); - REQUIRE( accu(abs(cumprod(A,1) - C)) == Approx(0.0) ); + REQUIRE( accu(abs(cumprod(A) - B)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cumprod(A,0) - B)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cumprod(A,1) - C)) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_cumsum.cpp b/tests2/fn_cumsum.cpp index 9389c354..013c0ef8 100644 --- a/tests2/fn_cumsum.cpp +++ b/tests2/fn_cumsum.cpp @@ -27,8 +27,8 @@ TEST_CASE("fn_cumsum_1") colvec c = { 1.0000, 2.8000, 5.4000, 8.8000, 13.0000, 18.0000 }; - REQUIRE( accu(abs(cumsum(a) - c )) == Approx(0.0) ); - REQUIRE( accu(abs(cumsum(b) - c.t())) == Approx(0.0) ); + REQUIRE( accu(abs(cumsum(a) - c )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cumsum(b) - c.t())) == Approx(0.0).margin(0.001) ); REQUIRE_THROWS( b = cumsum(a) ); } @@ -58,9 +58,9 @@ TEST_CASE("fn_cumsum_2") { 0.73573, 1.25677, 1.03414, 1.43577 } }; - REQUIRE( accu(abs(cumsum(A) - B)) == Approx(0.0) ); - REQUIRE( accu(abs(cumsum(A,0) - B)) == Approx(0.0) ); - REQUIRE( accu(abs(cumsum(A,1) - C)) == Approx(0.0) ); + REQUIRE( accu(abs(cumsum(A) - B)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cumsum(A,0) - B)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cumsum(A,1) - C)) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_diagmat.cpp b/tests2/fn_diagmat.cpp index 4d07afe6..d28d9a44 100644 --- a/tests2/fn_diagmat.cpp +++ b/tests2/fn_diagmat.cpp @@ -77,11 +77,11 @@ TEST_CASE("fn_diagmat_2") mat Amain(size(A),fill::zeros); Amain.diag( ) = dmain; mat Am1 (size(A),fill::zeros); Am1.diag(-1) = dm1; - REQUIRE( accu(abs(diagmat(A ) - Amain)) == Approx(0.0) ); - REQUIRE( accu(abs(diagmat(A, 0) - Amain)) == Approx(0.0) ); + REQUIRE( accu(abs(diagmat(A ) - Amain)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diagmat(A, 0) - Amain)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(diagmat(A, 1) - Ap1)) == Approx(0.0) ); - REQUIRE( accu(abs(diagmat(A,-1) - Am1)) == Approx(0.0) ); + REQUIRE( accu(abs(diagmat(A, 1) - Ap1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diagmat(A,-1) - Am1)) == Approx(0.0).margin(0.001) ); } @@ -129,13 +129,13 @@ TEST_CASE("fn_diagmat_3") -0.109213 0.011096 -0.057961;\ "; - REQUIRE( accu(abs((diagmat(Asub) * diagmat(Bsub)) - Asubdiagmat_times_Bsubdiagmat)) == Approx(0.0) ); + REQUIRE( accu(abs((diagmat(Asub) * diagmat(Bsub)) - Asubdiagmat_times_Bsubdiagmat)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((Bsub * diagmat(A)) - Bsub_times_Adiagmat)) == Approx(0.0) ); - REQUIRE( accu(abs((B(span::all, span(0,2)) * diagmat(A)) - Bsub_times_Adiagmat)) == Approx(0.0) ); + REQUIRE( accu(abs((Bsub * diagmat(A)) - Bsub_times_Adiagmat)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((B(span::all, span(0,2)) * diagmat(A)) - Bsub_times_Adiagmat)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((diagmat(A) * Bt ) - Adiagmat_times_Bt )) == Approx(0.0) ); - REQUIRE( accu(abs((diagmat(A) * B.t() ) - Adiagmat_times_Bt )) == Approx(0.0) ); + REQUIRE( accu(abs((diagmat(A) * Bt ) - Adiagmat_times_Bt )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((diagmat(A) * B.t() ) - Adiagmat_times_Bt )) == Approx(0.0).margin(0.001) ); // TODO: Asub and At } diff --git a/tests2/fn_diagvec.cpp b/tests2/fn_diagvec.cpp index dfd3f0f9..17ab5f32 100644 --- a/tests2/fn_diagvec.cpp +++ b/tests2/fn_diagvec.cpp @@ -62,9 +62,9 @@ TEST_CASE("fn_diagvec_1") -0.291020 }; - REQUIRE( accu(abs(A_main1 - a)) == Approx(0.0) ); - REQUIRE( accu(abs(A_main2 - a)) == Approx(0.0) ); + REQUIRE( accu(abs(A_main1 - a)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(A_main2 - a)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(A_p1 - b)) == Approx(0.0) ); - REQUIRE( accu(abs(A_m1 - c)) == Approx(0.0) ); + REQUIRE( accu(abs(A_p1 - b)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(A_m1 - c)) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_diff.cpp b/tests2/fn_diff.cpp index 9d05a9d1..03ab4b85 100644 --- a/tests2/fn_diff.cpp +++ b/tests2/fn_diff.cpp @@ -33,17 +33,17 @@ TEST_CASE("fn_diff_1") rowvec b_diff_2 = { 2, 2, 2 }; rowvec b_diff_9; - REQUIRE( accu(abs(diff(a,0) - a )) == Approx(0.0) ); - REQUIRE( accu(abs(diff(a ) - a_diff_1)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(a,1) - a_diff_1)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(a,2) - a_diff_2)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(a,9) - a_diff_9)) == Approx(0.0) ); + REQUIRE( accu(abs(diff(a,0) - a )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(a ) - a_diff_1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(a,1) - a_diff_1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(a,2) - a_diff_2)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(a,9) - a_diff_9)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(diff(b,0) - b )) == Approx(0.0) ); - REQUIRE( accu(abs(diff(b ) - b_diff_1)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(b,1) - b_diff_1)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(b,2) - b_diff_2)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(b,9) - b_diff_9)) == Approx(0.0) ); + REQUIRE( accu(abs(diff(b,0) - b )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(b ) - b_diff_1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(b,1) - b_diff_1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(b,2) - b_diff_2)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(b,9) - b_diff_9)) == Approx(0.0).margin(0.001) ); } @@ -107,19 +107,19 @@ TEST_CASE("fn_diff_2") -0.5964850 -0.2726540;\ "; - REQUIRE( accu(abs(diff(A,0) - A )) == Approx(0.0) ); - REQUIRE( accu(abs(diff(A ) - A_diff1_0)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(A,1) - A_diff1_0)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(A,2) - A_diff2_0)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(A,3) - A_diff3_0)) == Approx(0.0) ); + REQUIRE( accu(abs(diff(A,0) - A )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(A ) - A_diff1_0)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(A,1) - A_diff1_0)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(A,2) - A_diff2_0)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(A,3) - A_diff3_0)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(diff(A,0,0) - A )) == Approx(0.0) ); - REQUIRE( accu(abs(diff(A,1,0) - A_diff1_0)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(A,2,0) - A_diff2_0)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(A,3,0) - A_diff3_0)) == Approx(0.0) ); + REQUIRE( accu(abs(diff(A,0,0) - A )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(A,1,0) - A_diff1_0)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(A,2,0) - A_diff2_0)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(A,3,0) - A_diff3_0)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(diff(A,0,1) - A )) == Approx(0.0) ); - REQUIRE( accu(abs(diff(A,1,1) - A_diff1_1)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(A,2,1) - A_diff2_1)) == Approx(0.0) ); - REQUIRE( accu(abs(diff(A,3,1) - A_diff3_1)) == Approx(0.0) ); + REQUIRE( accu(abs(diff(A,0,1) - A )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(A,1,1) - A_diff1_1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(A,2,1) - A_diff2_1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(diff(A,3,1) - A_diff3_1)) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_dot.cpp b/tests2/fn_dot.cpp index ed6705bd..11ac271a 100644 --- a/tests2/fn_dot.cpp +++ b/tests2/fn_dot.cpp @@ -66,11 +66,11 @@ TEST_CASE("fn_dot_2") cx_rowvec c = cx_rowvec(A.row(0), A.row(1)); cx_rowvec d = cx_rowvec(A.row(2), A.row(3)); - REQUIRE( abs( dot(a,b) - cx_double(-0.009544718641000, -0.110209641379000)) == Approx(0.0) ); - REQUIRE( abs( dot(c,d) - cx_double(-0.326993347830000, +0.061084261990000)) == Approx(0.0) ); + REQUIRE( abs( dot(a,b) - cx_double(-0.009544718641000, -0.110209641379000)) == Approx(0.0).margin(0.001) ); + REQUIRE( abs( dot(c,d) - cx_double(-0.326993347830000, +0.061084261990000)) == Approx(0.0).margin(0.001) ); - REQUIRE( abs(cdot(a,b) - cx_double(-0.314669805873000, -0.807333974477000)) == Approx(0.0) ); - REQUIRE( abs(cdot(c,d) - cx_double(-0.165527940664000, +0.586984291846000)) == Approx(0.0) ); + REQUIRE( abs(cdot(a,b) - cx_double(-0.314669805873000, -0.807333974477000)) == Approx(0.0).margin(0.001) ); + REQUIRE( abs(cdot(c,d) - cx_double(-0.165527940664000, +0.586984291846000)) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_eigs_gen.cpp b/tests2/fn_eigs_gen.cpp index 2c003b55..10edec2a 100644 --- a/tests2/fn_eigs_gen.cpp +++ b/tests2/fn_eigs_gen.cpp @@ -65,10 +65,10 @@ TEST_CASE("fn_eigs_gen_odd_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.1) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.1) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.1) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.1) ); } } } @@ -127,10 +127,10 @@ TEST_CASE("fn_eigs_gen_even_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -190,10 +190,10 @@ TEST_CASE("fn_eigs_gen_even_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -254,10 +254,10 @@ TEST_CASE("fn_eigs_gen_odd_sigma_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.1) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.1) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.1) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.1) ); } } } @@ -318,10 +318,10 @@ TEST_CASE("fn_eigs_gen_even_sigma_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -383,10 +383,10 @@ TEST_CASE("fn_eigs_gen_even_sigma_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -446,10 +446,10 @@ TEST_CASE("fn_eigs_gen_odd_sm_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.1) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.1) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.1) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.1) ); } } } @@ -509,10 +509,10 @@ TEST_CASE("fn_eigs_gen_even_sm_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -573,10 +573,10 @@ TEST_CASE("fn_eigs_gen_even_sm_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -636,10 +636,10 @@ TEST_CASE("fn_eigs_gen_odd_float_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.001) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.001) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -699,10 +699,10 @@ TEST_CASE("fn_eigs_gen_even_float_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -763,10 +763,10 @@ TEST_CASE("fn_eigs_gen_even_float_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -828,10 +828,10 @@ TEST_CASE("fn_eigs_gen_odd_float_sigma_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.001) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.001) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -893,10 +893,10 @@ TEST_CASE("fn_eigs_gen_even_float_sigma_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -959,10 +959,10 @@ TEST_CASE("fn_eigs_gen_even_float_sigma_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1023,10 +1023,10 @@ TEST_CASE("fn_eigs_gen_odd_float_sm_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.001) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.001) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1087,10 +1087,10 @@ TEST_CASE("fn_eigs_gen_even_float_sm_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1152,10 +1152,10 @@ TEST_CASE("fn_eigs_gen_even_float_sm_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1211,10 +1211,10 @@ TEST_CASE("fn_eigs_gen_odd_complex_float_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1270,10 +1270,10 @@ TEST_CASE("fn_eigs_gen_even_complex_float_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1330,10 +1330,10 @@ TEST_CASE("fn_eigs_gen_even_complex_float_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1394,10 +1394,10 @@ TEST_CASE("fn_eigs_gen_odd_complex_float_sigma_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1458,10 +1458,10 @@ TEST_CASE("fn_eigs_gen_even_complex_float_sigma_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1523,10 +1523,10 @@ TEST_CASE("fn_eigs_gen_even_complex_float_sigma_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1586,10 +1586,10 @@ TEST_CASE("fn_eigs_gen_odd_complex_float_sm_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1649,10 +1649,10 @@ TEST_CASE("fn_eigs_gen_even_complex_float_sm_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1713,10 +1713,10 @@ TEST_CASE("fn_eigs_gen_even_complex_float_sm_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1772,10 +1772,10 @@ TEST_CASE("eigs_gen_odd_complex_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(size_t j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1831,10 +1831,10 @@ TEST_CASE("fn_eigs_gen_even_complex_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1891,10 +1891,10 @@ TEST_CASE("fn_eigs_gen_even_complex_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -1955,10 +1955,10 @@ TEST_CASE("eigs_gen_odd_complex_sigma_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(size_t j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -2019,10 +2019,10 @@ TEST_CASE("fn_eigs_gen_even_complex_sigma_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -2084,10 +2084,10 @@ TEST_CASE("fn_eigs_gen_even_complex_sigma_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -2144,10 +2144,10 @@ TEST_CASE("eigs_gen_odd_complex_sm_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(size_t j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -2204,10 +2204,10 @@ TEST_CASE("fn_eigs_gen_even_complex_sm_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } @@ -2265,10 +2265,10 @@ TEST_CASE("fn_eigs_gen_even_complex_sm_opts_test") REQUIRE( dense_eval != n_rows + 1 ); - REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigval(i)) == Approx(std::abs(eigval(dense_eval))).margin(0.01) ); for(uword j = 0; j < n_rows; ++j) { - REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).epsilon(0.01) ); + REQUIRE( std::abs(sp_eigvec(j, i)) == Approx(std::abs(eigvec(j, dense_eval))).margin(0.01) ); } } } diff --git a/tests2/fn_eigs_sym.cpp b/tests2/fn_eigs_sym.cpp index 3e993d34..9c300c7b 100644 --- a/tests2/fn_eigs_sym.cpp +++ b/tests2/fn_eigs_sym.cpp @@ -47,12 +47,12 @@ TEST_CASE("fn_eigs_test") for (uword i = 0; i < 5; ++i) { // It may be pointed the wrong direction. - REQUIRE( sp_eigval(i) == Approx(eigval(i + 995)).epsilon(0.01) ); + REQUIRE( sp_eigval(i) == Approx(eigval(i + 995)).margin(0.01) ); for (uword j = 0; j < 1000; ++j) { REQUIRE( std::abs(sp_eigvec(j, i)) == - Approx(std::abs(eigvec(j, i + 995))).epsilon(0.01) ); + Approx(std::abs(eigvec(j, i + 995))).margin(0.01) ); } } } @@ -88,12 +88,12 @@ TEST_CASE("fn_eigs_float_test") for (uword i = 0; i < 5; ++i) { // It may be pointed the wrong direction. - REQUIRE( sp_eigval(i) == Approx(eigval(i + 95)).epsilon(0.01) ); + REQUIRE( sp_eigval(i) == Approx(eigval(i + 95)).margin(0.01) ); for (uword j = 0; j < 100; ++j) { REQUIRE(std::abs(sp_eigvec(j, i)) == - Approx(std::abs(eigvec(j, i + 95))).epsilon(0.01) ); + Approx(std::abs(eigvec(j, i + 95))).margin(0.01) ); } } } @@ -126,12 +126,12 @@ TEST_CASE("fn_eigs_sm_test") for (size_t i = 0; i < 5; ++i) { // It may be pointed the wrong direction. - REQUIRE( sp_eigval(i) == Approx(eigval(i)).epsilon(0.01) ); + REQUIRE( sp_eigval(i) == Approx(eigval(i)).margin(0.01) ); for (size_t j = 0; j < 100; ++j) { REQUIRE( std::abs(sp_eigvec(j, i)) == - Approx(std::abs(eigvec(j, i))).epsilon(0.01) ); + Approx(std::abs(eigvec(j, i))).margin(0.01) ); } } } @@ -170,12 +170,12 @@ TEST_CASE("fn_eigs_sigma_test") for(uword i = 0; i < 5; ++i) { // It may be pointed the wrong direction. - REQUIRE( sp_eigval(i) == Approx(eigval(i)).epsilon(0.01) ); + REQUIRE( sp_eigval(i) == Approx(eigval(i)).margin(0.01) ); for (size_t j = 0; j < 100; ++j) { REQUIRE( std::abs(sp_eigvec(j, i)) == - Approx(std::abs(eigvec(j, i))).epsilon(0.01) ); + Approx(std::abs(eigvec(j, i))).margin(0.01) ); } } } diff --git a/tests2/fn_eps.cpp b/tests2/fn_eps.cpp index 6ac24d51..38e2e265 100644 --- a/tests2/fn_eps.cpp +++ b/tests2/fn_eps.cpp @@ -43,5 +43,5 @@ TEST_CASE("fn_eps_1") 2.77555756156289e-17 5.55111512312578e-17 5.55111512312578e-17 5.55111512312578e-17 5.55111512312578e-17;\ "; - REQUIRE( accu(abs(eps(A) - B)) == Approx(0.0) ); + REQUIRE( accu(abs(eps(A) - B)) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_expmat.cpp b/tests2/fn_expmat.cpp index a82d9dfb..9938425c 100644 --- a/tests2/fn_expmat.cpp +++ b/tests2/fn_expmat.cpp @@ -40,7 +40,7 @@ TEST_CASE("fn_expmat_1") 0.16726671762680370 -0.40082334719624046 -0.43832065342010318 -0.30675328534305307 0.64261934864584291;\ "; - REQUIRE( accu(abs(expmat(A) - B)) == Approx(0.0) ); + REQUIRE( accu(abs(expmat(A) - B)) == Approx(0.0).margin(0.001) ); mat X; diff --git a/tests2/fn_find.cpp b/tests2/fn_find.cpp index 89737188..4507ebc1 100644 --- a/tests2/fn_find.cpp +++ b/tests2/fn_find.cpp @@ -45,17 +45,17 @@ TEST_CASE("fn_find_1") uvec indices_lessthan_neg04 = { 2, 9, 14, 15, 27 }; - REQUIRE( accu(abs( conv_to::from(find(A )) - conv_to::from(indices_nonzero ) )) == Approx(0.0) ); + REQUIRE( accu(abs( conv_to::from(find(A )) - conv_to::from(indices_nonzero ) )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( conv_to::from(find(A == 0.0)) - conv_to::from(indices_zero ) )) == Approx(0.0) ); + REQUIRE( accu(abs( conv_to::from(find(A == 0.0)) - conv_to::from(indices_zero ) )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( conv_to::from(find(A > 0.0)) - conv_to::from(indices_greaterthan_00) )) == Approx(0.0) ); + REQUIRE( accu(abs( conv_to::from(find(A > 0.0)) - conv_to::from(indices_greaterthan_00) )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( conv_to::from(find(A < 0.0)) - conv_to::from(indices_lessthan_00 ) )) == Approx(0.0) ); + REQUIRE( accu(abs( conv_to::from(find(A < 0.0)) - conv_to::from(indices_lessthan_00 ) )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( conv_to::from(find(A > 0.4)) - conv_to::from(indices_greaterthan_04) )) == Approx(0.0) ); + REQUIRE( accu(abs( conv_to::from(find(A > 0.4)) - conv_to::from(indices_greaterthan_04) )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( conv_to::from(find(A < -0.4)) - conv_to::from(indices_lessthan_neg04) )) == Approx(0.0) ); + REQUIRE( accu(abs( conv_to::from(find(A < -0.4)) - conv_to::from(indices_lessthan_neg04) )) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } diff --git a/tests2/fn_find_unique.cpp b/tests2/fn_find_unique.cpp index f528eef5..40f7c2ab 100644 --- a/tests2/fn_find_unique.cpp +++ b/tests2/fn_find_unique.cpp @@ -46,7 +46,7 @@ TEST_CASE("fn_find_unique_1") vec unique_elem = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - REQUIRE( accu(abs( A.elem(indices) - unique_elem )) == Approx(0.0) ); + REQUIRE( accu(abs( A.elem(indices) - unique_elem )) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } @@ -92,7 +92,7 @@ TEST_CASE("fn_find_unique_2") cx_double(9,-9) }; - REQUIRE( accu(abs( A.elem(indices) - unique_elem )) == Approx(0.0) ); + REQUIRE( accu(abs( A.elem(indices) - unique_elem )) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } diff --git a/tests2/fn_flip.cpp b/tests2/fn_flip.cpp index bdbc4400..b63a7a01 100644 --- a/tests2/fn_flip.cpp +++ b/tests2/fn_flip.cpp @@ -68,20 +68,20 @@ TEST_CASE("fn_flip_1") 0.122396 0.403980 0.039356 -0.987872 -0.253490 0.102816;\ "; - REQUIRE( accu(abs( fliplr(A) - A_fliplr )) == Approx(0.0) ); - REQUIRE( accu(abs( flipud(A) - A_flipud )) == Approx(0.0) ); + REQUIRE( accu(abs( fliplr(A) - A_fliplr )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( flipud(A) - A_flipud )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (-fliplr(A)) + A_fliplr )) == Approx(0.0) ); - REQUIRE( accu(abs( (-flipud(A)) + A_flipud )) == Approx(0.0) ); + REQUIRE( accu(abs( (-fliplr(A)) + A_fliplr )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (-flipud(A)) + A_flipud )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( fliplr(-A) + A_fliplr )) == Approx(0.0) ); - REQUIRE( accu(abs( flipud(-A) + A_flipud )) == Approx(0.0) ); + REQUIRE( accu(abs( fliplr(-A) + A_fliplr )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( flipud(-A) + A_flipud )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*fliplr(A) - two_times_A_fliplr )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*flipud(A) - two_times_A_flipud )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*fliplr(A) - two_times_A_fliplr )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*flipud(A) - two_times_A_flipud )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( fliplr(2*A) - two_times_A_fliplr )) == Approx(0.0) ); - REQUIRE( accu(abs( flipud(2*A) - two_times_A_flipud )) == Approx(0.0) ); + REQUIRE( accu(abs( fliplr(2*A) - two_times_A_fliplr )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( flipud(2*A) - two_times_A_flipud )) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } diff --git a/tests2/fn_hess.cpp b/tests2/fn_hess.cpp index ddabbafe..2c6498d7 100644 --- a/tests2/fn_hess.cpp +++ b/tests2/fn_hess.cpp @@ -83,8 +83,8 @@ TEST_CASE("fn_hess_2") hess(H2, A); REQUIRE( U(0, 0) == Approx(1.0) ); - REQUIRE( U(0, 1) == Approx(0.0) ); - REQUIRE( U(1, 0) == Approx(0.0) ); + REQUIRE( U(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( U(1, 0) == Approx(0.0).margin(0.001) ); REQUIRE( U(1, 1) == Approx(1.0) ); REQUIRE( H(0, 0) == Approx(0.061198) ); @@ -120,8 +120,8 @@ TEST_CASE("fn_hess_3") hess(H2, A); REQUIRE( U(0, 0) == Approx(1.0) ); - REQUIRE( U(0, 1) == Approx(0.0) ); - REQUIRE( U(0, 2) == Approx(0.0) ); + REQUIRE( U(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 2) == Approx(0.0).margin(0.001) ); REQUIRE( U(1, 0) == Approx( 0.0) ); REQUIRE( U(1, 1) == Approx(-0.663928864062532) ); @@ -190,9 +190,9 @@ TEST_CASE("fn_hess_4") hess(H2, A); REQUIRE( U(0, 0) == Approx(1.0) ); - REQUIRE( U(0, 1) == Approx(0.0) ); - REQUIRE( U(0, 2) == Approx(0.0) ); - REQUIRE( U(0, 3) == Approx(0.0) ); + REQUIRE( U(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 3) == Approx(0.0).margin(0.001) ); REQUIRE( U(1, 0) == Approx( 0.0) ); REQUIRE( U(1, 1) == Approx(-0.591275924818639) ); @@ -306,7 +306,7 @@ TEST_CASE("fn_hess_cx_1") hess(H2, A); REQUIRE( U(0, 0).real() == Approx(1.0) ); - REQUIRE( U(0, 0).imag() == Approx(0.0) ); + REQUIRE( U(0, 0).imag() == Approx(0.0).margin(0.001) ); REQUIRE( H(0, 0).real() == Approx(0.061198) ); REQUIRE( H(0, 0).imag() == Approx(1.012234) ); @@ -335,13 +335,13 @@ TEST_CASE("fn_hess_cx_2") hess(H2, A); REQUIRE( U(0, 0).real() == Approx(1.0) ); - REQUIRE( U(0, 0).imag() == Approx(0.0) ); - REQUIRE( U(0, 1).real() == Approx(0.0) ); - REQUIRE( U(0, 1).imag() == Approx(0.0) ); - REQUIRE( U(1, 0).real() == Approx(0.0) ); - REQUIRE( U(1, 0).imag() == Approx(0.0) ); + REQUIRE( U(0, 0).imag() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 1).real() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 1).imag() == Approx(0.0).margin(0.001) ); + REQUIRE( U(1, 0).real() == Approx(0.0).margin(0.001) ); + REQUIRE( U(1, 0).imag() == Approx(0.0).margin(0.001) ); REQUIRE( U(1, 1).real() == Approx(1.0) ); - REQUIRE( U(1, 1).imag() == Approx(0.0) ); + REQUIRE( U(1, 1).imag() == Approx(0.0).margin(0.001) ); REQUIRE( H(0, 0).real() == Approx( 0.061198000000000) ); REQUIRE( H(0, 0).imag() == Approx( 0.092063706784000) ); @@ -389,11 +389,11 @@ TEST_CASE("fn_hess_cx_3") hess(H2, A); REQUIRE( U(0, 0).real() == Approx(1.0) ); - REQUIRE( U(0, 0).imag() == Approx(0.0) ); - REQUIRE( U(0, 1).real() == Approx(0.0) ); - REQUIRE( U(0, 1).imag() == Approx(0.0) ); - REQUIRE( U(0, 2).real() == Approx(0.0) ); - REQUIRE( U(0, 2).imag() == Approx(0.0) ); + REQUIRE( U(0, 0).imag() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 1).real() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 1).imag() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 2).real() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 2).imag() == Approx(0.0).margin(0.001) ); REQUIRE( U(1, 0).real() == Approx( 0.0) ); REQUIRE( U(1, 0).imag() == Approx( 0.0) ); @@ -496,13 +496,13 @@ TEST_CASE("fn_hess_cx_4") hess(H2, A*A); REQUIRE( U(0, 0).real() == Approx(1.0) ); - REQUIRE( U(0, 0).imag() == Approx(0.0) ); - REQUIRE( U(0, 1).real() == Approx(0.0) ); - REQUIRE( U(0, 1).imag() == Approx(0.0) ); - REQUIRE( U(0, 2).real() == Approx(0.0) ); - REQUIRE( U(0, 2).imag() == Approx(0.0) ); - REQUIRE( U(0, 3).real() == Approx(0.0) ); - REQUIRE( U(0, 3).imag() == Approx(0.0) ); + REQUIRE( U(0, 0).imag() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 1).real() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 1).imag() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 2).real() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 2).imag() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 3).real() == Approx(0.0).margin(0.001) ); + REQUIRE( U(0, 3).imag() == Approx(0.0).margin(0.001) ); REQUIRE( U(1, 0).real() == Approx( 0.0) ); REQUIRE( U(1, 0).imag() == Approx( 0.0) ); diff --git a/tests2/fn_interp1.cpp b/tests2/fn_interp1.cpp index b9ff42e7..89d9f6b5 100644 --- a/tests2/fn_interp1.cpp +++ b/tests2/fn_interp1.cpp @@ -46,8 +46,8 @@ TEST_CASE("fn_interp1_1") vec yi_a_gt = { 0.419733, 0.241248, 0.149666, 0.058084, 0.057588, 0.152062, -0.284524, -0.307613, -0.336627, 0.373833 }; vec yi_b_gt = { 0.373833, -0.300357, -0.353940, -0.201854, -0.449865, 0.063571, 0.045817, 0.085559, 0.167982, 0.250406, 0.419733 }; - REQUIRE( accu(abs( yi_a - yi_a_gt )) == Approx(0.0) ); - REQUIRE( accu(abs( yi_b - yi_b_gt )) == Approx(0.0) ); + REQUIRE( accu(abs( yi_a - yi_a_gt )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( yi_b - yi_b_gt )) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } diff --git a/tests2/fn_mean.cpp b/tests2/fn_mean.cpp index 0921144b..16cbe8b3 100644 --- a/tests2/fn_mean.cpp +++ b/tests2/fn_mean.cpp @@ -34,7 +34,7 @@ TEST_CASE("fn_mean_spmat_empty_test") REQUIRE( result2.n_cols == 1 ); double r = mean(mean(m)); - REQUIRE( r == Approx(0.0) ); + REQUIRE( r == Approx(0.0).margin(0.001) ); // Now the same with subviews. result = mean(m.submat(2, 2, 11, 16)); @@ -48,7 +48,7 @@ TEST_CASE("fn_mean_spmat_empty_test") REQUIRE( result2.n_cols == 1 ); r = mean(mean(m.submat(2, 2, 11, 16))); - REQUIRE( r == Approx(0.0) ); + REQUIRE( r == Approx(0.0).margin(0.001) ); // And with an operation. result = mean(trans(m)); @@ -62,7 +62,7 @@ TEST_CASE("fn_mean_spmat_empty_test") REQUIRE( result2.n_cols == 1 ); r = mean(mean(trans(m))); - REQUIRE( r == Approx(0.0) ); + REQUIRE( r == Approx(0.0).margin(0.001) ); } @@ -85,8 +85,8 @@ TEST_CASE("fn_mean_spcxmat_empty_test") std::complex r = mean(mean(m)); - REQUIRE( real(r) == Approx(0.0) ); - REQUIRE( imag(r) == Approx(0.0) ); + REQUIRE( real(r) == Approx(0.0).margin(0.001) ); + REQUIRE( imag(r) == Approx(0.0).margin(0.001) ); // Now the same with subviews. result = mean(m.submat(2, 2, 11, 16)); @@ -100,8 +100,8 @@ TEST_CASE("fn_mean_spcxmat_empty_test") REQUIRE( result2.n_cols == 1 ); r = mean(mean(m.submat(2, 2, 11, 16))); - REQUIRE( real(r) == Approx(0.0) ); - REQUIRE( imag(r) == Approx(0.0) ); + REQUIRE( real(r) == Approx(0.0).margin(0.001) ); + REQUIRE( imag(r) == Approx(0.0).margin(0.001) ); // And with an operation. result = mean(trans(m)); @@ -115,8 +115,8 @@ TEST_CASE("fn_mean_spcxmat_empty_test") REQUIRE( result2.n_cols == 1 ); r = mean(mean(trans(m))); - REQUIRE( real(r) == Approx(0.0) ); - REQUIRE( imag(r) == Approx(0.0) ); + REQUIRE( real(r) == Approx(0.0).margin(0.001) ); + REQUIRE( imag(r) == Approx(0.0).margin(0.001) ); } @@ -366,18 +366,18 @@ TEST_CASE("fn_mean_sp_vector_test") SpCol cr = mean(c, 0); REQUIRE( cr.n_rows == 1 ); REQUIRE( cr.n_cols == 1 ); - REQUIRE( (double) cr[0] == Approx(0.0) ); + REQUIRE( (double) cr[0] == Approx(0.0).margin(0.001) ); cr = mean(c, 1); REQUIRE( cr.n_rows == 1000 ); REQUIRE( cr.n_cols == 1 ); for (uword i = 0; i < 1000; ++i) { - REQUIRE( (double) cr[i] == Approx(0.0) ); + REQUIRE( (double) cr[i] == Approx(0.0).margin(0.001) ); } double ddcr = mean(c); - REQUIRE( ddcr == Approx(0.0) ); + REQUIRE( ddcr == Approx(0.0).margin(0.001) ); c.sprandu(1000, 1, 0.3); vec dc(c); @@ -441,21 +441,21 @@ TEST_CASE("fn_mean_sp_cx_vector_test") SpCol > cr = mean(c, 0); REQUIRE( cr.n_rows == 1 ); REQUIRE( cr.n_cols == 1 ); - REQUIRE( real((std::complex) cr[0]) == Approx(0.0) ); - REQUIRE( imag((std::complex) cr[0]) == Approx(0.0) ); + REQUIRE( real((std::complex) cr[0]) == Approx(0.0).margin(0.001) ); + REQUIRE( imag((std::complex) cr[0]) == Approx(0.0).margin(0.001) ); cr = mean(c, 1); REQUIRE( cr.n_rows == 1000 ); REQUIRE( cr.n_cols == 1 ); for (uword i = 0; i < 1000; ++i) { - REQUIRE( real((std::complex) cr[i]) == Approx(0.0) ); - REQUIRE( imag((std::complex) cr[i]) == Approx(0.0) ); + REQUIRE( real((std::complex) cr[i]) == Approx(0.0).margin(0.001) ); + REQUIRE( imag((std::complex) cr[i]) == Approx(0.0).margin(0.001) ); } std::complex ddcr = mean(c); - REQUIRE( real(ddcr) == Approx(0.0) ); - REQUIRE( imag(ddcr) == Approx(0.0) ); + REQUIRE( real(ddcr) == Approx(0.0).margin(0.001) ); + REQUIRE( imag(ddcr) == Approx(0.0).margin(0.001) ); c.sprandu(1000, 1, 0.3); cx_vec dc(c); diff --git a/tests2/fn_princomp.cpp b/tests2/fn_princomp.cpp index e9513807..c06a1415 100644 --- a/tests2/fn_princomp.cpp +++ b/tests2/fn_princomp.cpp @@ -136,15 +136,15 @@ TEST_CASE("fn_princomp_6") mat m(5, 20); initMatrix(m); mat coeff = princomp(m); - REQUIRE(std::abs(coeff(0,0)) == Approx(2.4288979933e-01)); - REQUIRE(std::abs(coeff(0,1)) == Approx(3.9409505019e-16)); - REQUIRE(std::abs(coeff(0,2)) == Approx(1.2516285718e-02)); - REQUIRE(std::abs(coeff(1,0)) == Approx(2.4288979933e-01)); - REQUIRE(std::abs(coeff(1,1)) == Approx(2.9190770799e-16)); - REQUIRE(std::abs(coeff(1,2)) == Approx(1.2516285718e-02)); - REQUIRE(std::abs(coeff(2,0)) == Approx(2.4288979933e-01)); - REQUIRE(std::abs(coeff(2,1)) == Approx(3.4719806003e-17)); - REQUIRE(std::abs(coeff(2,2)) == Approx(1.2516285718e-02)); - REQUIRE(std::abs(coeff(19,19)) == Approx(9.5528446175e-01).epsilon(0.01)); + REQUIRE(std::abs(coeff(0,0)) == Approx(2.4288979933e-01).margin(0.001)); + REQUIRE(std::abs(coeff(0,1)) == Approx(3.9409505019e-16).margin(0.001)); + REQUIRE(std::abs(coeff(0,2)) == Approx(1.2516285718e-02).margin(0.001)); + REQUIRE(std::abs(coeff(1,0)) == Approx(2.4288979933e-01).margin(0.001)); + REQUIRE(std::abs(coeff(1,1)) == Approx(2.9190770799e-16).margin(0.001)); + REQUIRE(std::abs(coeff(1,2)) == Approx(1.2516285718e-02).margin(0.001)); + REQUIRE(std::abs(coeff(2,0)) == Approx(2.4288979933e-01).margin(0.001)); + REQUIRE(std::abs(coeff(2,1)) == Approx(3.4719806003e-17).margin(0.001)); + REQUIRE(std::abs(coeff(2,2)) == Approx(1.2516285718e-02).margin(0.001)); + REQUIRE(std::abs(coeff(19,19)) == Approx(9.5528446175e-01).margin(0.001)); } diff --git a/tests2/fn_spsolve.cpp b/tests2/fn_spsolve.cpp index 16c981b3..a842e412 100644 --- a/tests2/fn_spsolve.cpp +++ b/tests2/fn_spsolve.cpp @@ -54,7 +54,7 @@ TEST_CASE("fn_spsolve_sparse_test") { for (uword j = 0; j < dX.n_rows; ++j) { - REQUIRE( (double) X(j, i) == Approx((double) dX(j, i)).epsilon(0.01) ); + REQUIRE( (double) X(j, i) == Approx((double) dX(j, i)).margin(0.01) ); } } } @@ -94,7 +94,7 @@ TEST_CASE("fn_spsolve_sparse_nonsymmetric_test") { for (uword j = 0; j < dX.n_rows; ++j) { - REQUIRE( (double) X(j, i) == Approx((double) dX(j, i)).epsilon(0.01) ); + REQUIRE( (double) X(j, i) == Approx((double) dX(j, i)).margin(0.01) ); } } } @@ -135,7 +135,7 @@ TEST_CASE("fn_spsolve_sparse_float_test") { for (size_t j = 0; j < dX.n_rows; ++j) { - REQUIRE( (float) X(j, i) == Approx((float) dX(j, i)).epsilon(0.01) ); + REQUIRE( (float) X(j, i) == Approx((float) dX(j, i)).margin(0.01) ); } } } @@ -175,7 +175,7 @@ TEST_CASE("fn_spsolve_sparse_nonsymmetric_float_test") { for (uword j = 0; j < dX.n_rows; ++j) { - REQUIRE( (float) X(j, i) == Approx((float) dX(j, i)).epsilon(0.01) ); + REQUIRE( (float) X(j, i) == Approx((float) dX(j, i)).margin(0.01) ); } } } @@ -217,7 +217,7 @@ TEST_CASE("fn_spsolve_sparse_complex_float_test") for (uword j = 0; j < dX.n_rows; ++j) { REQUIRE( (float) std::abs((cx_float) X(j, i)) == - Approx((float) std::abs((cx_float) dX(j, i))).epsilon(0.01) ); + Approx((float) std::abs((cx_float) dX(j, i))).margin(0.01) ); } } } @@ -258,7 +258,7 @@ TEST_CASE("fn_spsolve_sparse_nonsymmetric_complex_float_test") for (uword j = 0; j < dX.n_rows; ++j) { REQUIRE( (float) std::abs((cx_float) X(j, i)) == - Approx((float) std::abs((cx_float) dX(j, i))).epsilon(0.01) ); + Approx((float) std::abs((cx_float) dX(j, i))).margin(0.01) ); } } } @@ -300,7 +300,7 @@ TEST_CASE("fn_spsolve_sparse_complex_test") for (uword j = 0; j < dX.n_rows; ++j) { REQUIRE( (double) std::abs((cx_double) X(j, i)) == - Approx((double) std::abs((cx_double) dX(j, i))).epsilon(0.01) ); + Approx((double) std::abs((cx_double) dX(j, i))).margin(0.01) ); } } } @@ -341,7 +341,7 @@ TEST_CASE("fn_spsolve_sparse_nonsymmetric_complex_test") for (uword j = 0; j < dX.n_rows; ++j) { REQUIRE( (double) std::abs((cx_double) X(j, i)) == - Approx((double) std::abs((cx_double) dX(j, i))).epsilon(0.01) ); + Approx((double) std::abs((cx_double) dX(j, i))).margin(0.01) ); } } } @@ -376,7 +376,7 @@ TEST_CASE("fn_spsolve_delayed_sparse_test") { for (uword j = 0; j < dX.n_rows; ++j) { - REQUIRE( (double) X(j, i) == Approx((double) dX(j, i)).epsilon(0.01) ); + REQUIRE( (double) X(j, i) == Approx((double) dX(j, i)).margin(0.01) ); } } } @@ -420,7 +420,7 @@ TEST_CASE("fn_spsolve_superlu_solve_test") { for (uword j = 0; j < x.n_rows; ++j) { - REQUIRE( (double) x(j, i) == Approx(dx(j, i)).epsilon(0.01) ); + REQUIRE( (double) x(j, i) == Approx(dx(j, i)).margin(0.01) ); } } } @@ -451,7 +451,7 @@ TEST_CASE("fn_spsolve_random_superlu_solve_test") { for (uword j = 0; j < x.n_rows; ++j) { - REQUIRE( x(j, i) == Approx((double) trueX(j, i)).epsilon(0.01) ); + REQUIRE( x(j, i) == Approx((double) trueX(j, i)).margin(0.01) ); } } } @@ -496,7 +496,7 @@ TEST_CASE("fn_spsolve_float_superlu_solve_test") { for (uword j = 0; j < x.n_rows; ++j) { - REQUIRE( (float) x(j, i) == Approx(dx(j, i)).epsilon(0.01) ); + REQUIRE( (float) x(j, i) == Approx(dx(j, i)).margin(0.01) ); } } } @@ -530,7 +530,7 @@ TEST_CASE("fn_spsolve_float_random_superlu_solve_test") if (std::abs(trueX(j, i)) < 0.001) REQUIRE( std::abs(x(j, i)) < 0.005 ); else - REQUIRE( trueX(j, i) == Approx((float) x(j, i)).epsilon(0.01) ); + REQUIRE( trueX(j, i) == Approx((float) x(j, i)).margin(0.01) ); } } } @@ -582,9 +582,9 @@ TEST_CASE("fn_spsolve_cx_float_superlu_solve_test") else { REQUIRE( ((cx_float) x(j, i)).real() == - Approx(dx(j, i).real()).epsilon(0.01) ); + Approx(dx(j, i).real()).margin(0.01) ); REQUIRE( ((cx_float) x(j, i)).imag() == - Approx(dx(j, i).imag()).epsilon(0.01) ); + Approx(dx(j, i).imag()).margin(0.01) ); } } } @@ -623,9 +623,9 @@ TEST_CASE("fn_spsolve_cx_float_random_superlu_solve_test") else { REQUIRE( ((cx_float) trueX(j, i)).real() == - Approx(x(j, i).real()).epsilon(0.01) ); + Approx(x(j, i).real()).margin(0.01) ); REQUIRE( ((cx_float) trueX(j, i)).imag() == - Approx(x(j, i).imag()).epsilon(0.01) ); + Approx(x(j, i).imag()).margin(0.01) ); } } } @@ -678,9 +678,9 @@ TEST_CASE("fn_spsolve_cx_superlu_solve_test") else { REQUIRE( ((cx_double) x(j, i)).real() == - Approx(dx(j, i).real()).epsilon(0.01) ); + Approx(dx(j, i).real()).margin(0.01) ); REQUIRE( ((cx_double) x(j, i)).imag() == - Approx(dx(j, i).imag()).epsilon(0.01) ); + Approx(dx(j, i).imag()).margin(0.01) ); } } } @@ -719,9 +719,9 @@ TEST_CASE("fn_spsolve_cx_random_superlu_solve_test") else { REQUIRE( ((cx_double) trueX(j, i)).real() == - Approx(x(j, i).real()).epsilon(0.01) ); + Approx(x(j, i).real()).margin(0.01) ); REQUIRE( ((cx_double) trueX(j, i)).imag() == - Approx(x(j, i).imag()).epsilon(0.01) ); + Approx(x(j, i).imag()).margin(0.01) ); } } } @@ -754,7 +754,7 @@ TEST_CASE("fn_spsolve_function_test") { for (uword j = 0; j < x.n_rows; ++j) { - REQUIRE( (double) trueX(j, i) == Approx(x(j, i)).epsilon(0.01) ); + REQUIRE( (double) trueX(j, i) == Approx(x(j, i)).margin(0.01) ); } } } @@ -791,7 +791,7 @@ TEST_CASE("fn_spsolve_float_function_test") } else { - REQUIRE( (float) trueX(j, i) == Approx(x(j, i)).epsilon(0.01) ); + REQUIRE( (float) trueX(j, i) == Approx(x(j, i)).margin(0.01) ); } } } @@ -830,9 +830,9 @@ TEST_CASE("fn_spsolve_cx_function_test") else { REQUIRE( ((cx_double) trueX(j, i)).real() == - Approx(x(j, i).real()).epsilon(0.01) ); + Approx(x(j, i).real()).margin(0.01) ); REQUIRE( ((cx_double) trueX(j, i)).imag() == - Approx(x(j, i).imag()).epsilon(0.01) ); + Approx(x(j, i).imag()).margin(0.01) ); } } } @@ -871,9 +871,9 @@ TEST_CASE("fn_spsolve_cx_float_function_test") else { REQUIRE( ((cx_float) trueX(j, i)).real() == - Approx(x(j, i).real()).epsilon(0.01) ); + Approx(x(j, i).real()).margin(0.01) ); REQUIRE( ((cx_float) trueX(j, i)).imag() == - Approx(x(j, i).imag()).epsilon(0.01) ); + Approx(x(j, i).imag()).margin(0.01) ); } } } diff --git a/tests2/fn_sum.cpp b/tests2/fn_sum.cpp index 187ca0f6..4839c8f5 100644 --- a/tests2/fn_sum.cpp +++ b/tests2/fn_sum.cpp @@ -49,9 +49,9 @@ TEST_CASE("sum2") 1.43577 }; - REQUIRE( accu(abs(colsums - sum(A ))) == Approx(0.0) ); - REQUIRE( accu(abs(colsums - sum(A,0))) == Approx(0.0) ); - REQUIRE( accu(abs(rowsums - sum(A,1))) == Approx(0.0) ); + REQUIRE( accu(abs(colsums - sum(A ))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(colsums - sum(A,0))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(rowsums - sum(A,1))) == Approx(0.0).margin(0.001) ); } @@ -79,9 +79,9 @@ TEST_CASE("sum3") cx_colvec cx_rowsums = cx_colvec(re_rowsums, 0.5*re_rowsums); - REQUIRE( accu(abs(cx_colsums - sum(A ))) == Approx(0.0) ); - REQUIRE( accu(abs(cx_colsums - sum(A,0))) == Approx(0.0) ); - REQUIRE( accu(abs(cx_rowsums - sum(A,1))) == Approx(0.0) ); + REQUIRE( accu(abs(cx_colsums - sum(A ))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_colsums - sum(A,0))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_rowsums - sum(A,1))) == Approx(0.0).margin(0.001) ); } @@ -89,8 +89,8 @@ TEST_CASE("sum4") { mat X(100,101, fill::randu); - REQUIRE( (sum(sum(X))/X.n_elem) == Approx(0.5).epsilon(0.02) ); - REQUIRE( (sum(sum(X(span::all,span::all)))/X.n_elem) == Approx(0.5).epsilon(0.02) ); + REQUIRE( (sum(sum(X))/X.n_elem) == Approx(0.5).margin(0.02) ); + REQUIRE( (sum(sum(X(span::all,span::all)))/X.n_elem) == Approx(0.5).margin(0.02) ); } @@ -135,9 +135,9 @@ TEST_CASE("sum_spmat") REQUIRE( (double) result(0, 1) == Approx(4.3) ); REQUIRE( (double) result(0, 2) == Approx(1.3) ); REQUIRE( (double) result(0, 3) == Approx(4.1) ); - REQUIRE( (double) result(0, 4) == Approx(0.0) ); + REQUIRE( (double) result(0, 4) == Approx(0.0).margin(0.001) ); REQUIRE( (double) result(0, 5) == Approx(6.6) ); - REQUIRE( (double) result(0, 6) == Approx(0.0) ); + REQUIRE( (double) result(0, 6) == Approx(0.0).margin(0.001) ); REQUIRE( (double) result(0, 7) == Approx(3.4) ); result = sum(c, 1); @@ -148,7 +148,7 @@ TEST_CASE("sum_spmat") REQUIRE( (double) result(0, 0) == Approx(3.0) ); REQUIRE( (double) result(1, 0) == Approx(3.8) ); REQUIRE( (double) result(2, 0) == Approx(4.1) ); - REQUIRE( (double) result(3, 0) == Approx(0.0) ); + REQUIRE( (double) result(3, 0) == Approx(0.0).margin(0.001) ); REQUIRE( (double) result(4, 0) == Approx(3.2) ); REQUIRE( (double) result(5, 0) == Approx(3.4) ); REQUIRE( (double) result(6, 0) == Approx(5.2) ); diff --git a/tests2/fn_symmat.cpp b/tests2/fn_symmat.cpp index e26e7774..ad28e9f0 100644 --- a/tests2/fn_symmat.cpp +++ b/tests2/fn_symmat.cpp @@ -52,8 +52,8 @@ TEST_CASE("fn_symmat_1") 0.239585 -0.428913 -0.406953 -0.291020 -0.353768;\ "; - REQUIRE( accu(abs( B - BB )) == Approx(0.0) ); - REQUIRE( accu(abs( C - CC )) == Approx(0.0) ); + REQUIRE( accu(abs( B - BB )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( C - CC )) == Approx(0.0).margin(0.001) ); mat X; REQUIRE_THROWS( X = symmatu(A) ); // symmatu() and symmatl() currently handle only square matrices @@ -109,14 +109,14 @@ TEST_CASE("fn_symmat_2") { cx_double(-0.49247, +0.41973), cx_double(-0.03131, +0.06832), cx_double( 0.31416, -0.45450) } }; - REQUIRE( accu(abs( B1 - BB )) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs( C1 - CC )) == Approx(0.0).epsilon(0.0001) ); + REQUIRE( accu(abs( B1 - BB )) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs( C1 - CC )) == Approx(0.0).margin(0.0001) ); - REQUIRE( accu(abs( B2 - BB )) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs( C2 - CC )) == Approx(0.0).epsilon(0.0001) ); + REQUIRE( accu(abs( B2 - BB )) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs( C2 - CC )) == Approx(0.0).margin(0.0001) ); - REQUIRE( accu(abs( D - DD )) == Approx(0.0).epsilon(0.0001) ); - REQUIRE( accu(abs( E - EE )) == Approx(0.0).epsilon(0.0001) ); + REQUIRE( accu(abs( D - DD )) == Approx(0.0).margin(0.0001) ); + REQUIRE( accu(abs( E - EE )) == Approx(0.0).margin(0.0001) ); cx_mat X; REQUIRE_THROWS( X = symmatu( cx_mat(A(0,0,size(2,3)), A(0,3,size(2,3))) ) ); // symmatu() and symmatl() currently handle only square matrices diff --git a/tests2/fn_trace.cpp b/tests2/fn_trace.cpp index 0f24b395..96259bdc 100644 --- a/tests2/fn_trace.cpp +++ b/tests2/fn_trace.cpp @@ -33,11 +33,11 @@ TEST_CASE("fn_trace_1") vec diagonal = { 0.061198, 0.058956, 0.314156, -0.393139, -0.353768 }; - REQUIRE( accu( trace(A) - accu(diagonal) ) == Approx(0.0) ); + REQUIRE( accu( trace(A) - accu(diagonal) ) == Approx(0.0).margin(0.001) ); - REQUIRE( accu( trace(2*A) - accu(2*diagonal) ) == Approx(0.0) ); + REQUIRE( accu( trace(2*A) - accu(2*diagonal) ) == Approx(0.0).margin(0.001) ); - REQUIRE( accu( trace(A+A) - accu(diagonal+diagonal) ) == Approx(0.0) ); + REQUIRE( accu( trace(A+A) - accu(diagonal+diagonal) ) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } diff --git a/tests2/fn_trans.cpp b/tests2/fn_trans.cpp index eabd7630..c37cf62c 100644 --- a/tests2/fn_trans.cpp +++ b/tests2/fn_trans.cpp @@ -70,93 +70,93 @@ TEST_CASE("fn_trans_1") double accu_A_col1_t = 0.21227; double accu_A_row1_t = 0.63296; - REQUIRE( accu(abs(mat(A.t().t()) - A)) == Approx(0.0) ); - REQUIRE( accu(abs( A.t().t() - A)) == Approx(0.0) ); + REQUIRE( accu(abs(mat(A.t().t()) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A.t().t() - A)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(mat(A.t() ) - At)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(A.st() ) - At)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(A.ht() ) - At)) == Approx(0.0) ); - REQUIRE( accu(abs(mat( trans(A)) - At)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(strans(A)) - At)) == Approx(0.0) ); + REQUIRE( accu(abs(mat(A.t() ) - At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(A.st() ) - At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(A.ht() ) - At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat( trans(A)) - At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(strans(A)) - At)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(A.t() - At)) == Approx(0.0) ); - REQUIRE( accu(abs(A.st() - At)) == Approx(0.0) ); - REQUIRE( accu(abs(A.ht() - At)) == Approx(0.0) ); - REQUIRE( accu(abs( trans(A) - At)) == Approx(0.0) ); - REQUIRE( accu(abs(strans(A) - At)) == Approx(0.0) ); + REQUIRE( accu(abs(A.t() - At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(A.st() - At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(A.ht() - At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( trans(A) - At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(strans(A) - At)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(mat(At.t() ) - A)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(At.st() ) - A)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(At.ht() ) - A)) == Approx(0.0) ); - REQUIRE( accu(abs(mat( trans(At)) - A)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(strans(At)) - A)) == Approx(0.0) ); + REQUIRE( accu(abs(mat(At.t() ) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(At.st() ) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(At.ht() ) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat( trans(At)) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(strans(At)) - A)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(At.t() - A)) == Approx(0.0) ); - REQUIRE( accu(abs(At.st() - A)) == Approx(0.0) ); - REQUIRE( accu(abs(At.ht() - A)) == Approx(0.0) ); - REQUIRE( accu(abs( trans(At) - A)) == Approx(0.0) ); - REQUIRE( accu(abs(strans(At) - A)) == Approx(0.0) ); + REQUIRE( accu(abs(At.t() - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(At.st() - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(At.ht() - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( trans(At) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(strans(At) - A)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((0 + At.t() ) - A)) == Approx(0.0) ); - REQUIRE( accu(abs((0 + At.st() ) - A)) == Approx(0.0) ); - REQUIRE( accu(abs((0 + At.ht() ) - A)) == Approx(0.0) ); - REQUIRE( accu(abs((0 + trans(At)) - A)) == Approx(0.0) ); - REQUIRE( accu(abs((0 + strans(At)) - A)) == Approx(0.0) ); + REQUIRE( accu(abs((0 + At.t() ) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((0 + At.st() ) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((0 + At.ht() ) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((0 + trans(At)) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((0 + strans(At)) - A)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(mat(0 + At.t() ) - A)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(0 + At.st() ) - A)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(0 + At.ht() ) - A)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(0 + trans(At)) - A)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(0 + strans(At)) - A)) == Approx(0.0) ); + REQUIRE( accu(abs(mat(0 + At.t() ) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(0 + At.st() ) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(0 + At.ht() ) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(0 + trans(At)) - A)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(0 + strans(At)) - A)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(2*A.t() - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs(2*trans(A) - 2*At)) == Approx(0.0) ); + REQUIRE( accu(abs(2*A.t() - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(2*trans(A) - 2*At)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((2*A).t() - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs(trans(2*A) - 2*At)) == Approx(0.0) ); + REQUIRE( accu(abs((2*A).t() - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(trans(2*A) - 2*At)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((A+A).t() - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs(trans(A+A) - 2*At)) == Approx(0.0) ); + REQUIRE( accu(abs((A+A).t() - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(trans(A+A) - 2*At)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((A.t() + At) - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs((trans(A) + At) - 2*At)) == Approx(0.0) ); + REQUIRE( accu(abs((A.t() + At) - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((trans(A) + At) - 2*At)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(mat(2*A.t()) - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(2*trans(A)) - 2*At)) == Approx(0.0) ); + REQUIRE( accu(abs(mat(2*A.t()) - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(2*trans(A)) - 2*At)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(mat((2*A).t()) - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(trans(2*A)) - 2*At)) == Approx(0.0) ); + REQUIRE( accu(abs(mat((2*A).t()) - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(trans(2*A)) - 2*At)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(mat((A+A).t()) - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(trans(A+A)) - 2*At)) == Approx(0.0) ); + REQUIRE( accu(abs(mat((A+A).t()) - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(trans(A+A)) - 2*At)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(mat(A.t() + At) - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs(mat(trans(A) + At) - 2*At)) == Approx(0.0) ); + REQUIRE( accu(abs(mat(A.t() + At) - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(mat(trans(A) + At) - 2*At)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(rowvec(A.col(1).t()) - A_col1_t)) == Approx(0.0) ); - REQUIRE( accu(abs(colvec(A.row(1).t()) - A_row1_t)) == Approx(0.0) ); + REQUIRE( accu(abs(rowvec(A.col(1).t()) - A_col1_t)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(colvec(A.row(1).t()) - A_row1_t)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(A.col(1).t() - A_col1_t)) == Approx(0.0) ); - REQUIRE( accu(abs(A.row(1).t() - A_row1_t)) == Approx(0.0) ); + REQUIRE( accu(abs(A.col(1).t() - A_col1_t)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(A.row(1).t() - A_row1_t)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(2*A.col(1).t() - 2*A_col1_t)) == Approx(0.0) ); - REQUIRE( accu(abs(2*A.row(1).t() - 2*A_row1_t)) == Approx(0.0) ); + REQUIRE( accu(abs(2*A.col(1).t() - 2*A_col1_t)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(2*A.row(1).t() - 2*A_row1_t)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (A.col(1).t() + A_col1_t) - 2*A_col1_t)) == Approx(0.0) ); - REQUIRE( accu(abs( (A.row(1).t() + A_row1_t) - 2*A_row1_t)) == Approx(0.0) ); + REQUIRE( accu(abs( (A.col(1).t() + A_col1_t) - 2*A_col1_t)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A.row(1).t() + A_row1_t) - 2*A_row1_t)) == Approx(0.0).margin(0.001) ); - REQUIRE( abs( accu(A.col(1).t()) - accu_A_col1_t ) == Approx(0.0) ); - REQUIRE( abs( accu(A.row(1).t()) - accu_A_row1_t ) == Approx(0.0) ); + REQUIRE( abs( accu(A.col(1).t()) - accu_A_col1_t ) == Approx(0.0).margin(0.001) ); + REQUIRE( abs( accu(A.row(1).t()) - accu_A_row1_t ) == Approx(0.0).margin(0.001) ); - REQUIRE( abs( accu(A.col(1).t()) - accu(A.col(1)) ) == Approx(0.0) ); - REQUIRE( abs( accu(A.row(1).t()) - accu(A.row(1)) ) == Approx(0.0) ); + REQUIRE( abs( accu(A.col(1).t()) - accu(A.col(1)) ) == Approx(0.0).margin(0.001) ); + REQUIRE( abs( accu(A.row(1).t()) - accu(A.row(1)) ) == Approx(0.0).margin(0.001) ); - REQUIRE( abs( sum(A.col(1).t()) - accu_A_col1_t ) == Approx(0.0) ); - REQUIRE( abs( sum(A.row(1).t()) - accu_A_row1_t ) == Approx(0.0) ); + REQUIRE( abs( sum(A.col(1).t()) - accu_A_col1_t ) == Approx(0.0).margin(0.001) ); + REQUIRE( abs( sum(A.row(1).t()) - accu_A_row1_t ) == Approx(0.0).margin(0.001) ); mat B; REQUIRE_THROWS( B = A + A.t() ); @@ -200,91 +200,91 @@ TEST_CASE("fn_trans_2") }; - REQUIRE( accu(abs(C.t().t() - C)) == Approx(0.0) ); + REQUIRE( accu(abs(C.t().t() - C)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(cx_mat(C.t() ) - Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(cx_mat(C.ht() ) - Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(cx_mat(trans(C)) - Ct)) == Approx(0.0) ); + REQUIRE( accu(abs(cx_mat(C.t() ) - Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_mat(C.ht() ) - Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_mat(trans(C)) - Ct)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(C.t() - Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(C.ht() - Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(trans(C) - Ct)) == Approx(0.0) ); + REQUIRE( accu(abs(C.t() - Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(C.ht() - Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(trans(C) - Ct)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(cx_mat(Ct.t() ) - C)) == Approx(0.0) ); - REQUIRE( accu(abs(cx_mat(Ct.ht() ) - C)) == Approx(0.0) ); - REQUIRE( accu(abs(cx_mat(trans(Ct)) - C)) == Approx(0.0) ); + REQUIRE( accu(abs(cx_mat(Ct.t() ) - C)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_mat(Ct.ht() ) - C)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_mat(trans(Ct)) - C)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(Ct.t() - C)) == Approx(0.0) ); - REQUIRE( accu(abs(Ct.ht() - C)) == Approx(0.0) ); - REQUIRE( accu(abs(trans(Ct) - C)) == Approx(0.0) ); + REQUIRE( accu(abs(Ct.t() - C)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Ct.ht() - C)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(trans(Ct) - C)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(2*C.t() - 2*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(2*trans(C) - 2*Ct)) == Approx(0.0) ); + REQUIRE( accu(abs(2*C.t() - 2*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(2*trans(C) - 2*Ct)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((2*C).t() - 2*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(trans(2*C) - 2*Ct)) == Approx(0.0) ); + REQUIRE( accu(abs((2*C).t() - 2*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(trans(2*C) - 2*Ct)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((C+C).t() - 2*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(trans(C+C) - 2*Ct)) == Approx(0.0) ); + REQUIRE( accu(abs((C+C).t() - 2*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(trans(C+C) - 2*Ct)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(cx_double(2,3)*C.t() - cx_double(2,3)*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(cx_double(2,3)*trans(C) - cx_double(2,3)*Ct)) == Approx(0.0) ); + REQUIRE( accu(abs(cx_double(2,3)*C.t() - cx_double(2,3)*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_double(2,3)*trans(C) - cx_double(2,3)*Ct)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(cx_mat(2*C.t()) - 2*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(cx_mat(2*trans(C)) - 2*Ct)) == Approx(0.0) ); + REQUIRE( accu(abs(cx_mat(2*C.t()) - 2*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_mat(2*trans(C)) - 2*Ct)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(cx_mat((2*C).t()) - 2*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(cx_mat(trans(2*C)) - 2*Ct)) == Approx(0.0) ); + REQUIRE( accu(abs(cx_mat((2*C).t()) - 2*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_mat(trans(2*C)) - 2*Ct)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(cx_mat((C+C).t()) - 2*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(cx_mat(trans(C+C)) - 2*Ct)) == Approx(0.0) ); + REQUIRE( accu(abs(cx_mat((C+C).t()) - 2*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_mat(trans(C+C)) - 2*Ct)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(cx_mat(cx_double(2,3)*C.t()) - cx_double(2,3)*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(cx_mat(cx_double(2,3)*trans(C)) - cx_double(2,3)*Ct)) == Approx(0.0) ); + REQUIRE( accu(abs(cx_mat(cx_double(2,3)*C.t()) - cx_double(2,3)*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_mat(cx_double(2,3)*trans(C)) - cx_double(2,3)*Ct)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((C.t() + Ct) - 2*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs((trans(C) + Ct) - 2*Ct)) == Approx(0.0) ); + REQUIRE( accu(abs((C.t() + Ct) - 2*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((trans(C) + Ct) - 2*Ct)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(cx_rowvec(C.col(1).t()) - C_col1_t)) == Approx(0.0) ); - REQUIRE( accu(abs(cx_colvec(C.row(1).t()) - C_row1_t)) == Approx(0.0) ); + REQUIRE( accu(abs(cx_rowvec(C.col(1).t()) - C_col1_t)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_colvec(C.row(1).t()) - C_row1_t)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(C.col(1).t() - C_col1_t)) == Approx(0.0) ); - REQUIRE( accu(abs(C.row(1).t() - C_row1_t)) == Approx(0.0) ); + REQUIRE( accu(abs(C.col(1).t() - C_col1_t)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(C.row(1).t() - C_row1_t)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(2*C.col(1).t() - 2*C_col1_t)) == Approx(0.0) ); - REQUIRE( accu(abs(2*C.row(1).t() - 2*C_row1_t)) == Approx(0.0) ); + REQUIRE( accu(abs(2*C.col(1).t() - 2*C_col1_t)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(2*C.row(1).t() - 2*C_row1_t)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (C.col(1).t() + C_col1_t) - 2*C_col1_t)) == Approx(0.0) ); - REQUIRE( accu(abs( (C.row(1).t() + C_row1_t) - 2*C_row1_t)) == Approx(0.0) ); + REQUIRE( accu(abs( (C.col(1).t() + C_col1_t) - 2*C_col1_t)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (C.row(1).t() + C_row1_t) - 2*C_row1_t)) == Approx(0.0).margin(0.001) ); // - REQUIRE( accu(abs(cx_mat(C.st()) - conj(Ct))) == Approx(0.0) ); - REQUIRE( accu(abs(cx_mat(strans(C)) - conj(Ct))) == Approx(0.0) ); + REQUIRE( accu(abs(cx_mat(C.st()) - conj(Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_mat(strans(C)) - conj(Ct))) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(C.st() - conj(Ct))) == Approx(0.0) ); - REQUIRE( accu(abs(strans(C) - conj(Ct))) == Approx(0.0) ); + REQUIRE( accu(abs(C.st() - conj(Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(strans(C) - conj(Ct))) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(2*C.st() - conj(2*Ct))) == Approx(0.0) ); - REQUIRE( accu(abs(2*strans(C) - conj(2*Ct))) == Approx(0.0) ); + REQUIRE( accu(abs(2*C.st() - conj(2*Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(2*strans(C) - conj(2*Ct))) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(cx_double(2,3)*C.st() - cx_double(2,3)*conj(Ct))) == Approx(0.0) ); - REQUIRE( accu(abs(cx_double(2,3)*strans(C) - cx_double(2,3)*conj(Ct))) == Approx(0.0) ); + REQUIRE( accu(abs(cx_double(2,3)*C.st() - cx_double(2,3)*conj(Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_double(2,3)*strans(C) - cx_double(2,3)*conj(Ct))) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs((C.st() + C.st()) - conj(2*Ct))) == Approx(0.0) ); - REQUIRE( accu(abs((strans(C) + C.st()) - conj(2*Ct))) == Approx(0.0) ); + REQUIRE( accu(abs((C.st() + C.st()) - conj(2*Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs((strans(C) + C.st()) - conj(2*Ct))) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(cx_rowvec(C.col(1).st()) - conj(C_col1_t))) == Approx(0.0) ); - REQUIRE( accu(abs(cx_colvec(C.row(1).st()) - conj(C_row1_t))) == Approx(0.0) ); + REQUIRE( accu(abs(cx_rowvec(C.col(1).st()) - conj(C_col1_t))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(cx_colvec(C.row(1).st()) - conj(C_row1_t))) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(C.col(1).st() - conj(C_col1_t))) == Approx(0.0) ); - REQUIRE( accu(abs(C.row(1).st() - conj(C_row1_t))) == Approx(0.0) ); + REQUIRE( accu(abs(C.col(1).st() - conj(C_col1_t))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(C.row(1).st() - conj(C_row1_t))) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs(2*C.col(1).st() - conj(2*C_col1_t))) == Approx(0.0) ); - REQUIRE( accu(abs(2*C.row(1).st() - conj(2*C_row1_t))) == Approx(0.0) ); + REQUIRE( accu(abs(2*C.col(1).st() - conj(2*C_col1_t))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(2*C.row(1).st() - conj(2*C_row1_t))) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (C.col(1).st() + conj(C_col1_t)) - conj(2*C_col1_t))) == Approx(0.0) ); - REQUIRE( accu(abs( (C.row(1).st() + conj(C_row1_t)) - conj(2*C_row1_t))) == Approx(0.0) ); + REQUIRE( accu(abs( (C.col(1).st() + conj(C_col1_t)) - conj(2*C_col1_t))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (C.row(1).st() + conj(C_row1_t)) - conj(2*C_row1_t))) == Approx(0.0).margin(0.001) ); // @@ -326,38 +326,38 @@ TEST_CASE("fn_trans_3") X = A; X = X.t(); Y = B; Y = Y.t(); - REQUIRE( accu(abs(X - At)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - Bt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - Bt)) == Approx(0.0).margin(0.001) ); X = A; X = 0 + X.t(); Y = B; Y = 0 + Y.t(); - REQUIRE( accu(abs(X - At)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - Bt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - Bt)) == Approx(0.0).margin(0.001) ); X = A; X = 2*X.t(); Y = B; Y = 2*Y.t(); - REQUIRE( accu(abs(X - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - 2*Bt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - 2*Bt)) == Approx(0.0).margin(0.001) ); X = A; X = 0 + 2*X.t(); Y = B; Y = 0 + 2*Y.t(); - REQUIRE( accu(abs(X - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - 2*Bt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - 2*Bt)) == Approx(0.0).margin(0.001) ); X = A; X = (2*X).t(); Y = B; Y = (2*Y).t(); - REQUIRE( accu(abs(X - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - 2*Bt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - 2*Bt)) == Approx(0.0).margin(0.001) ); X = A; X = (X+X).t(); Y = B; Y = (Y+Y).t(); - REQUIRE( accu(abs(X - 2*At)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - 2*Bt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - 2*At)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - 2*Bt)) == Approx(0.0).margin(0.001) ); colvec q = A.col(1); rowvec r = A.row(1); @@ -403,88 +403,88 @@ TEST_CASE("fn_trans_4") X = C; X = X.t(); Y = D; Y = Y.t(); - REQUIRE( accu(abs(X - Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - Dt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - Dt)) == Approx(0.0).margin(0.001) ); X = C; X = 0 + X.t(); Y = D; Y = 0 + Y.t(); - REQUIRE( accu(abs(X - Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - Dt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - Dt)) == Approx(0.0).margin(0.001) ); X = C; X = 2*X.t(); Y = D; Y = 2*Y.t(); - REQUIRE( accu(abs(X - 2*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - 2*Dt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - 2*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - 2*Dt)) == Approx(0.0).margin(0.001) ); X = C; X = 0 + 2*X.t(); Y = D; Y = 0 + 2*Y.t(); - REQUIRE( accu(abs(X - 2*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - 2*Dt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - 2*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - 2*Dt)) == Approx(0.0).margin(0.001) ); X = C; X = (2*X).t(); Y = D; Y = (2*Y).t(); - REQUIRE( accu(abs(X - 2*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - 2*Dt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - 2*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - 2*Dt)) == Approx(0.0).margin(0.001) ); X = C; X = (X+X).t(); Y = D; Y = (Y+Y).t(); - REQUIRE( accu(abs(X - 2*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - 2*Dt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - 2*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - 2*Dt)) == Approx(0.0).margin(0.001) ); X = C; X = cx_double(2,3)*X.t(); Y = D; Y = cx_double(2,3)*Y.t(); - REQUIRE( accu(abs(X - cx_double(2,3)*Ct)) == Approx(0.0) ); - REQUIRE( accu(abs(Y - cx_double(2,3)*Dt)) == Approx(0.0) ); + REQUIRE( accu(abs(X - cx_double(2,3)*Ct)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - cx_double(2,3)*Dt)) == Approx(0.0).margin(0.001) ); // X = C; X = X.st(); Y = D; Y = Y.st(); - REQUIRE( accu(abs(X - conj(Ct))) == Approx(0.0) ); - REQUIRE( accu(abs(Y - conj(Dt))) == Approx(0.0) ); + REQUIRE( accu(abs(X - conj(Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - conj(Dt))) == Approx(0.0).margin(0.001) ); X = C; X = 0 + X.st(); Y = D; Y = 0 + Y.st(); - REQUIRE( accu(abs(X - conj(Ct))) == Approx(0.0) ); - REQUIRE( accu(abs(Y - conj(Dt))) == Approx(0.0) ); + REQUIRE( accu(abs(X - conj(Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - conj(Dt))) == Approx(0.0).margin(0.001) ); X = C; X = 2*X.st(); Y = D; Y = 2*Y.st(); - REQUIRE( accu(abs(X - 2*conj(Ct))) == Approx(0.0) ); - REQUIRE( accu(abs(Y - 2*conj(Dt))) == Approx(0.0) ); + REQUIRE( accu(abs(X - 2*conj(Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - 2*conj(Dt))) == Approx(0.0).margin(0.001) ); X = C; X = 0 + 2*X.st(); Y = D; Y = 0 + 2*Y.st(); - REQUIRE( accu(abs(X - 2*conj(Ct))) == Approx(0.0) ); - REQUIRE( accu(abs(Y - 2*conj(Dt))) == Approx(0.0) ); + REQUIRE( accu(abs(X - 2*conj(Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - 2*conj(Dt))) == Approx(0.0).margin(0.001) ); X = C; X = (2*X).st(); Y = D; Y = (2*Y).st(); - REQUIRE( accu(abs(X - conj(2*Ct))) == Approx(0.0) ); - REQUIRE( accu(abs(Y - conj(2*Dt))) == Approx(0.0) ); + REQUIRE( accu(abs(X - conj(2*Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - conj(2*Dt))) == Approx(0.0).margin(0.001) ); X = C; X = (X+X).st(); Y = D; Y = (Y+Y).st(); - REQUIRE( accu(abs(X - conj(2*Ct))) == Approx(0.0) ); - REQUIRE( accu(abs(Y - conj(2*Dt))) == Approx(0.0) ); + REQUIRE( accu(abs(X - conj(2*Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - conj(2*Dt))) == Approx(0.0).margin(0.001) ); X = C; X = cx_double(2,3)*X.st(); Y = D; Y = cx_double(2,3)*Y.st(); - REQUIRE( accu(abs(X - cx_double(2,3)*conj(Ct))) == Approx(0.0) ); - REQUIRE( accu(abs(Y - cx_double(2,3)*conj(Dt))) == Approx(0.0) ); + REQUIRE( accu(abs(X - cx_double(2,3)*conj(Ct))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(Y - cx_double(2,3)*conj(Dt))) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/fn_var.cpp b/tests2/fn_var.cpp index 4be67946..ad15634a 100644 --- a/tests2/fn_var.cpp +++ b/tests2/fn_var.cpp @@ -29,7 +29,7 @@ TEST_CASE("fn_var_empty_sparse_test") REQUIRE( result.n_rows == 1 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) result[i] == Approx(0.0) ); + REQUIRE( (double) result[i] == Approx(0.0).margin(0.001) ); } result = var(m, 0, 0); @@ -38,7 +38,7 @@ TEST_CASE("fn_var_empty_sparse_test") REQUIRE( result.n_rows == 1 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) result[i] == Approx(0.0) ); + REQUIRE( (double) result[i] == Approx(0.0).margin(0.001) ); } result = var(m, 1, 0); @@ -47,7 +47,7 @@ TEST_CASE("fn_var_empty_sparse_test") REQUIRE( result.n_rows == 1 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) result[i] == Approx(0.0) ); + REQUIRE( (double) result[i] == Approx(0.0).margin(0.001) ); } result = var(m, 1); @@ -56,7 +56,7 @@ TEST_CASE("fn_var_empty_sparse_test") REQUIRE( result.n_rows == 1 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) result[i] == Approx(0.0) ); + REQUIRE( (double) result[i] == Approx(0.0).margin(0.001) ); } SpCol colres = var(m, 1, 1); @@ -65,7 +65,7 @@ TEST_CASE("fn_var_empty_sparse_test") REQUIRE( colres.n_rows == 100 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) colres[i] == Approx(0.0) ); + REQUIRE( (double) colres[i] == Approx(0.0).margin(0.001) ); } colres = var(m, 0, 1); @@ -74,7 +74,7 @@ TEST_CASE("fn_var_empty_sparse_test") REQUIRE( colres.n_rows == 100 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) colres[i] == Approx(0.0) ); + REQUIRE( (double) colres[i] == Approx(0.0).margin(0.001) ); } } @@ -90,7 +90,7 @@ TEST_CASE("fn_var_empty_cx_sparse_test") REQUIRE( result.n_rows == 1 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) result[i] == Approx(0.0) ); + REQUIRE( (double) result[i] == Approx(0.0).margin(0.001) ); } result = var(m, 0, 0); @@ -99,7 +99,7 @@ TEST_CASE("fn_var_empty_cx_sparse_test") REQUIRE( result.n_rows == 1 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) result[i] == Approx(0.0) ); + REQUIRE( (double) result[i] == Approx(0.0).margin(0.001) ); } result = var(m, 1, 0); @@ -108,7 +108,7 @@ TEST_CASE("fn_var_empty_cx_sparse_test") REQUIRE( result.n_rows == 1 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) result[i] == Approx(0.0) ); + REQUIRE( (double) result[i] == Approx(0.0).margin(0.001) ); } result = var(m, 1); @@ -117,7 +117,7 @@ TEST_CASE("fn_var_empty_cx_sparse_test") REQUIRE( result.n_rows == 1 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) result[i] == Approx(0.0) ); + REQUIRE( (double) result[i] == Approx(0.0).margin(0.001) ); } SpCol colres = var(m, 1, 1); @@ -126,7 +126,7 @@ TEST_CASE("fn_var_empty_cx_sparse_test") REQUIRE( colres.n_rows == 100 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) colres[i] == Approx(0.0) ); + REQUIRE( (double) colres[i] == Approx(0.0).margin(0.001) ); } colres = var(m, 0, 1); @@ -135,7 +135,7 @@ TEST_CASE("fn_var_empty_cx_sparse_test") REQUIRE( colres.n_rows == 100 ); for (uword i = 0; i < 100; ++i) { - REQUIRE( (double) colres[i] == Approx(0.0) ); + REQUIRE( (double) colres[i] == Approx(0.0).margin(0.001) ); } } diff --git a/tests2/fn_vectorise.cpp b/tests2/fn_vectorise.cpp index 211169da..103f0ea7 100644 --- a/tests2/fn_vectorise.cpp +++ b/tests2/fn_vectorise.cpp @@ -44,7 +44,7 @@ TEST_CASE("fn_vectorise_1") rowvec b = { 0.061198, 0.201990, 0.437242, 0.058956, -0.492474, -0.031309, 0.336352, 0.411541 }; - REQUIRE( accu(abs(a - vectorise(A ))) == Approx(0.0) ); - REQUIRE( accu(abs(a - vectorise(A,0))) == Approx(0.0) ); - REQUIRE( accu(abs(b - vectorise(A,1))) == Approx(0.0) ); + REQUIRE( accu(abs(a - vectorise(A ))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(a - vectorise(A,0))) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(b - vectorise(A,1))) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/gen_ones.cpp b/tests2/gen_ones.cpp index bd118bf4..15660256 100644 --- a/tests2/gen_ones.cpp +++ b/tests2/gen_ones.cpp @@ -63,27 +63,27 @@ TEST_CASE("gen_ones_2") A.col(1).ones(); - REQUIRE( accu(A.col(0)) == Approx(0.0) ); + REQUIRE( accu(A.col(0)) == Approx(0.0).margin(0.001) ); REQUIRE( accu(A.col(1)) == Approx(double(A.n_rows)) ); - REQUIRE( accu(A.col(2)) == Approx(0.0) ); + REQUIRE( accu(A.col(2)) == Approx(0.0).margin(0.001) ); mat B(5,6,fill::zeros); B.row(1).ones(); - REQUIRE( accu(B.row(0)) == Approx(0.0) ); + REQUIRE( accu(B.row(0)) == Approx(0.0).margin(0.001) ); REQUIRE( accu(B.row(1)) == Approx(double(B.n_cols)) ); - REQUIRE( accu(B.row(2)) == Approx(0.0) ); + REQUIRE( accu(B.row(2)) == Approx(0.0).margin(0.001) ); mat C(5,6,fill::zeros); C(span(1,3),span(1,4)).ones(); - REQUIRE( accu(C.head_cols(1)) == Approx(0.0) ); - REQUIRE( accu(C.head_rows(1)) == Approx(0.0) ); + REQUIRE( accu(C.head_cols(1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(C.head_rows(1)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(C.tail_cols(1)) == Approx(0.0) ); - REQUIRE( accu(C.tail_rows(1)) == Approx(0.0) ); + REQUIRE( accu(C.tail_cols(1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(C.tail_rows(1)) == Approx(0.0).margin(0.001) ); REQUIRE( accu(C(span(1,3),span(1,4))) == Approx(double(3*4)) ); @@ -106,8 +106,8 @@ TEST_CASE("gen_ones_3") REQUIRE( accu(A) == Approx(double(3)) ); - REQUIRE( A(0) == Approx(0.0) ); - REQUIRE( A(A.n_elem-1) == Approx(0.0) ); + REQUIRE( A(0) == Approx(0.0).margin(0.001) ); + REQUIRE( A(A.n_elem-1) == Approx(0.0).margin(0.001) ); REQUIRE( A(indices(0)) == Approx(1.0) ); REQUIRE( A(indices(1)) == Approx(1.0) ); diff --git a/tests2/gen_randu.cpp b/tests2/gen_randu.cpp index feb2323d..c4a9253f 100644 --- a/tests2/gen_randu.cpp +++ b/tests2/gen_randu.cpp @@ -31,11 +31,11 @@ TEST_CASE("gen_randu_1") mat C; C.randu(n_rows,n_cols); - REQUIRE( (accu(A)/A.n_elem) == Approx(0.5).epsilon(0.02) ); - REQUIRE( (accu(B)/A.n_elem) == Approx(0.5).epsilon(0.02) ); - REQUIRE( (accu(C)/A.n_elem) == Approx(0.5).epsilon(0.02) ); + REQUIRE( (accu(A)/A.n_elem) == Approx(0.5).margin(0.02) ); + REQUIRE( (accu(B)/A.n_elem) == Approx(0.5).margin(0.02) ); + REQUIRE( (accu(C)/A.n_elem) == Approx(0.5).margin(0.02) ); - REQUIRE( (mean(vectorise(A))) == Approx(0.5).epsilon(0.02) ); + REQUIRE( (mean(vectorise(A))) == Approx(0.5).margin(0.02) ); } @@ -46,12 +46,12 @@ TEST_CASE("gen_randu_2") A(span(1,48),span(1,58)).randu(); - REQUIRE( accu(A.head_cols(1)) == Approx(0.0) ); - REQUIRE( accu(A.head_rows(1)) == Approx(0.0) ); + REQUIRE( accu(A.head_cols(1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(A.head_rows(1)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(A.tail_cols(1)) == Approx(0.0) ); - REQUIRE( accu(A.tail_rows(1)) == Approx(0.0) ); + REQUIRE( accu(A.tail_cols(1)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(A.tail_rows(1)) == Approx(0.0).margin(0.001) ); - REQUIRE( mean(vectorise(A(span(1,48),span(1,58)))) == Approx(double(0.5)).epsilon(0.02) ); + REQUIRE( mean(vectorise(A(span(1,48),span(1,58)))) == Approx(double(0.5)).margin(0.02) ); } diff --git a/tests2/gen_zeros.cpp b/tests2/gen_zeros.cpp index 685feb36..b0791c25 100644 --- a/tests2/gen_zeros.cpp +++ b/tests2/gen_zeros.cpp @@ -24,7 +24,7 @@ TEST_CASE("gen_zeros_1") { mat A(5,6,fill::zeros); - REQUIRE( accu(A) == Approx(0.0) ); + REQUIRE( accu(A) == Approx(0.0).margin(0.001) ); REQUIRE( A.n_rows == 5 ); REQUIRE( A.n_cols == 6 ); @@ -32,25 +32,25 @@ TEST_CASE("gen_zeros_1") B.zeros(); - REQUIRE( accu(B) == Approx(0.0) ); + REQUIRE( accu(B) == Approx(0.0).margin(0.001) ); REQUIRE( B.n_rows == 5 ); REQUIRE( B.n_cols == 6 ); mat C = zeros(5,6); - REQUIRE( accu(C) == Approx(0.0) ); + REQUIRE( accu(C) == Approx(0.0).margin(0.001) ); REQUIRE( C.n_rows == 5 ); REQUIRE( C.n_cols == 6 ); mat D; D = zeros(5,6); - REQUIRE( accu(D) == Approx(0.0) ); + REQUIRE( accu(D) == Approx(0.0).margin(0.001) ); REQUIRE( D.n_rows == 5 ); REQUIRE( D.n_cols == 6 ); mat E; E = 2*zeros(5,6); - REQUIRE( accu(E) == Approx(0.0) ); + REQUIRE( accu(E) == Approx(0.0).margin(0.001) ); REQUIRE( E.n_rows == 5 ); REQUIRE( E.n_cols == 6 ); } @@ -64,7 +64,7 @@ TEST_CASE("gen_zeros_2") A.col(1).zeros(); REQUIRE( accu(A.col(0)) == Approx(double(A.n_rows)) ); - REQUIRE( accu(A.col(1)) == Approx(0.0) ); + REQUIRE( accu(A.col(1)) == Approx(0.0).margin(0.001) ); REQUIRE( accu(A.col(2)) == Approx(double(A.n_rows)) ); mat B(5,6,fill::ones); @@ -72,7 +72,7 @@ TEST_CASE("gen_zeros_2") B.row(1).zeros(); REQUIRE( accu(B.row(0)) == Approx(double(B.n_cols)) ); - REQUIRE( accu(B.row(1)) == Approx(0.0) ); + REQUIRE( accu(B.row(1)) == Approx(0.0).margin(0.001) ); REQUIRE( accu(B.row(2)) == Approx(double(B.n_cols)) ); mat C(5,6,fill::ones); @@ -85,13 +85,13 @@ TEST_CASE("gen_zeros_2") REQUIRE( accu(C.tail_cols(1)) == Approx(double(5)) ); REQUIRE( accu(C.tail_rows(1)) == Approx(double(6)) ); - REQUIRE( accu(C(span(1,3),span(1,4))) == Approx(0.0) ); + REQUIRE( accu(C(span(1,3),span(1,4))) == Approx(0.0).margin(0.001) ); mat D(5,6,fill::ones); D.diag().zeros(); - REQUIRE( accu(D.diag()) == Approx(0.0) ); + REQUIRE( accu(D.diag()) == Approx(0.0).margin(0.001) ); } @@ -109,9 +109,9 @@ TEST_CASE("gen_zeros_3") REQUIRE( A(0) == Approx(1.0) ); REQUIRE( A(A.n_elem-1) == Approx(1.0) ); - REQUIRE( A(indices(0)) == Approx(0.0) ); - REQUIRE( A(indices(1)) == Approx(0.0) ); - REQUIRE( A(indices(2)) == Approx(0.0) ); + REQUIRE( A(indices(0)) == Approx(0.0).margin(0.001) ); + REQUIRE( A(indices(1)) == Approx(0.0).margin(0.001) ); + REQUIRE( A(indices(2)) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/gmm.cpp b/tests2/gmm.cpp index b74dc002..55a4f5a1 100644 --- a/tests2/gmm.cpp +++ b/tests2/gmm.cpp @@ -87,16 +87,16 @@ TEST_CASE("gmm_full_1") for(size_t i = 0; i < gaussians; i++) { // Check weight. - success &= ( weights[sortRef[i]] == Approx(gmm.hefts[sortTry[i]]).epsilon(0.1) ); + success &= ( weights[sortRef[i]] == Approx(gmm.hefts[sortTry[i]]).margin(0.1) ); for(uword j = 0; j < gmm.means.n_rows; ++j) { - success &= ( means[sortRef[i]][j] == Approx(gmm.means(j, sortTry[i])).epsilon(0.1) ); + success &= ( means[sortRef[i]][j] == Approx(gmm.means(j, sortTry[i])).margin(0.1) ); } for(uword j = 0; j < gmm.fcovs.n_rows * gmm.fcovs.n_cols; ++j) { - success &= ( covars[sortRef[i]][j] == Approx(gmm.fcovs.slice(sortTry[i])[j]).epsilon(0.1) ); + success &= ( covars[sortRef[i]][j] == Approx(gmm.fcovs.slice(sortTry[i])[j]).margin(0.1) ); } if(success == false) { continue; } @@ -185,16 +185,16 @@ TEST_CASE("gmm_diag_1") for(size_t i = 0; i < gaussians; i++) { // Check weight. - success &= ( weights[sortRef[i]] == Approx(gmm.hefts[sortTry[i]]).epsilon(0.1) ); + success &= ( weights[sortRef[i]] == Approx(gmm.hefts[sortTry[i]]).margin(0.1) ); for(uword j = 0; j < gmm.means.n_rows; ++j) { - success &= ( means[sortRef[i]][j] == Approx(gmm.means(j, sortTry[i])).epsilon(0.1) ); + success &= ( means[sortRef[i]][j] == Approx(gmm.means(j, sortTry[i])).margin(0.1) ); } for(uword j = 0; j < gmm.dcovs.n_rows; ++j) { - success &= ( covars[sortRef[i]](j, j) == Approx(gmm.dcovs.col(sortTry[i])[j]).epsilon(0.1) ); + success &= ( covars[sortRef[i]](j, j) == Approx(gmm.dcovs.col(sortTry[i])[j]).margin(0.1) ); } if(success == false) { continue; } diff --git a/tests2/init_misc.cpp b/tests2/init_misc.cpp index ecaa852d..637f11e4 100644 --- a/tests2/init_misc.cpp +++ b/tests2/init_misc.cpp @@ -134,9 +134,9 @@ TEST_CASE("init_misc_2") REQUIRE( A(1,3) == Approx( 0.53124) ); REQUIRE( A(2,3) == Approx( 0.40163) ); - REQUIRE( accu(abs(A-B)) == Approx(0.0) ); - REQUIRE( accu(abs(A-C)) == Approx(0.0) ); - REQUIRE( accu(abs(A-D)) == Approx(0.0) ); + REQUIRE( accu(abs(A-B)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(A-C)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs(A-D)) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/mat_minus.cpp b/tests2/mat_minus.cpp index 500b1b29..9d55a036 100644 --- a/tests2/mat_minus.cpp +++ b/tests2/mat_minus.cpp @@ -93,10 +93,10 @@ TEST_CASE("mat_minus_1") REQUIRE( Y(4,5) == Approx( 0.0191190) ); - REQUIRE( accu(mat(A-B) + (neg_of_A_minus_B)) == Approx(0.0) ); - REQUIRE( accu( (A-B) + (neg_of_A_minus_B)) == Approx(0.0) ); + REQUIRE( accu(mat(A-B) + (neg_of_A_minus_B)) == Approx(0.0).margin(0.001) ); + REQUIRE( accu( (A-B) + (neg_of_A_minus_B)) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*(A-B) + 2*neg_of_A_minus_B )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*(A-B) + 2*neg_of_A_minus_B )) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } diff --git a/tests2/mat_mul_cx.cpp b/tests2/mat_mul_cx.cpp index a85fb878..9cc1448b 100644 --- a/tests2/mat_mul_cx.cpp +++ b/tests2/mat_mul_cx.cpp @@ -186,105 +186,105 @@ TEST_CASE("mat_mul_cx_1") - REQUIRE( accu(abs( C*D.t() - C_times_D_t )) == Approx(0.0).epsilon(0.00005) ); - REQUIRE( accu(abs( C.t()*D - C_t_times_D )) == Approx(0.0).epsilon(0.00005) ); + REQUIRE( accu(abs( C*D.t() - C_times_D_t )) == Approx(0.0).margin(0.00005) ); + REQUIRE( accu(abs( C.t()*D - C_t_times_D )) == Approx(0.0).margin(0.00005) ); // - REQUIRE( accu(abs( re*C*D.t() - re_times_C_times_D_t )) == Approx(0.0).epsilon(0.00005) ); - REQUIRE( accu(abs( re*C.t()*D - re_times_C_t_times_D )) == Approx(0.0).epsilon(0.00005) ); + REQUIRE( accu(abs( re*C*D.t() - re_times_C_times_D_t )) == Approx(0.0).margin(0.00005) ); + REQUIRE( accu(abs( re*C.t()*D - re_times_C_t_times_D )) == Approx(0.0).margin(0.00005) ); - REQUIRE( accu(abs( C*re*D.t() - C_times_re_times_D_t )) == Approx(0.0).epsilon(0.00005) ); - REQUIRE( accu(abs( C.t()*re*D - C_t_times_re_times_D )) == Approx(0.0).epsilon(0.00005) ); + REQUIRE( accu(abs( C*re*D.t() - C_times_re_times_D_t )) == Approx(0.0).margin(0.00005) ); + REQUIRE( accu(abs( C.t()*re*D - C_t_times_re_times_D )) == Approx(0.0).margin(0.00005) ); - REQUIRE( accu(abs( re*C*re*D.t() - re_times_C_times_re_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( re*C.t()*re*D - re_times_C_t_times_re_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( re*C*re*D.t() - re_times_C_times_re_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( re*C.t()*re*D - re_times_C_t_times_re_times_D )) == Approx(0.0).margin(0.00010) ); // - REQUIRE( accu(abs( (re*C)*D.t() - re_times_C_times_D_t )) == Approx(0.0).epsilon(0.00005) ); - REQUIRE( accu(abs( (re*C.t())*D - re_times_C_t_times_D )) == Approx(0.0).epsilon(0.00005) ); + REQUIRE( accu(abs( (re*C)*D.t() - re_times_C_times_D_t )) == Approx(0.0).margin(0.00005) ); + REQUIRE( accu(abs( (re*C.t())*D - re_times_C_t_times_D )) == Approx(0.0).margin(0.00005) ); - REQUIRE( accu(abs( C*(re*D.t()) - C_times_re_times_D_t )) == Approx(0.0).epsilon(0.00005) ); - REQUIRE( accu(abs( C.t()*(re*D) - C_t_times_re_times_D )) == Approx(0.0).epsilon(0.00005) ); + REQUIRE( accu(abs( C*(re*D.t()) - C_times_re_times_D_t )) == Approx(0.0).margin(0.00005) ); + REQUIRE( accu(abs( C.t()*(re*D) - C_t_times_re_times_D )) == Approx(0.0).margin(0.00005) ); - REQUIRE( accu(abs( (re*C)*(re*D.t()) - re_times_C_times_re_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( (re*C.t())*(re*D) - re_times_C_t_times_re_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( (re*C)*(re*D.t()) - re_times_C_times_re_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( (re*C.t())*(re*D) - re_times_C_t_times_re_times_D )) == Approx(0.0).margin(0.00010) ); - REQUIRE( accu(abs( C*D.t().eval() - C_times_D_t )) == Approx(0.0).epsilon(0.00005) ); - REQUIRE( accu(abs( C.t().eval()*D - C_t_times_D )) == Approx(0.0).epsilon(0.00005) ); + REQUIRE( accu(abs( C*D.t().eval() - C_times_D_t )) == Approx(0.0).margin(0.00005) ); + REQUIRE( accu(abs( C.t().eval()*D - C_t_times_D )) == Approx(0.0).margin(0.00005) ); // - REQUIRE( accu(abs( re*C*D.t().eval() - re_times_C_times_D_t )) == Approx(0.0).epsilon(0.00005) ); - REQUIRE( accu(abs( re*C.t().eval()*D - re_times_C_t_times_D )) == Approx(0.0).epsilon(0.00005) ); + REQUIRE( accu(abs( re*C*D.t().eval() - re_times_C_times_D_t )) == Approx(0.0).margin(0.00005) ); + REQUIRE( accu(abs( re*C.t().eval()*D - re_times_C_t_times_D )) == Approx(0.0).margin(0.00005) ); - REQUIRE( accu(abs( C*re*D.t().eval() - C_times_re_times_D_t )) == Approx(0.0).epsilon(0.00005) ); - REQUIRE( accu(abs( C.t().eval()*re*D - C_t_times_re_times_D )) == Approx(0.0).epsilon(0.00005) ); + REQUIRE( accu(abs( C*re*D.t().eval() - C_times_re_times_D_t )) == Approx(0.0).margin(0.00005) ); + REQUIRE( accu(abs( C.t().eval()*re*D - C_t_times_re_times_D )) == Approx(0.0).margin(0.00005) ); - REQUIRE( accu(abs( re*C*re*D.t().eval() - re_times_C_times_re_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( re*C.t().eval()*re*D - re_times_C_t_times_re_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( re*C*re*D.t().eval() - re_times_C_times_re_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( re*C.t().eval()*re*D - re_times_C_t_times_re_times_D )) == Approx(0.0).margin(0.00010) ); // - REQUIRE( accu(abs( (re*C)*(D.t().eval()) - re_times_C_times_D_t )) == Approx(0.0).epsilon(0.00005) ); - REQUIRE( accu(abs( (re*C.t()).eval()*D - re_times_C_t_times_D )) == Approx(0.0).epsilon(0.00005) ); + REQUIRE( accu(abs( (re*C)*(D.t().eval()) - re_times_C_times_D_t )) == Approx(0.0).margin(0.00005) ); + REQUIRE( accu(abs( (re*C.t()).eval()*D - re_times_C_t_times_D )) == Approx(0.0).margin(0.00005) ); - REQUIRE( accu(abs( C*(re*D.t()).eval() - C_times_re_times_D_t )) == Approx(0.0).epsilon(0.00005) ); - REQUIRE( accu(abs( C.t().eval()*(re*D) - C_t_times_re_times_D )) == Approx(0.0).epsilon(0.00005) ); + REQUIRE( accu(abs( C*(re*D.t()).eval() - C_times_re_times_D_t )) == Approx(0.0).margin(0.00005) ); + REQUIRE( accu(abs( C.t().eval()*(re*D) - C_t_times_re_times_D )) == Approx(0.0).margin(0.00005) ); - REQUIRE( accu(abs( (re*C)*(re*D.t()).eval() - re_times_C_times_re_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( (re*C.t()).eval()*(re*D) - re_times_C_t_times_re_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( (re*C)*(re*D.t()).eval() - re_times_C_times_re_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( (re*C.t()).eval()*(re*D) - re_times_C_t_times_re_times_D )) == Approx(0.0).margin(0.00010) ); // - REQUIRE( accu(abs( cx*C*D.t() - cx_times_C_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( cx*C.t()*D - cx_times_C_t_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( cx*C*D.t() - cx_times_C_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( cx*C.t()*D - cx_times_C_t_times_D )) == Approx(0.0).margin(0.00010) ); - REQUIRE( accu(abs( C*cx*D.t() - C_times_cx_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( C.t()*cx*D - C_t_times_cx_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( C*cx*D.t() - C_times_cx_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( C.t()*cx*D - C_t_times_cx_times_D )) == Approx(0.0).margin(0.00010) ); - REQUIRE( accu(abs( cx*C*cx*D.t() - cx_times_C_times_cx_times_D_t )) == Approx(0.0).epsilon(0.00030) ); - REQUIRE( accu(abs( cx*C.t()*cx*D - cx_times_C_t_times_cx_times_D )) == Approx(0.0).epsilon(0.00030) ); + REQUIRE( accu(abs( cx*C*cx*D.t() - cx_times_C_times_cx_times_D_t )) == Approx(0.0).margin(0.00030) ); + REQUIRE( accu(abs( cx*C.t()*cx*D - cx_times_C_t_times_cx_times_D )) == Approx(0.0).margin(0.00030) ); // - REQUIRE( accu(abs( (cx*C)*D.t() - cx_times_C_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( (cx*C.t())*D - cx_times_C_t_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( (cx*C)*D.t() - cx_times_C_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( (cx*C.t())*D - cx_times_C_t_times_D )) == Approx(0.0).margin(0.00010) ); - REQUIRE( accu(abs( C*(cx*D.t()) - C_times_cx_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( C.t()*(cx*D) - C_t_times_cx_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( C*(cx*D.t()) - C_times_cx_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( C.t()*(cx*D) - C_t_times_cx_times_D )) == Approx(0.0).margin(0.00010) ); - REQUIRE( accu(abs( (cx*C)*(cx*D.t()) - cx_times_C_times_cx_times_D_t )) == Approx(0.0).epsilon(0.00030) ); - REQUIRE( accu(abs( (cx*C.t())*(cx*D) - cx_times_C_t_times_cx_times_D )) == Approx(0.0).epsilon(0.00030) ); + REQUIRE( accu(abs( (cx*C)*(cx*D.t()) - cx_times_C_times_cx_times_D_t )) == Approx(0.0).margin(0.00030) ); + REQUIRE( accu(abs( (cx*C.t())*(cx*D) - cx_times_C_t_times_cx_times_D )) == Approx(0.0).margin(0.00030) ); - REQUIRE( accu(abs( C*D.t().eval() - C_times_D_t )) == Approx(0.0).epsilon(0.00005) ); - REQUIRE( accu(abs( C.t().eval()*D - C_t_times_D )) == Approx(0.0).epsilon(0.00005) ); + REQUIRE( accu(abs( C*D.t().eval() - C_times_D_t )) == Approx(0.0).margin(0.00005) ); + REQUIRE( accu(abs( C.t().eval()*D - C_t_times_D )) == Approx(0.0).margin(0.00005) ); // - REQUIRE( accu(abs( cx*C*D.t().eval() - cx_times_C_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( cx*C.t().eval()*D - cx_times_C_t_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( cx*C*D.t().eval() - cx_times_C_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( cx*C.t().eval()*D - cx_times_C_t_times_D )) == Approx(0.0).margin(0.00010) ); - REQUIRE( accu(abs( C*cx*D.t().eval() - C_times_cx_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( C.t().eval()*cx*D - C_t_times_cx_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( C*cx*D.t().eval() - C_times_cx_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( C.t().eval()*cx*D - C_t_times_cx_times_D )) == Approx(0.0).margin(0.00010) ); - REQUIRE( accu(abs( cx*C*cx*D.t().eval() - cx_times_C_times_cx_times_D_t )) == Approx(0.0).epsilon(0.00030) ); - REQUIRE( accu(abs( cx*C.t().eval()*cx*D - cx_times_C_t_times_cx_times_D )) == Approx(0.0).epsilon(0.00030) ); + REQUIRE( accu(abs( cx*C*cx*D.t().eval() - cx_times_C_times_cx_times_D_t )) == Approx(0.0).margin(0.00030) ); + REQUIRE( accu(abs( cx*C.t().eval()*cx*D - cx_times_C_t_times_cx_times_D )) == Approx(0.0).margin(0.00030) ); // - REQUIRE( accu(abs( (cx*C)*(D.t().eval()) - cx_times_C_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( (cx*C.t()).eval()*D - cx_times_C_t_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( (cx*C)*(D.t().eval()) - cx_times_C_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( (cx*C.t()).eval()*D - cx_times_C_t_times_D )) == Approx(0.0).margin(0.00010) ); - REQUIRE( accu(abs( C*(cx*D.t()).eval() - C_times_cx_times_D_t )) == Approx(0.0).epsilon(0.00010) ); - REQUIRE( accu(abs( C.t().eval()*(cx*D) - C_t_times_cx_times_D )) == Approx(0.0).epsilon(0.00010) ); + REQUIRE( accu(abs( C*(cx*D.t()).eval() - C_times_cx_times_D_t )) == Approx(0.0).margin(0.00010) ); + REQUIRE( accu(abs( C.t().eval()*(cx*D) - C_t_times_cx_times_D )) == Approx(0.0).margin(0.00010) ); - REQUIRE( accu(abs( (cx*C)*(cx*D.t()).eval() - cx_times_C_times_cx_times_D_t )) == Approx(0.0).epsilon(0.00030) ); - REQUIRE( accu(abs( (cx*C.t()).eval()*(cx*D) - cx_times_C_t_times_cx_times_D )) == Approx(0.0).epsilon(0.00030) ); + REQUIRE( accu(abs( (cx*C)*(cx*D.t()).eval() - cx_times_C_times_cx_times_D_t )) == Approx(0.0).margin(0.00030) ); + REQUIRE( accu(abs( (cx*C.t()).eval()*(cx*D) - cx_times_C_t_times_cx_times_D )) == Approx(0.0).margin(0.00030) ); } diff --git a/tests2/mat_mul_real.cpp b/tests2/mat_mul_real.cpp index 27e01a0f..9f8928f0 100644 --- a/tests2/mat_mul_real.cpp +++ b/tests2/mat_mul_real.cpp @@ -84,12 +84,12 @@ TEST_CASE("mat_mul_real_1") -0.0182371 -0.0207407 -0.0522859 -0.0485276 0.0678171;\ "; - REQUIRE( accu(abs( (A00*B00) - A00_times_B00 )) == Approx(0.0) ); - REQUIRE( accu(abs( (A11*B11) - A11_times_B11 )) == Approx(0.0) ); - REQUIRE( accu(abs( (A22*B22) - A22_times_B22 )) == Approx(0.0) ); - REQUIRE( accu(abs( (A33*B33) - A33_times_B33 )) == Approx(0.0) ); - REQUIRE( accu(abs( (A44*B44) - A44_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( (A55*B55) - A55_times_B55 )) == Approx(0.0) ); + REQUIRE( accu(abs( (A00*B00) - A00_times_B00 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A11*B11) - A11_times_B11 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A22*B22) - A22_times_B22 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A33*B33) - A33_times_B33 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A44*B44) - A44_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A55*B55) - A55_times_B55 )) == Approx(0.0).margin(0.001) ); mat X; REQUIRE_THROWS( X = A22*B44 ); @@ -202,19 +202,19 @@ TEST_CASE("mat_mul_real_2") 0.245991 -0.060162 -0.208409 -0.293470 -0.151911;\ "; - REQUIRE( accu(abs( (A00*q0) - A00_times_q0 )) == Approx(0.0) ); - REQUIRE( accu(abs( (A11*q1) - A11_times_q1 )) == Approx(0.0) ); - REQUIRE( accu(abs( (A22*q2) - A22_times_q2 )) == Approx(0.0) ); - REQUIRE( accu(abs( (A33*q3) - A33_times_q3 )) == Approx(0.0) ); - REQUIRE( accu(abs( (A44*q4) - A44_times_q4 )) == Approx(0.0) ); - REQUIRE( accu(abs( (A55*q5) - A55_times_q5 )) == Approx(0.0) ); + REQUIRE( accu(abs( (A00*q0) - A00_times_q0 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A11*q1) - A11_times_q1 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A22*q2) - A22_times_q2 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A33*q3) - A33_times_q3 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A44*q4) - A44_times_q4 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A55*q5) - A55_times_q5 )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (r0*A00) - r0_times_A00 )) == Approx(0.0) ); - REQUIRE( accu(abs( (r1*A11) - r1_times_A11 )) == Approx(0.0) ); - REQUIRE( accu(abs( (r2*A22) - r2_times_A22 )) == Approx(0.0) ); - REQUIRE( accu(abs( (r3*A33) - r3_times_A33 )) == Approx(0.0) ); - REQUIRE( accu(abs( (r4*A44) - r4_times_A44 )) == Approx(0.0) ); - REQUIRE( accu(abs( (r5*A55) - r5_times_A55 )) == Approx(0.0) ); + REQUIRE( accu(abs( (r0*A00) - r0_times_A00 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (r1*A11) - r1_times_A11 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (r2*A22) - r2_times_A22 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (r3*A33) - r3_times_A33 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (r4*A44) - r4_times_A44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (r5*A55) - r5_times_A55 )) == Approx(0.0).margin(0.001) ); mat X; REQUIRE_THROWS( X = A22*q4 ); @@ -327,33 +327,33 @@ TEST_CASE("mat_mul_real_3") 0.190504;\ "; - REQUIRE( accu(abs( (q0.t()*A00) - q0_t_times_A00 )) == Approx(0.0) ); - REQUIRE( accu(abs( (q1.t()*A11) - q1_t_times_A11 )) == Approx(0.0) ); - REQUIRE( accu(abs( (q2.t()*A22) - q2_t_times_A22 )) == Approx(0.0) ); - REQUIRE( accu(abs( (q3.t()*A33) - q3_t_times_A33 )) == Approx(0.0) ); - REQUIRE( accu(abs( (q4.t()*A44) - q4_t_times_A44 )) == Approx(0.0) ); - REQUIRE( accu(abs( (q5.t()*A55) - q5_t_times_A55 )) == Approx(0.0) ); + REQUIRE( accu(abs( (q0.t()*A00) - q0_t_times_A00 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (q1.t()*A11) - q1_t_times_A11 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (q2.t()*A22) - q2_t_times_A22 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (q3.t()*A33) - q3_t_times_A33 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (q4.t()*A44) - q4_t_times_A44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (q5.t()*A55) - q5_t_times_A55 )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (A00*r0.t()) - A00_times_r0_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (A11*r1.t()) - A11_times_r1_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (A22*r2.t()) - A22_times_r2_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (A33*r3.t()) - A33_times_r3_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (A44*r4.t()) - A44_times_r4_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (A55*r5.t()) - A55_times_r5_t )) == Approx(0.0) ); + REQUIRE( accu(abs( (A00*r0.t()) - A00_times_r0_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A11*r1.t()) - A11_times_r1_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A22*r2.t()) - A22_times_r2_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A33*r3.t()) - A33_times_r3_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A44*r4.t()) - A44_times_r4_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A55*r5.t()) - A55_times_r5_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (q0.t().eval()*A00) - q0_t_times_A00 )) == Approx(0.0) ); - REQUIRE( accu(abs( (q1.t().eval()*A11) - q1_t_times_A11 )) == Approx(0.0) ); - REQUIRE( accu(abs( (q2.t().eval()*A22) - q2_t_times_A22 )) == Approx(0.0) ); - REQUIRE( accu(abs( (q3.t().eval()*A33) - q3_t_times_A33 )) == Approx(0.0) ); - REQUIRE( accu(abs( (q4.t().eval()*A44) - q4_t_times_A44 )) == Approx(0.0) ); - REQUIRE( accu(abs( (q5.t().eval()*A55) - q5_t_times_A55 )) == Approx(0.0) ); + REQUIRE( accu(abs( (q0.t().eval()*A00) - q0_t_times_A00 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (q1.t().eval()*A11) - q1_t_times_A11 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (q2.t().eval()*A22) - q2_t_times_A22 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (q3.t().eval()*A33) - q3_t_times_A33 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (q4.t().eval()*A44) - q4_t_times_A44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (q5.t().eval()*A55) - q5_t_times_A55 )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (A00*r0.t().eval()) - A00_times_r0_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (A11*r1.t().eval()) - A11_times_r1_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (A22*r2.t().eval()) - A22_times_r2_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (A33*r3.t().eval()) - A33_times_r3_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (A44*r4.t().eval()) - A44_times_r4_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (A55*r5.t().eval()) - A55_times_r5_t )) == Approx(0.0) ); + REQUIRE( accu(abs( (A00*r0.t().eval()) - A00_times_r0_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A11*r1.t().eval()) - A11_times_r1_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A22*r2.t().eval()) - A22_times_r2_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A33*r3.t().eval()) - A33_times_r3_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A44*r4.t().eval()) - A44_times_r4_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A55*r5.t().eval()) - A55_times_r5_t )) == Approx(0.0).margin(0.001) ); mat X; REQUIRE_THROWS( X = A22*r4.t() ); @@ -516,46 +516,46 @@ TEST_CASE("mat_mul_real_4") // - REQUIRE( accu(abs( A44 * B44 - A44_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( A44.t() * B44 - A44_t_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( A44 * B44.t() - A44_times_B44_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A44.t() * B44.t() - A44_t_times_B44_t )) == Approx(0.0) ); + REQUIRE( accu(abs( A44 * B44 - A44_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44.t() * B44 - A44_t_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44 * B44.t() - A44_times_B44_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44.t() * B44.t() - A44_t_times_B44_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*A44 * B44 - two_times_A44_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A44.t() * B44 - two_times_A44_t_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A44 * B44.t() - two_times_A44_times_B44_t )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A44.t() * B44.t() - two_times_A44_t_times_B44_t )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*A44 * B44 - two_times_A44_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A44.t() * B44 - two_times_A44_t_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A44 * B44.t() - two_times_A44_times_B44_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A44.t() * B44.t() - two_times_A44_t_times_B44_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( A44 * 2 * B44 - A44_times_two_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( A44.t() * 2 * B44 - A44_t_times_two_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( A44 * 2 * B44.t() - A44_times_two_times_B44_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A44.t() * 2 * B44.t() - A44_t_times_two_times_B44_t )) == Approx(0.0) ); + REQUIRE( accu(abs( A44 * 2 * B44 - A44_times_two_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44.t() * 2 * B44 - A44_t_times_two_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44 * 2 * B44.t() - A44_times_two_times_B44_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44.t() * 2 * B44.t() - A44_t_times_two_times_B44_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*A44 * 2*B44 - two_times_A44_times_two_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A44.t() * 2*B44 - two_times_A44_t_times_two_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A44 * 2*B44.t() - two_times_A44_times_two_times_B44_t )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A44.t() * 2*B44.t() - two_times_A44_t_times_two_times_B44_t )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*A44 * 2*B44 - two_times_A44_times_two_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A44.t() * 2*B44 - two_times_A44_t_times_two_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A44 * 2*B44.t() - two_times_A44_times_two_times_B44_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A44.t() * 2*B44.t() - two_times_A44_t_times_two_times_B44_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( A44 * B44 - A44_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( A44.t().eval() * B44 - A44_t_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( A44 * B44.t().eval() - A44_times_B44_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A44.t() * B44.t().eval() - A44_t_times_B44_t )) == Approx(0.0) ); + REQUIRE( accu(abs( A44 * B44 - A44_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44.t().eval() * B44 - A44_t_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44 * B44.t().eval() - A44_times_B44_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44.t() * B44.t().eval() - A44_t_times_B44_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (2*A44).eval() * B44 - two_times_A44_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A44.t()).eval() * B44 - two_times_A44_t_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A44).eval() * B44.t().eval() - two_times_A44_times_B44_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A44.t()).eval() * B44.t().eval() - two_times_A44_t_times_B44_t )) == Approx(0.0) ); + REQUIRE( accu(abs( (2*A44).eval() * B44 - two_times_A44_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A44.t()).eval() * B44 - two_times_A44_t_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A44).eval() * B44.t().eval() - two_times_A44_times_B44_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A44.t()).eval() * B44.t().eval() - two_times_A44_t_times_B44_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( A44 * (2 * B44).eval() - A44_times_two_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( A44.t().eval() * (2 * B44).eval() - A44_t_times_two_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( A44 * (2 * B44.t()).eval() - A44_times_two_times_B44_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A44.t().eval() * (2 * B44.t()).eval() - A44_t_times_two_times_B44_t )) == Approx(0.0) ); + REQUIRE( accu(abs( A44 * (2 * B44).eval() - A44_times_two_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44.t().eval() * (2 * B44).eval() - A44_t_times_two_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44 * (2 * B44.t()).eval() - A44_times_two_times_B44_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A44.t().eval() * (2 * B44.t()).eval() - A44_t_times_two_times_B44_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (2*A44).eval() * (2*B44).eval() - two_times_A44_times_two_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A44.t()).eval() * (2*B44).eval() - two_times_A44_t_times_two_times_B44 )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A44).eval() * (2*B44.t()).eval() - two_times_A44_times_two_times_B44_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A44.t()).eval() * (2*B44.t()).eval() - two_times_A44_t_times_two_times_B44_t )) == Approx(0.0) ); + REQUIRE( accu(abs( (2*A44).eval() * (2*B44).eval() - two_times_A44_times_two_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A44.t()).eval() * (2*B44).eval() - two_times_A44_t_times_two_times_B44 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A44).eval() * (2*B44.t()).eval() - two_times_A44_times_two_times_B44_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A44.t()).eval() * (2*B44.t()).eval() - two_times_A44_t_times_two_times_B44_t )) == Approx(0.0).margin(0.001) ); } @@ -730,47 +730,47 @@ TEST_CASE("mat_mul_real_5") // - REQUIRE( accu(abs( A55 * B55 - A55_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( A55.t() * B55 - A55_t_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( A55 * B55.t() - A55_times_B55_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A55.t() * B55.t() - A55_t_times_B55_t )) == Approx(0.0) ); + REQUIRE( accu(abs( A55 * B55 - A55_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55.t() * B55 - A55_t_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55 * B55.t() - A55_times_B55_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55.t() * B55.t() - A55_t_times_B55_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*A55 * B55 - two_times_A55_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A55.t() * B55 - two_times_A55_t_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A55 * B55.t() - two_times_A55_times_B55_t )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A55.t() * B55.t() - two_times_A55_t_times_B55_t )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*A55 * B55 - two_times_A55_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A55.t() * B55 - two_times_A55_t_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A55 * B55.t() - two_times_A55_times_B55_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A55.t() * B55.t() - two_times_A55_t_times_B55_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( A55 * 2 * B55 - A55_times_two_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( A55.t() * 2 * B55 - A55_t_times_two_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( A55 * 2 * B55.t() - A55_times_two_times_B55_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A55.t() * 2 * B55.t() - A55_t_times_two_times_B55_t )) == Approx(0.0) ); + REQUIRE( accu(abs( A55 * 2 * B55 - A55_times_two_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55.t() * 2 * B55 - A55_t_times_two_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55 * 2 * B55.t() - A55_times_two_times_B55_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55.t() * 2 * B55.t() - A55_t_times_two_times_B55_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*A55 * 2*B55 - two_times_A55_times_two_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A55.t() * 2*B55 - two_times_A55_t_times_two_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A55 * 2*B55.t() - two_times_A55_times_two_times_B55_t )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A55.t() * 2*B55.t() - two_times_A55_t_times_two_times_B55_t )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*A55 * 2*B55 - two_times_A55_times_two_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A55.t() * 2*B55 - two_times_A55_t_times_two_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A55 * 2*B55.t() - two_times_A55_times_two_times_B55_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A55.t() * 2*B55.t() - two_times_A55_t_times_two_times_B55_t )) == Approx(0.0).margin(0.001) ); // - REQUIRE( accu(abs( A55 * B55 - A55_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( A55.t().eval() * B55 - A55_t_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( A55 * B55.t().eval() - A55_times_B55_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A55.t().eval() * B55.t().eval() - A55_t_times_B55_t )) == Approx(0.0) ); + REQUIRE( accu(abs( A55 * B55 - A55_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55.t().eval() * B55 - A55_t_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55 * B55.t().eval() - A55_times_B55_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55.t().eval() * B55.t().eval() - A55_t_times_B55_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (2*A55).eval() * B55 - two_times_A55_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A55.t()).eval() * B55 - two_times_A55_t_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A55).eval() * B55.t().eval() - two_times_A55_times_B55_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A55.t()).eval() * B55.t().eval() - two_times_A55_t_times_B55_t )) == Approx(0.0) ); + REQUIRE( accu(abs( (2*A55).eval() * B55 - two_times_A55_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A55.t()).eval() * B55 - two_times_A55_t_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A55).eval() * B55.t().eval() - two_times_A55_times_B55_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A55.t()).eval() * B55.t().eval() - two_times_A55_t_times_B55_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( A55 * (2 * B55).eval() - A55_times_two_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( A55.t().eval() * (2 * B55).eval() - A55_t_times_two_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( A55 * (2 * B55.t()).eval() - A55_times_two_times_B55_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A55.t().eval() * (2 * B55.t()).eval() - A55_t_times_two_times_B55_t )) == Approx(0.0) ); + REQUIRE( accu(abs( A55 * (2 * B55).eval() - A55_times_two_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55.t().eval() * (2 * B55).eval() - A55_t_times_two_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55 * (2 * B55.t()).eval() - A55_times_two_times_B55_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A55.t().eval() * (2 * B55.t()).eval() - A55_t_times_two_times_B55_t )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( (2*A55).eval() * (2*B55).eval() - two_times_A55_times_two_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A55.t()).eval() * (2*B55).eval() - two_times_A55_t_times_two_times_B55 )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A55).eval() * (2*B55.t()).eval() - two_times_A55_times_two_times_B55_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A55.t()).eval() * (2*B55.t()).eval() - two_times_A55_t_times_two_times_B55_t )) == Approx(0.0) ); + REQUIRE( accu(abs( (2*A55).eval() * (2*B55).eval() - two_times_A55_times_two_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A55.t()).eval() * (2*B55).eval() - two_times_A55_t_times_two_times_B55 )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A55).eval() * (2*B55.t()).eval() - two_times_A55_times_two_times_B55_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A55.t()).eval() * (2*B55.t()).eval() - two_times_A55_t_times_two_times_B55_t )) == Approx(0.0).margin(0.001) ); } @@ -874,53 +874,53 @@ TEST_CASE("mat_mul_real_6") // - REQUIRE( accu(abs( A*B.t() - A_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A.t()*B - A_t_times_B )) == Approx(0.0) ); + REQUIRE( accu(abs( A*B.t() - A_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A.t()*B - A_t_times_B )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*A*B.t() - two_times_A_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A)*B.t() - two_times_A_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A.t()*B - two_times_A_t_times_B )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A).t()*B - two_times_A_t_times_B )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*A*B.t() - two_times_A_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A)*B.t() - two_times_A_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A.t()*B - two_times_A_t_times_B )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A).t()*B - two_times_A_t_times_B )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( A*2*B.t() - A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A*(2*B).t() - A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A.t()*2*B - A_t_times_two_times_B )) == Approx(0.0) ); - REQUIRE( accu(abs( A.t()*(2*B) - A_t_times_two_times_B )) == Approx(0.0) ); + REQUIRE( accu(abs( A*2*B.t() - A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A*(2*B).t() - A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A.t()*2*B - A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A.t()*(2*B) - A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*A*2*B.t() - two_times_A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A)*2*B.t() - two_times_A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A.t()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A).t()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*A*2*B.t() - two_times_A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A)*2*B.t() - two_times_A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A.t()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A).t()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*A*(2*B).t() - two_times_A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A)*(2*B).t() - two_times_A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A.t()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A).t()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*A*(2*B).t() - two_times_A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A)*(2*B).t() - two_times_A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A.t()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A).t()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); // - REQUIRE( accu(abs( A*B.t().eval() - A_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A.t().eval()*B - A_t_times_B )) == Approx(0.0) ); + REQUIRE( accu(abs( A*B.t().eval() - A_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A.t().eval()*B - A_t_times_B )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*A*B.t().eval() - two_times_A_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A)*B.t().eval() - two_times_A_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A.t()).eval()*B - two_times_A_t_times_B )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A).t().eval()*B - two_times_A_t_times_B )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*A*B.t().eval() - two_times_A_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A)*B.t().eval() - two_times_A_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A.t()).eval()*B - two_times_A_t_times_B )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A).t().eval()*B - two_times_A_t_times_B )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( A*2*(B.t().eval()) - A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A*(2*B).t().eval() - A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( A.t().eval()*2*B - A_t_times_two_times_B )) == Approx(0.0) ); - REQUIRE( accu(abs( A.t().eval()*(2*B).eval() - A_t_times_two_times_B )) == Approx(0.0) ); + REQUIRE( accu(abs( A*2*(B.t().eval()) - A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A*(2*B).t().eval() - A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A.t().eval()*2*B - A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( A.t().eval()*(2*B).eval() - A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*A*2*(B.t()).eval() - two_times_A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A)*(2*B.t()).eval() - two_times_A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A.t().eval()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A).t().eval()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*A*2*(B.t()).eval() - two_times_A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A)*(2*B.t()).eval() - two_times_A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A.t().eval()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A).t().eval()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*A*(2*B).t().eval() - two_times_A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A)*(2*B).t().eval() - two_times_A_times_two_times_B_t )) == Approx(0.0) ); - REQUIRE( accu(abs( 2*A.t().eval()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0) ); - REQUIRE( accu(abs( (2*A).t().eval()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*A*(2*B).t().eval() - two_times_A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A)*(2*B).t().eval() - two_times_A_times_two_times_B_t )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( 2*A.t().eval()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (2*A).t().eval()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0).margin(0.001) ); } diff --git a/tests2/mat_neg.cpp b/tests2/mat_neg.cpp index bea7afe5..0e9fe467 100644 --- a/tests2/mat_neg.cpp +++ b/tests2/mat_neg.cpp @@ -51,7 +51,7 @@ TEST_CASE("mat_neg_1") REQUIRE( B(3,5) == Approx(-0.373833) ); REQUIRE( B(4,5) == Approx(-0.258704) ); - REQUIRE( accu(B + A) == Approx(0.0) ); + REQUIRE( accu(B + A) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } diff --git a/tests2/mat_plus.cpp b/tests2/mat_plus.cpp index 9a6ee043..9ead3e2b 100644 --- a/tests2/mat_plus.cpp +++ b/tests2/mat_plus.cpp @@ -84,10 +84,10 @@ TEST_CASE("mat_plus_1") REQUIRE( Y(4,5) == Approx( 0.498289) ); - REQUIRE( accu(abs( mat(A+B) - A_plus_B )) == Approx(0.0) ); - REQUIRE( accu(abs( (A+B) - A_plus_B )) == Approx(0.0) ); + REQUIRE( accu(abs( mat(A+B) - A_plus_B )) == Approx(0.0).margin(0.001) ); + REQUIRE( accu(abs( (A+B) - A_plus_B )) == Approx(0.0).margin(0.001) ); - REQUIRE( accu(abs( 2*(A+B) - 2*A_plus_B )) == Approx(0.0) ); + REQUIRE( accu(abs( 2*(A+B) - 2*A_plus_B )) == Approx(0.0).margin(0.001) ); // REQUIRE_THROWS( ); } diff --git a/tests2/spmat.cpp b/tests2/spmat.cpp index 11408ca8..c06ae0d4 100644 --- a/tests2/spmat.cpp +++ b/tests2/spmat.cpp @@ -209,7 +209,7 @@ TEST_CASE("division_test") REQUIRE( std::isnan((double) a(0, 0)) ); REQUIRE( (double) a(0, 1) == Approx(0.5) ); - REQUIRE( (double) a(1, 0) == Approx(1e-5) ); + REQUIRE( (double) a(1, 0) == Approx(0.0).margin(0.001) ); REQUIRE( std::isnan((double) a(1, 1)) ); } @@ -953,7 +953,7 @@ TEST_CASE("sp_mat_eye_test") if (i == j) REQUIRE( (double) e(i, j) == Approx(1.0) ); else - REQUIRE( (double) e(i, j) == Approx(1e-5) ); + REQUIRE( (double) e(i, j) == Approx(0.0).margin(0.001) ); } } @@ -1217,7 +1217,7 @@ TEST_CASE("min_test") a(2) = 1.0; double res = min(a); - REQUIRE( res == Approx(1e-5) ); + REQUIRE( res == Approx(0.0).margin(0.001) ); a(0) = -3.0; a(2) = -1.0; @@ -1240,7 +1240,7 @@ TEST_CASE("min_test") b(2) = 1.0; res = min(b); - REQUIRE( res == Approx(1e-5) ); + REQUIRE( res == Approx(0.0).margin(0.001) ); b(0) = -3.0; b(2) = -1.0; @@ -1275,18 +1275,18 @@ TEST_CASE("min_test") REQUIRE( r.n_rows == 1 ); REQUIRE( r.n_cols == 5 ); REQUIRE( (double) r(0, 0) == Approx(0.6) ); - REQUIRE( (double) r(0, 1) == Approx(1e-5) ); + REQUIRE( (double) r(0, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) r(0, 2) == Approx(-3.4) ); REQUIRE( (double) r(0, 3) == Approx(-4.1) ); - REQUIRE( (double) r(0, 4) == Approx(1e-5) ); + REQUIRE( (double) r(0, 4) == Approx(0.0).margin(0.001) ); r = min(c, 1); REQUIRE( r.n_rows == 6 ); REQUIRE( r.n_cols == 1 ); - REQUIRE( (double) r(0, 0) == Approx(1e-5) ); - REQUIRE( (double) r(1, 0) == Approx(1e-5) ); + REQUIRE( (double) r(0, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) r(1, 0) == Approx(0.0).margin(0.001) ); REQUIRE( (double) r(2, 0) == Approx(-4.0) ); - REQUIRE( (double) r(3, 0) == Approx(1e-5) ); + REQUIRE( (double) r(3, 0) == Approx(0.0).margin(0.001) ); REQUIRE( (double) r(4, 0) == Approx(-1.4) ); REQUIRE( (double) r(5, 0) == Approx(-4.1) ); } @@ -1300,7 +1300,7 @@ TEST_CASE("max_test") a(2) = -1.0; double resa = max(a); - REQUIRE( resa == Approx(1e-5) ); + REQUIRE( resa == Approx(0.0).margin(0.001) ); a(0) = 3.0; a(2) = 1.0; @@ -1323,7 +1323,7 @@ TEST_CASE("max_test") b(2) = -1.0; resa = max(b); - REQUIRE( resa == Approx(1e-5) ); + REQUIRE( resa == Approx(0.0).margin(0.001) ); b(0) = 3.0; b(2) = 1.0; @@ -1358,10 +1358,10 @@ TEST_CASE("max_test") REQUIRE( res.n_rows == 1 ); REQUIRE( res.n_cols == 5 ); REQUIRE( (double) res(0, 0) == Approx(4.0) ); - REQUIRE( (double) res(0, 1) == Approx(1e-5) ); + REQUIRE( (double) res(0, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) res(0, 2) == Approx(1.3) ); - REQUIRE( (double) res(0, 3) == Approx(1e-5) ); - REQUIRE( (double) res(0, 4) == Approx(1e-5) ); + REQUIRE( (double) res(0, 3) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) res(0, 4) == Approx(0.0).margin(0.001) ); res = max(c, 1); REQUIRE( res.n_rows == 6 ); @@ -1370,7 +1370,7 @@ TEST_CASE("max_test") REQUIRE( (double) res(1, 0) == Approx(3.0) ); REQUIRE( (double) res(2, 0) == Approx(4.0) ); REQUIRE( (double) res(3, 0) == Approx(1.3) ); - REQUIRE( (double) res(4, 0) == Approx(1e-5) ); + REQUIRE( (double) res(4, 0) == Approx(0.0).margin(0.001) ); REQUIRE( (double) res(5, 0) == Approx(1.2) ); } @@ -1383,15 +1383,15 @@ TEST_CASE("spmat_min_cx_test") a(2) = cx_double(1.0, 1.0); cx_double res = min(a); - REQUIRE( res.real() == Approx(1e-5) ); - REQUIRE( res.imag() == Approx(1e-5) ); + REQUIRE( res.real() == Approx(0.0).margin(0.001) ); + REQUIRE( res.imag() == Approx(0.0).margin(0.001) ); a(0) = cx_double(-3.0, -2.0); a(2) = cx_double(-1.0, -1.0); res = min(a); - REQUIRE( res.real() == Approx(1e-5) ); - REQUIRE( res.imag() == Approx(1e-5) ); + REQUIRE( res.real() == Approx(0.0).margin(0.001) ); + REQUIRE( res.imag() == Approx(0.0).margin(0.001) ); a(0) = cx_double(1.0, 0.5); a(1) = cx_double(2.4, 1.4); @@ -1409,15 +1409,15 @@ TEST_CASE("spmat_min_cx_test") b(2) = cx_double(1.0, 1.0); res = min(b); - REQUIRE( res.real() == Approx(1e-5) ); - REQUIRE( res.imag() == Approx(1e-5) ); + REQUIRE( res.real() == Approx(0.0).margin(0.001) ); + REQUIRE( res.imag() == Approx(0.0).margin(0.001) ); b(0) = cx_double(-3.0, -2.0); b(2) = cx_double(-1.0, -1.0); res = min(b); - REQUIRE( res.real() == Approx(1e-5) ); - REQUIRE( res.imag() == Approx(1e-5) ); + REQUIRE( res.real() == Approx(0.0).margin(0.001) ); + REQUIRE( res.imag() == Approx(0.0).margin(0.001) ); b(0) = cx_double(1.0, 0.5); b(1) = cx_double(2.4, 1.4); @@ -1441,24 +1441,24 @@ TEST_CASE("spmat_min_cx_test") SpMat r = min(c, 0); REQUIRE( r.n_rows == 1 ); REQUIRE( r.n_cols == 3 ); - REQUIRE( ((cx_double) r(0, 0)).real() == Approx(1e-5) ); - REQUIRE( ((cx_double) r(0, 0)).imag() == Approx(1e-5) ); + REQUIRE( ((cx_double) r(0, 0)).real() == Approx(0.0).margin(0.001) ); + REQUIRE( ((cx_double) r(0, 0)).imag() == Approx(0.0).margin(0.001) ); REQUIRE( ((cx_double) r(0, 1)).real() == Approx(0.25) ); REQUIRE( ((cx_double) r(0, 1)).imag() == Approx(0.25) ); - REQUIRE( ((cx_double) r(0, 2)).real() == Approx(1e-5) ); - REQUIRE( ((cx_double) r(0, 2)).imag() == Approx(1e-5) ); + REQUIRE( ((cx_double) r(0, 2)).real() == Approx(0.0).margin(0.001) ); + REQUIRE( ((cx_double) r(0, 2)).imag() == Approx(0.0).margin(0.001) ); r = min(c, 1); REQUIRE( r.n_rows == 4 ); REQUIRE( r.n_cols == 1 ); REQUIRE( ((cx_double) r(0, 0)).real() == Approx(0.5) ); REQUIRE( ((cx_double) r(0, 0)).imag() == Approx(0.5) ); - REQUIRE( ((cx_double) r(1, 0)).real() == Approx(1e-5) ); - REQUIRE( ((cx_double) r(1, 0)).imag() == Approx(1e-5) ); - REQUIRE( ((cx_double) r(2, 0)).real() == Approx(1e-5) ); - REQUIRE( ((cx_double) r(2, 0)).imag() == Approx(1e-5) ); - REQUIRE( ((cx_double) r(3, 0)).real() == Approx(1e-5) ); - REQUIRE( ((cx_double) r(3, 0)).imag() == Approx(1e-5) ); + REQUIRE( ((cx_double) r(1, 0)).real() == Approx(0.0).margin(0.001) ); + REQUIRE( ((cx_double) r(1, 0)).imag() == Approx(0.0).margin(0.001) ); + REQUIRE( ((cx_double) r(2, 0)).real() == Approx(0.0).margin(0.001) ); + REQUIRE( ((cx_double) r(2, 0)).imag() == Approx(0.0).margin(0.001) ); + REQUIRE( ((cx_double) r(3, 0)).real() == Approx(0.0).margin(0.001) ); + REQUIRE( ((cx_double) r(3, 0)).imag() == Approx(0.0).margin(0.001) ); } @@ -1478,8 +1478,8 @@ TEST_CASE("spmat_max_cx_test") a(2) = cx_double(0); res = max(a); - REQUIRE( res.real() == Approx(1e-5) ); - REQUIRE( res.imag() == Approx(1e-5) ); + REQUIRE( res.real() == Approx(0.0).margin(0.001) ); + REQUIRE( res.imag() == Approx(0.0).margin(0.001) ); a(0) = cx_double(1.0, 0.5); a(1) = cx_double(2.4, 1.4); @@ -1504,8 +1504,8 @@ TEST_CASE("spmat_max_cx_test") b(2) = cx_double(0); res = max(b); - REQUIRE( res.real() == Approx(1e-5) ); - REQUIRE( res.imag() == Approx(1e-5) ); + REQUIRE( res.real() == Approx(0.0).margin(0.001) ); + REQUIRE( res.imag() == Approx(0.0).margin(0.001) ); b(0) = cx_double(1.0, 0.5); b(1) = cx_double(2.4, 1.4); @@ -1532,8 +1532,8 @@ TEST_CASE("spmat_max_cx_test") REQUIRE( ((cx_double) r(0, 0)).imag() == Approx(2.0) ); REQUIRE( ((cx_double) r(0, 1)).real() == Approx(-3.0) ); REQUIRE( ((cx_double) r(0, 1)).imag() == Approx(-3.0) ); - REQUIRE( ((cx_double) r(0, 2)).real() == Approx(1e-5) ); - REQUIRE( ((cx_double) r(0, 2)).imag() == Approx(1e-5) ); + REQUIRE( ((cx_double) r(0, 2)).real() == Approx(0.0).margin(0.001) ); + REQUIRE( ((cx_double) r(0, 2)).imag() == Approx(0.0).margin(0.001) ); r = max(c, 1); REQUIRE( r.n_rows == 4 ); @@ -1690,16 +1690,16 @@ TEST_CASE("spmat_unary_val_operators_test") REQUIRE( b.n_nonzero == 2 ); REQUIRE( (double) b(0, 0) == Approx(6.0) ); - REQUIRE( (double) b(0, 1) == Approx(1e-5) ); - REQUIRE( (double) b(1, 0) == Approx(1e-5) ); + REQUIRE( (double) b(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(1, 0) == Approx(0.0).margin(0.001) ); REQUIRE( (double) b(1, 1) == Approx(-9.0) ); b = a / 3.0; REQUIRE( b.n_nonzero == 2 ); REQUIRE( (double) b(0, 0) == Approx(2.0 / 3.0) ); - REQUIRE( (double) b(0, 1) == Approx(1e-5) ); - REQUIRE( (double) b(1, 0) == Approx(1e-5) ); + REQUIRE( (double) b(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(1, 0) == Approx(0.0).margin(0.001) ); REQUIRE( (double) b(1, 1) == Approx(-1.0) ); } @@ -1792,7 +1792,7 @@ TEST_CASE("spmat_unary_operator_test_2") REQUIRE( c(2, 1) == Approx(3.0) ); REQUIRE( c(0, 2) == Approx(6.5) ); REQUIRE( c(1, 2) == Approx(7.0) ); - REQUIRE( c(2, 2) == Approx(1e-5) ); + REQUIRE( c(2, 2) == Approx(0.0).margin(0.001) ); c = a - b; @@ -1810,11 +1810,11 @@ TEST_CASE("spmat_unary_operator_test_2") REQUIRE( d.n_nonzero == 4 ); REQUIRE( (double) d(0, 0) == Approx(3.0) ); - REQUIRE( (double) d(1, 0) == Approx(1e-5) ); - REQUIRE( (double) d(2, 0) == Approx(1e-5) ); - REQUIRE( (double) d(0, 1) == Approx(1e-5) ); - REQUIRE( (double) d(1, 1) == Approx(1e-5) ); - REQUIRE( (double) d(2, 1) == Approx(1e-5) ); + REQUIRE( (double) d(1, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) d(2, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) d(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) d(1, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) d(2, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) d(0, 2) == Approx(10.5) ); REQUIRE( (double) d(1, 2) == Approx(12.0) ); REQUIRE( (double) d(2, 2) == Approx(-9.0) ); @@ -1823,11 +1823,11 @@ TEST_CASE("spmat_unary_operator_test_2") REQUIRE( d.n_nonzero == 4 ); REQUIRE( (double) d(0, 0) == Approx((1.0 / 3.0)) ); - REQUIRE( (double) d(1, 0) == Approx(1e-5) ); - REQUIRE( (double) d(2, 0) == Approx(1e-5) ); - REQUIRE( (double) d(0, 1) == Approx(1e-5) ); - REQUIRE( (double) d(1, 1) == Approx(1e-5) ); - REQUIRE( (double) d(2, 1) == Approx(1e-5) ); + REQUIRE( (double) d(1, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) d(2, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) d(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) d(1, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) d(2, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) d(0, 2) == Approx((3.5 / 3.0)) ); REQUIRE( (double) d(1, 2) == Approx((4.0 / 3.0)) ); REQUIRE( (double) d(2, 2) == Approx(-1.0) ); @@ -1849,9 +1849,9 @@ TEST_CASE("spmat_unary_operator_test_2") REQUIRE( (double) c(0, 0) == Approx(3.0) ); REQUIRE( (double) c(1, 0) == Approx(3.0) ); REQUIRE( (double) c(2, 0) == Approx(3.0) ); - REQUIRE( (double) c(0, 1) == Approx(1e-5) ); - REQUIRE( (double) c(1, 1) == Approx(1e-5) ); - REQUIRE( (double) c(2, 1) == Approx(1e-5) ); + REQUIRE( (double) c(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(1, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(2, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(0, 2) == Approx(13.5) ); REQUIRE( (double) c(1, 2) == Approx(13.5) ); REQUIRE( (double) c(2, 2) == Approx(13.5) ); @@ -1879,7 +1879,7 @@ TEST_CASE("spmat_mat_operator_tests") REQUIRE( (double) c(2, 0) == Approx(2.0) ); REQUIRE( (double) c(0, 1) == Approx(2.0) ); REQUIRE( (double) c(1, 1) == Approx(2.0) ); - REQUIRE( (double) c(2, 1) == Approx(1e-5) ); + REQUIRE( (double) c(2, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(0, 2) == Approx(2.0) ); REQUIRE( (double) c(1, 2) == Approx(5.5) ); REQUIRE( (double) c(2, 2) == Approx(6.5) ); @@ -1891,7 +1891,7 @@ TEST_CASE("spmat_mat_operator_tests") REQUIRE( (double) c(2, 0) == Approx(2.0) ); REQUIRE( (double) c(0, 1) == Approx(2.0) ); REQUIRE( (double) c(1, 1) == Approx(2.0) ); - REQUIRE( (double) c(2, 1) == Approx(1e-5) ); + REQUIRE( (double) c(2, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(0, 2) == Approx(2.0) ); REQUIRE( (double) c(1, 2) == Approx(5.5) ); REQUIRE( (double) c(2, 2) == Approx(6.5) ); @@ -1899,7 +1899,7 @@ TEST_CASE("spmat_mat_operator_tests") c = b; c -= a; - REQUIRE( (double) c(0, 0) == Approx(1e-5) ); + REQUIRE( (double) c(0, 0) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(1, 0) == Approx(2.0) ); REQUIRE( (double) c(2, 0) == Approx(2.0) ); REQUIRE( (double) c(0, 1) == Approx(2.0) ); @@ -1911,7 +1911,7 @@ TEST_CASE("spmat_mat_operator_tests") c = b - a; - REQUIRE( (double) c(0, 0) == Approx(1e-5) ); + REQUIRE( (double) c(0, 0) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(1, 0) == Approx(2.0) ); REQUIRE( (double) c(2, 0) == Approx(2.0) ); REQUIRE( (double) c(0, 1) == Approx(2.0) ); @@ -1950,12 +1950,12 @@ TEST_CASE("spmat_mat_operator_tests") c %= a; REQUIRE( (double) c(0, 0) == Approx(4.0) ); - REQUIRE( (double) c(1, 0) == Approx(1e-5) ); - REQUIRE( (double) c(2, 0) == Approx(1e-5) ); - REQUIRE( (double) c(0, 1) == Approx(1e-5) ); - REQUIRE( (double) c(1, 1) == Approx(1e-5) ); + REQUIRE( (double) c(1, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(2, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(1, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(2, 1) == Approx(-4.0) ); - REQUIRE( (double) c(0, 2) == Approx(1e-5) ); + REQUIRE( (double) c(0, 2) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(1, 2) == Approx(7.0) ); REQUIRE( (double) c(2, 2) == Approx(9.0) ); @@ -2010,7 +2010,7 @@ TEST_CASE("spmat_sparse_dense_in_place") if ((double) a(r, c) != 0) REQUIRE( (double) a(r, c) == Approx(d(r, c)) ); else - REQUIRE( d(r, c) == Approx(1e-5) ); + REQUIRE( d(r, c) == Approx(0.0).margin(0.001) ); } } @@ -2030,7 +2030,7 @@ TEST_CASE("spmat_sparse_dense_in_place") if ((double) a(r, c) != 0) REQUIRE( (double) a(r, c) == Approx(d(r, c)) ); else - REQUIRE( d(r, c) == Approx(1e-5) ); + REQUIRE( d(r, c) == Approx(0.0).margin(0.001) ); } } @@ -2047,7 +2047,7 @@ TEST_CASE("spmat_sparse_dense_in_place") if ((double) a(r, c) != 0) REQUIRE( (double) a(r, c) == Approx(d(r, c)) ); else - REQUIRE( d(r, c) == Approx(1e-5) ); + REQUIRE( d(r, c) == Approx(0.0).margin(0.001) ); } } @@ -2064,7 +2064,7 @@ TEST_CASE("spmat_sparse_dense_in_place") if ((double) a(r, c) != 0) REQUIRE( (double) a(r, c) == Approx(d(r, c)) ); else - REQUIRE(d(r, c) == Approx(1e-5) ); + REQUIRE(d(r, c) == Approx(0.0).margin(0.001) ); } } } @@ -2093,7 +2093,7 @@ TEST_CASE("spmat_sparse_dense_not_in_place") if ((double) y(r, c) != 0) REQUIRE( (double) y(r, c) == Approx(z(r, c)) ); else - REQUIRE( z(r, c) == Approx(1e-5) ); + REQUIRE( z(r, c) == Approx(0.0).margin(0.001) ); } } @@ -2107,7 +2107,7 @@ TEST_CASE("spmat_sparse_dense_not_in_place") if ((double) y(r, c) != 0) REQUIRE( (double) y(r, c) == Approx(z(r, c)) ); else - REQUIRE( z(r, c) == Approx(1e-5) ); + REQUIRE( z(r, c) == Approx(0.0).margin(0.001) ); } } @@ -2121,7 +2121,7 @@ TEST_CASE("spmat_sparse_dense_not_in_place") if ((double) y(r, c) != 0) REQUIRE( (double) y(r, c) == Approx(z(r, c)) ); else - REQUIRE( z(r, c) == Approx(1e-5) ); + REQUIRE( z(r, c) == Approx(0.0).margin(0.001) ); } } @@ -2135,7 +2135,7 @@ TEST_CASE("spmat_sparse_dense_not_in_place") if ((double) y(r, c) != 0) REQUIRE( (double) y(r, c) == Approx(z(r, c)) ); else - REQUIRE( z(r, c) == Approx(1e-5) ); + REQUIRE( z(r, c) == Approx(0.0).margin(0.001) ); } } @@ -2149,7 +2149,7 @@ TEST_CASE("spmat_sparse_dense_not_in_place") if ((double) y(r, c) != 0) REQUIRE( (double) y(r, c) == Approx(z(r, c)) ); else - REQUIRE( z(r, c) == Approx(1e-5) ); + REQUIRE( z(r, c) == Approx(0.0).margin(0.001) ); } } @@ -2163,7 +2163,7 @@ TEST_CASE("spmat_sparse_dense_not_in_place") if ((double) y(r, c) != 0) REQUIRE( (double) y(r, c) == Approx(z(r, c)) ); else - REQUIRE( z(r, c) == Approx(1e-5) ); + REQUIRE( z(r, c) == Approx(0.0).margin(0.001) ); } } @@ -2177,7 +2177,7 @@ TEST_CASE("spmat_sparse_dense_not_in_place") if ((double) y(r, c) != 0) REQUIRE( (double) y(r, c) == Approx(z(r, c)) ); else - REQUIRE( z(r, c) == Approx(1e-5) ); + REQUIRE( z(r, c) == Approx(0.0).margin(0.001) ); } } @@ -2191,7 +2191,7 @@ TEST_CASE("spmat_sparse_dense_not_in_place") if ((double) y(r, c) != 0) REQUIRE( (double) y(r, c) == Approx(z(r, c)) ); else - REQUIRE( z(r, c) == Approx(1e-5) ); + REQUIRE( z(r, c) == Approx(0.0).margin(0.001) ); } } @@ -2205,7 +2205,7 @@ TEST_CASE("spmat_sparse_dense_not_in_place") if ((double) y(r, c) != 0) REQUIRE( (double) y(r, c) == Approx(z(r, c)) ); else - REQUIRE( z(r, c) == Approx(1e-5) ); + REQUIRE( z(r, c) == Approx(0.0).margin(0.001) ); } } } @@ -2492,7 +2492,7 @@ TEST_CASE("spmat_batch_insert_zeroes_test") REQUIRE( (double) m(2, 1) == Approx(1.5) ); REQUIRE( (double) m(7, 1) == Approx(-15.15) ); REQUIRE( (double) m(0, 4) == Approx(2.2) ); - REQUIRE( (double) m(9, 4) == Approx(1e-5) ); + REQUIRE( (double) m(9, 4) == Approx(0.0).margin(0.001) ); REQUIRE( (double) m(0, 5) == Approx(5.0) ); // Auto size detection. @@ -2504,7 +2504,7 @@ TEST_CASE("spmat_batch_insert_zeroes_test") REQUIRE( (double) n(2, 1) == Approx(1.5) ); REQUIRE( (double) n(7, 1) == Approx(-15.15) ); REQUIRE( (double) n(0, 4) == Approx(2.2) ); - REQUIRE( (double) n(9, 4) == Approx(1e-5) ); + REQUIRE( (double) n(9, 4) == Approx(0.0).margin(0.001) ); REQUIRE( (double) n(0, 5) == Approx(5.0) ); } @@ -2539,7 +2539,7 @@ TEST_CASE("spmat_batch_insert_unsorted_case_zeroes") REQUIRE( (double) m(2, 1) == Approx(1.5) ); REQUIRE( (double) m(7, 1) == Approx(-15.15) ); REQUIRE( (double) m(0, 4) == Approx(2.2) ); - REQUIRE( (double) m(9, 4) == Approx(1e-5) ); + REQUIRE( (double) m(9, 4) == Approx(0.0).margin(0.001) ); REQUIRE( (double) m(0, 5) == Approx(5.0) ); REQUIRE( m.col_ptrs[11] == std::numeric_limits::max() ); @@ -2552,7 +2552,7 @@ TEST_CASE("spmat_batch_insert_unsorted_case_zeroes") REQUIRE( (double) n(2, 1) == Approx(1.5) ); REQUIRE( (double) n(7, 1) == Approx(-15.15) ); REQUIRE( (double) n(0, 4) == Approx(2.2) ); - REQUIRE( (double) n(9, 4) == Approx(1e-5) ); + REQUIRE( (double) n(9, 4) == Approx(0.0).margin(0.001) ); REQUIRE( (double) n(0, 5) == Approx(5.0) ); REQUIRE( n.col_ptrs[7] == std::numeric_limits::max() ); } diff --git a/tests2/spsubview.cpp b/tests2/spsubview.cpp index bae61958..a314ee8d 100644 --- a/tests2/spsubview.cpp +++ b/tests2/spsubview.cpp @@ -123,30 +123,30 @@ TEST_CASE("sp_subview_multiplication_test") REQUIRE( b.n_nonzero == 5 ); REQUIRE( (double) b(0, 0) == Approx(1.2) ); - REQUIRE( (double) b(0, 1) == Approx(1e-5) ); - REQUIRE( (double) b(0, 2) == Approx(1e-5) ); - REQUIRE( (double) b(0, 3) == Approx(1e-5) ); - REQUIRE( (double) b(0, 4) == Approx(1e-5) ); + REQUIRE( (double) b(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(0, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(0, 3) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(0, 4) == Approx(0.0).margin(0.001) ); REQUIRE( (double) b(1, 0) == Approx(2.0) ); - REQUIRE( (double) b(1, 1) == Approx(1e-5) ); - REQUIRE( (double) b(1, 2) == Approx(1e-5) ); - REQUIRE( (double) b(1, 3) == Approx(1e-5) ); - REQUIRE( (double) b(1, 4) == Approx(1e-5) ); - REQUIRE( (double) b(2, 0) == Approx(1e-5) ); - REQUIRE( (double) b(2, 1) == Approx(1e-5) ); - REQUIRE( (double) b(2, 2) == Approx(1e-5) ); - REQUIRE( (double) b(2, 3) == Approx(1e-5) ); - REQUIRE( (double) b(2, 4) == Approx(1e-5) ); + REQUIRE( (double) b(1, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(1, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(1, 3) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(1, 4) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(2, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(2, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(2, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(2, 3) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(2, 4) == Approx(0.0).margin(0.001) ); REQUIRE( (double) b(3, 0) == Approx(4.0) ); - REQUIRE( (double) b(3, 1) == Approx(1e-5) ); - REQUIRE( (double) b(3, 2) == Approx(1e-5) ); - REQUIRE( (double) b(3, 3) == Approx(1e-5) ); - REQUIRE( (double) b(3, 4) == Approx(1e-5) ); - REQUIRE( (double) b(4, 0) == Approx(1e-5) ); - REQUIRE( (double) b(4, 1) == Approx(1e-5) ); + REQUIRE( (double) b(3, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(3, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(3, 3) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(3, 4) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(4, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(4, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) b(4, 2) == Approx(4.5) ); REQUIRE( (double) b(4, 3) == Approx(3.0) ); - REQUIRE( (double) b(4, 4) == Approx(1e-5) ); + REQUIRE( (double) b(4, 4) == Approx(0.0).margin(0.001) ); } @@ -176,30 +176,30 @@ TEST_CASE("sp_subview_multiplication_test_2") REQUIRE( b.n_nonzero == 5 ); REQUIRE( (double) b(0, 0) == Approx(1.2) ); - REQUIRE( (double) b(0, 1) == Approx(1e-5) ); - REQUIRE( (double) b(0, 2) == Approx(1e-5) ); - REQUIRE( (double) b(0, 3) == Approx(1e-5) ); - REQUIRE( (double) b(0, 4) == Approx(1e-5) ); + REQUIRE( (double) b(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(0, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(0, 3) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(0, 4) == Approx(0.0).margin(0.001) ); REQUIRE( (double) b(1, 0) == Approx(2.0) ); - REQUIRE( (double) b(1, 1) == Approx(1e-5) ); - REQUIRE( (double) b(1, 2) == Approx(1e-5) ); - REQUIRE( (double) b(1, 3) == Approx(1e-5) ); - REQUIRE( (double) b(1, 4) == Approx(1e-5) ); - REQUIRE( (double) b(2, 0) == Approx(1e-5) ); - REQUIRE( (double) b(2, 1) == Approx(1e-5) ); - REQUIRE( (double) b(2, 2) == Approx(1e-5) ); - REQUIRE( (double) b(2, 3) == Approx(1e-5) ); - REQUIRE( (double) b(2, 4) == Approx(1e-5) ); + REQUIRE( (double) b(1, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(1, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(1, 3) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(1, 4) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(2, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(2, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(2, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(2, 3) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(2, 4) == Approx(0.0).margin(0.001) ); REQUIRE( (double) b(3, 0) == Approx(4.0) ); - REQUIRE( (double) b(3, 1) == Approx(1e-5) ); - REQUIRE( (double) b(3, 2) == Approx(1e-5) ); - REQUIRE( (double) b(3, 3) == Approx(1e-5) ); - REQUIRE( (double) b(3, 4) == Approx(1e-5) ); - REQUIRE( (double) b(4, 0) == Approx(1e-5) ); - REQUIRE( (double) b(4, 1) == Approx(1e-5) ); + REQUIRE( (double) b(3, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(3, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(3, 3) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(3, 4) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(4, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) b(4, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) b(4, 2) == Approx(4.5) ); REQUIRE( (double) b(4, 3) == Approx(3.0) ); - REQUIRE( (double) b(4, 4) == Approx(1e-5) ); + REQUIRE( (double) b(4, 4) == Approx(0.0).margin(0.001) ); } @@ -304,7 +304,7 @@ TEST_CASE("sp_subview_mat_operator_tests") REQUIRE( (double) c(2, 0) == Approx(2.0) ); REQUIRE( (double) c(0, 1) == Approx(2.0) ); REQUIRE( (double) c(1, 1) == Approx(2.0) ); - REQUIRE( (double) c(2, 1) == Approx(1e-5) ); + REQUIRE( (double) c(2, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(0, 2) == Approx(2.0) ); REQUIRE( (double) c(1, 2) == Approx(5.5) ); REQUIRE( (double) c(2, 2) == Approx(6.5) ); @@ -316,7 +316,7 @@ TEST_CASE("sp_subview_mat_operator_tests") REQUIRE( (double) c(2, 0) == Approx(2.0) ); REQUIRE( (double) c(0, 1) == Approx(2.0) ); REQUIRE( (double) c(1, 1) == Approx(2.0) ); - REQUIRE( (double) c(2, 1) == Approx(1e-5) ); + REQUIRE( (double) c(2, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(0, 2) == Approx(2.0) ); REQUIRE( (double) c(1, 2) == Approx(5.5) ); REQUIRE( (double) c(2, 2) == Approx(6.5) ); @@ -324,7 +324,7 @@ TEST_CASE("sp_subview_mat_operator_tests") c = b; c -= a.submat(2, 2, 4, 4); - REQUIRE( (double) c(0, 0) == Approx(1e-5) ); + REQUIRE( (double) c(0, 0) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(1, 0) == Approx(2.0) ); REQUIRE( (double) c(2, 0) == Approx(2.0) ); REQUIRE( (double) c(0, 1) == Approx(2.0) ); @@ -336,7 +336,7 @@ TEST_CASE("sp_subview_mat_operator_tests") c = b - a.submat(2, 2, 4, 4); - REQUIRE( (double) c(0, 0) == Approx(1e-5) ); + REQUIRE( (double) c(0, 0) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(1, 0) == Approx(2.0) ); REQUIRE( (double) c(2, 0) == Approx(2.0) ); REQUIRE( (double) c(0, 1) == Approx(2.0) ); @@ -375,12 +375,12 @@ TEST_CASE("sp_subview_mat_operator_tests") c %= a.submat(2, 2, 4, 4); REQUIRE( (double) c(0, 0) == Approx(4.0) ); - REQUIRE( (double) c(1, 0) == Approx(1e-5) ); - REQUIRE( (double) c(2, 0) == Approx(1e-5) ); - REQUIRE( (double) c(0, 1) == Approx(1e-5) ); - REQUIRE( (double) c(1, 1) == Approx(1e-5) ); + REQUIRE( (double) c(1, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(2, 0) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(0, 1) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(1, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(2, 1) == Approx(-4.0) ); - REQUIRE( (double) c(0, 2) == Approx(1e-5) ); + REQUIRE( (double) c(0, 2) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(1, 2) == Approx(7.0) ); REQUIRE( (double) c(2, 2) == Approx(9.0) ); @@ -446,7 +446,7 @@ TEST_CASE("sp_subview_base_test") REQUIRE( (double) c(4, 2) == Approx(2.0) ); REQUIRE( (double) c(2, 3) == Approx(2.0) ); REQUIRE( (double) c(3, 3) == Approx(2.0) ); - REQUIRE( (double) c(4, 3) == Approx(1e-5) ); + REQUIRE( (double) c(4, 3) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(2, 4) == Approx(2.0) ); REQUIRE( (double) c(3, 4) == Approx(5.5) ); REQUIRE( (double) c(4, 4) == Approx(6.5) ); @@ -460,7 +460,7 @@ TEST_CASE("sp_subview_base_test") REQUIRE( (double) c(2, 0) == Approx(2.0) ); REQUIRE( (double) c(0, 1) == Approx(2.0) ); REQUIRE( (double) c(1, 1) == Approx(2.0) ); - REQUIRE( (double) c(2, 1) == Approx(1e-5) ); + REQUIRE( (double) c(2, 1) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(0, 2) == Approx(2.0) ); REQUIRE( (double) c(1, 2) == Approx(5.5) ); REQUIRE( (double) c(2, 2) == Approx(6.5) ); @@ -469,7 +469,7 @@ TEST_CASE("sp_subview_base_test") c.submat(2, 2, 4, 4) -= b; REQUIRE( c.n_nonzero == 12 ); - REQUIRE( (double) c(2, 2) == Approx(1e-5) ); + REQUIRE( (double) c(2, 2) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(3, 2) == Approx(-2.0) ); REQUIRE( (double) c(4, 2) == Approx(-2.0) ); REQUIRE( (double) c(2, 3) == Approx(-2.0) ); @@ -482,7 +482,7 @@ TEST_CASE("sp_subview_base_test") c = a.submat(2, 2, 4, 4) - b; REQUIRE( c.n_nonzero == 8 ); - REQUIRE( (double) c(0, 0) == Approx(1e-5) ); + REQUIRE( (double) c(0, 0) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(1, 0) == Approx(-2.0) ); REQUIRE( (double) c(2, 0) == Approx(-2.0) ); REQUIRE( (double) c(0, 1) == Approx(-2.0) ); @@ -600,13 +600,13 @@ TEST_CASE("sp_subview_sp_mat_test") c.submat(2, 2, 4, 4) -= b; REQUIRE( c.n_nonzero == 7 ); - REQUIRE( (double) c(2, 2) == Approx(1e-5) ); - REQUIRE( (double) c(3, 2) == Approx(1e-5) ); - REQUIRE( (double) c(4, 2) == Approx(1e-5) ); - REQUIRE( (double) c(2, 3) == Approx(1e-5) ); - REQUIRE( (double) c(3, 3) == Approx(1e-5) ); + REQUIRE( (double) c(2, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(3, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(4, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(2, 3) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(3, 3) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(4, 3) == Approx(-4.0) ); - REQUIRE( (double) c(2, 4) == Approx(1e-5) ); + REQUIRE( (double) c(2, 4) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(3, 4) == Approx(2.0) ); REQUIRE( (double) c(4, 4) == Approx(4.5) ); @@ -639,7 +639,7 @@ TEST_CASE("sp_subview_sp_mat_test") REQUIRE( (double) c(0, 0) == Approx(4.0) ); REQUIRE( (double) c(2, 1) == Approx(-4.0) ); REQUIRE( (double) c(1, 2) == Approx(5.25) ); - REQUIRE( (double) c(2, 2) == Approx(1e-5) ); + REQUIRE( (double) c(2, 2) == Approx(0.0).margin(0.001) ); c = a; c.submat(2, 2, 4, 4) %= b; @@ -648,7 +648,7 @@ TEST_CASE("sp_subview_sp_mat_test") REQUIRE( (double) c(2, 2) == Approx(4.0) ); REQUIRE( (double) c(4, 3) == Approx(-4.0) ); REQUIRE( (double) c(3, 4) == Approx(5.25) ); - REQUIRE( (double) c(4, 4) == Approx(1e-5) ); + REQUIRE( (double) c(4, 4) == Approx(0.0).margin(0.001) ); // c = a.submat(2, 2, 4, 4) / b; @@ -740,13 +740,13 @@ TEST_CASE("sp_subview_sp_subview_tests") c.submat(2, 2, 4, 4) -= b.submat(1, 1, 3, 3); REQUIRE( c.n_nonzero == 7 ); - REQUIRE( (double) c(2, 2) == Approx(1e-5) ); - REQUIRE( (double) c(3, 2) == Approx(1e-5) ); - REQUIRE( (double) c(4, 2) == Approx(1e-5) ); - REQUIRE( (double) c(2, 3) == Approx(1e-5) ); - REQUIRE( (double) c(3, 3) == Approx(1e-5) ); + REQUIRE( (double) c(2, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(3, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(4, 2) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(2, 3) == Approx(0.0).margin(0.001) ); + REQUIRE( (double) c(3, 3) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(4, 3) == Approx(-4.0) ); - REQUIRE( (double) c(2, 4) == Approx(1e-5) ); + REQUIRE( (double) c(2, 4) == Approx(0.0).margin(0.001) ); REQUIRE( (double) c(3, 4) == Approx(2.0) ); REQUIRE( (double) c(4, 4) == Approx(4.5) ); @@ -779,7 +779,7 @@ TEST_CASE("sp_subview_sp_subview_tests") REQUIRE( (double) c(0, 0) == Approx(4.0) ); REQUIRE( (double) c(2, 1) == Approx(-4.0) ); REQUIRE( (double) c(1, 2) == Approx(5.25) ); - REQUIRE( (double) c(2, 2) == Approx(1e-5) ); + REQUIRE( (double) c(2, 2) == Approx(0.0).margin(0.001) ); c = a; c.submat(2, 2, 4, 4) %= b.submat(1, 1, 3, 3); @@ -788,7 +788,7 @@ TEST_CASE("sp_subview_sp_subview_tests") REQUIRE( (double) c(2, 2) == Approx(4.0) ); REQUIRE( (double) c(4, 3) == Approx(-4.0) ); REQUIRE( (double) c(3, 4) == Approx(5.25) ); - REQUIRE( (double) c(4, 4) == Approx(1e-5) ); + REQUIRE( (double) c(4, 4) == Approx(0.0).margin(0.001) ); // c = a.submat(2, 2, 4, 4) / b.submat(1, 1, 3, 3);