diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp index f0a80df8e..1e361aa29 100644 --- a/test/array_cwise.cpp +++ b/test/array_cwise.cpp @@ -251,9 +251,9 @@ void mixed_pow_test() { unary_pow_test(); // The following cases will test promoting a wider exponent type - // to a narrower base type. This should compile but generate a + // to a narrower base type. This should compile but would generate a // deprecation warning: - unary_pow_test(); + // unary_pow_test(); } void int_pow_test() { diff --git a/test/fastmath.cpp b/test/fastmath.cpp index 00a1a59b8..902dfd779 100644 --- a/test/fastmath.cpp +++ b/test/fastmath.cpp @@ -43,11 +43,11 @@ void check_inf_nan(bool dryrun) { } else { - if( (std::isfinite)(m(3))) g_test_level=1; VERIFY( !(numext::isfinite)(m(3)) ); g_test_level=0; - if( (std::isinf) (m(3))) g_test_level=1; VERIFY( !(numext::isinf)(m(3)) ); g_test_level=0; - if(!(std::isnan) (m(3))) g_test_level=1; VERIFY( (numext::isnan)(m(3)) ); g_test_level=0; - if( (std::isfinite)(m(3))) g_test_level=1; VERIFY( !m.allFinite() ); g_test_level=0; - if(!(std::isnan) (m(3))) g_test_level=1; VERIFY( m.hasNaN() ); g_test_level=0; + if( (std::isfinite)(m(3))) { g_test_level=1; VERIFY( !(numext::isfinite)(m(3)) ); g_test_level=0; } + if( (std::isinf) (m(3))) { g_test_level=1; VERIFY( !(numext::isinf)(m(3)) ); g_test_level=0; } + if(!(std::isnan) (m(3))) { g_test_level=1; VERIFY( (numext::isnan)(m(3)) ); g_test_level=0; } + if( (std::isfinite)(m(3))) { g_test_level=1; VERIFY( !m.allFinite() ); g_test_level=0; } + if(!(std::isnan) (m(3))) { g_test_level=1; VERIFY( m.hasNaN() ); g_test_level=0; } } T hidden_zero = (std::numeric_limits::min)()*(std::numeric_limits::min)(); m(4) /= hidden_zero; @@ -62,11 +62,11 @@ void check_inf_nan(bool dryrun) { } else { - if( (std::isfinite)(m(3))) g_test_level=1; VERIFY( !(numext::isfinite)(m(4)) ); g_test_level=0; - if(!(std::isinf) (m(3))) g_test_level=1; VERIFY( (numext::isinf)(m(4)) ); g_test_level=0; - if( (std::isnan) (m(3))) g_test_level=1; VERIFY( !(numext::isnan)(m(4)) ); g_test_level=0; - if( (std::isfinite)(m(3))) g_test_level=1; VERIFY( !m.allFinite() ); g_test_level=0; - if(!(std::isnan) (m(3))) g_test_level=1; VERIFY( m.hasNaN() ); g_test_level=0; + if( (std::isfinite)(m(3))) { g_test_level=1; VERIFY( !(numext::isfinite)(m(4)) ); g_test_level=0; } + if(!(std::isinf) (m(3))) { g_test_level=1; VERIFY( (numext::isinf)(m(4)) ); g_test_level=0; } + if( (std::isnan) (m(3))) { g_test_level=1; VERIFY( !(numext::isnan)(m(4)) ); g_test_level=0; } + if( (std::isfinite)(m(3))) { g_test_level=1; VERIFY( !m.allFinite() ); g_test_level=0; } + if(!(std::isnan) (m(3))) { g_test_level=1; VERIFY( m.hasNaN() ); g_test_level=0; } } m(3) = 0; if(dryrun) @@ -80,11 +80,11 @@ void check_inf_nan(bool dryrun) { } else { - if(!(std::isfinite)(m(3))) g_test_level=1; VERIFY( (numext::isfinite)(m(3)) ); g_test_level=0; - if( (std::isinf) (m(3))) g_test_level=1; VERIFY( !(numext::isinf)(m(3)) ); g_test_level=0; - if( (std::isnan) (m(3))) g_test_level=1; VERIFY( !(numext::isnan)(m(3)) ); g_test_level=0; - if( (std::isfinite)(m(3))) g_test_level=1; VERIFY( !m.allFinite() ); g_test_level=0; - if( (std::isnan) (m(3))) g_test_level=1; VERIFY( !m.hasNaN() ); g_test_level=0; + if(!(std::isfinite)(m(3))) { g_test_level=1; VERIFY( (numext::isfinite)(m(3)) ); g_test_level=0; } + if( (std::isinf) (m(3))) { g_test_level=1; VERIFY( !(numext::isinf)(m(3)) ); g_test_level=0; } + if( (std::isnan) (m(3))) { g_test_level=1; VERIFY( !(numext::isnan)(m(3)) ); g_test_level=0; } + if( (std::isfinite)(m(3))) { g_test_level=1; VERIFY( !m.allFinite() ); g_test_level=0; } + if( (std::isnan) (m(3))) { g_test_level=1; VERIFY( !m.hasNaN() ); g_test_level=0; } } } diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp index a9fc9fd5a..2cd9dab7a 100644 --- a/test/sparse_basic.cpp +++ b/test/sparse_basic.cpp @@ -164,7 +164,7 @@ template void sparse_basic(const SparseMatrixType& re // test sort if (inner > 1) { - bool StorageOrdersMatch = DenseMatrix::IsRowMajor == SparseMatrixType::IsRowMajor; + bool StorageOrdersMatch = int(DenseMatrix::IsRowMajor) == int(SparseMatrixType::IsRowMajor); DenseMatrix m1(rows, cols); m1.setZero(); SparseMatrixType m2(rows, cols); diff --git a/unsupported/test/NNLS.cpp b/unsupported/test/NNLS.cpp index d65920bfc..b347c06fe 100644 --- a/unsupported/test/NNLS.cpp +++ b/unsupported/test/NNLS.cpp @@ -12,10 +12,11 @@ #include "main.h" #include + /// Check that 'x' solves the NNLS optimization problem `min ||A*x-b|| s.t. 0 <= x`. /// The \p tolerance parameter is the absolute tolerance on the gradient, A'*(A*x-b). template -static void verify_nnls_optimality(const MatrixType &A, const VectorB &b, const VectorX &x, const Scalar tolerance) { +void verify_nnls_optimality(const MatrixType &A, const VectorB &b, const VectorX &x, const Scalar tolerance) { // The NNLS optimality conditions are: // // * 0 = A'*A*x - A'*b - lambda @@ -38,7 +39,7 @@ static void verify_nnls_optimality(const MatrixType &A, const VectorB &b, const } template -static void test_nnls_known_solution(const MatrixType &A, const VectorB &b, const VectorX &x_expected) { +void test_nnls_known_solution(const MatrixType &A, const VectorB &b, const VectorX &x_expected) { using Scalar = typename MatrixType::Scalar; using std::sqrt; @@ -53,7 +54,7 @@ static void test_nnls_known_solution(const MatrixType &A, const VectorB &b, cons } template -static void test_nnls_random_problem() { +void test_nnls_random_problem() { // // SETUP // @@ -101,7 +102,7 @@ static void test_nnls_random_problem() { verify_nnls_optimality(A, b, x, tolerance); } -static void test_nnls_handles_zero_rhs() { +void test_nnls_handles_zero_rhs() { // // SETUP // @@ -124,7 +125,7 @@ static void test_nnls_handles_zero_rhs() { VERIFY_IS_EQUAL(x, VectorXd::Zero(cols)); } -static void test_nnls_handles_Mx0_matrix() { +void test_nnls_handles_Mx0_matrix() { // // SETUP // @@ -146,7 +147,7 @@ static void test_nnls_handles_Mx0_matrix() { VERIFY_IS_EQUAL(x.size(), 0); } -static void test_nnls_handles_0x0_matrix() { +void test_nnls_handles_0x0_matrix() { // // SETUP // @@ -167,7 +168,7 @@ static void test_nnls_handles_0x0_matrix() { VERIFY_IS_EQUAL(x.size(), 0); } -static void test_nnls_handles_dependent_columns() { +void test_nnls_handles_dependent_columns() { // // SETUP // @@ -197,7 +198,7 @@ static void test_nnls_handles_dependent_columns() { } } -static void test_nnls_handles_wide_matrix() { +void test_nnls_handles_wide_matrix() { // // SETUP // @@ -230,7 +231,7 @@ static void test_nnls_handles_wide_matrix() { } // 4x2 problem, unconstrained solution positive -static void test_nnls_known_1() { +void test_nnls_known_1() { Matrix A(4, 2); Matrix b(4); Matrix x(2); @@ -242,7 +243,7 @@ static void test_nnls_known_1() { } // 4x3 problem, unconstrained solution positive -static void test_nnls_known_2() { +void test_nnls_known_2() { Matrix A(4, 3); Matrix b(4); Matrix x(3); @@ -255,7 +256,7 @@ static void test_nnls_known_2() { } // Simple 4x4 problem, unconstrained solution non-negative -static void test_nnls_known_3() { +void test_nnls_known_3() { Matrix A(4, 4); Matrix b(4); Matrix x(4); @@ -268,7 +269,7 @@ static void test_nnls_known_3() { } // Simple 4x3 problem, unconstrained solution non-negative -static void test_nnls_known_4() { +void test_nnls_known_4() { Matrix A(4, 3); Matrix b(4); Matrix x(3); @@ -281,7 +282,7 @@ static void test_nnls_known_4() { } // Simple 4x3 problem, unconstrained solution indefinite -static void test_nnls_known_5() { +void test_nnls_known_5() { Matrix A(4, 3); Matrix b(4); Matrix x(3); @@ -294,7 +295,7 @@ static void test_nnls_known_5() { test_nnls_known_solution(A, b, x); } -static void test_nnls_small_reference_problems() { +void test_nnls_small_reference_problems() { test_nnls_known_1(); test_nnls_known_2(); test_nnls_known_3(); @@ -302,7 +303,7 @@ static void test_nnls_small_reference_problems() { test_nnls_known_5(); } -static void test_nnls_with_half_precision() { +void test_nnls_with_half_precision() { // The random matrix generation tools don't work with `half`, // so here's a simpler setup mostly just to check that NNLS compiles & runs with custom scalar types. @@ -319,7 +320,7 @@ static void test_nnls_with_half_precision() { verify_nnls_optimality(A, b, x, half(1e-1)); } -static void test_nnls_special_case_solves_in_zero_iterations() { +void test_nnls_special_case_solves_in_zero_iterations() { // The particular NNLS algorithm that is implemented starts with all variables // in the active set. // This test builds a system where all constraints are active at the solution, @@ -346,7 +347,7 @@ static void test_nnls_special_case_solves_in_zero_iterations() { VERIFY(nnls.iterations() == 0); } -static void test_nnls_special_case_solves_in_n_iterations() { +void test_nnls_special_case_solves_in_n_iterations() { // The particular NNLS algorithm that is implemented starts with all variables // in the active set and then adds one variable to the inactive set each iteration. // This test builds a system where all variables are inactive at the solution, @@ -370,7 +371,7 @@ static void test_nnls_special_case_solves_in_n_iterations() { VERIFY(nnls.iterations() == n); } -static void test_nnls_returns_NoConvergence_when_maxIterations_is_too_low() { +void test_nnls_returns_NoConvergence_when_maxIterations_is_too_low() { // Using the special case that takes `n` iterations, // from `test_nnls_special_case_solves_in_n_iterations`, // we can set max iterations too low and that should cause the solve to fail. @@ -391,7 +392,7 @@ static void test_nnls_returns_NoConvergence_when_maxIterations_is_too_low() { VERIFY(nnls.iterations() == max_iters); } -static void test_nnls_default_maxIterations_is_twice_column_count() { +void test_nnls_default_maxIterations_is_twice_column_count() { const Index cols = internal::random(1, EIGEN_TEST_MAX_SIZE); const Index rows = internal::random(cols, EIGEN_TEST_MAX_SIZE); const MatrixXd A = MatrixXd::Random(rows, cols); @@ -401,7 +402,7 @@ static void test_nnls_default_maxIterations_is_twice_column_count() { VERIFY_IS_EQUAL(nnls.maxIterations(), 2 * cols); } -static void test_nnls_does_not_allocate_during_solve() { +void test_nnls_does_not_allocate_during_solve() { const Index cols = internal::random(1, EIGEN_TEST_MAX_SIZE); const Index rows = internal::random(cols, EIGEN_TEST_MAX_SIZE); const MatrixXd A = MatrixXd::Random(rows, cols); @@ -414,7 +415,7 @@ static void test_nnls_does_not_allocate_during_solve() { internal::set_is_malloc_allowed(true); } -static void test_nnls_repeated_calls_to_compute_and_solve() { +void test_nnls_repeated_calls_to_compute_and_solve() { const Index cols2 = internal::random(1, EIGEN_TEST_MAX_SIZE); const Index rows2 = internal::random(cols2, EIGEN_TEST_MAX_SIZE); const MatrixXd A2 = MatrixXd::Random(rows2, cols2); @@ -449,8 +450,10 @@ EIGEN_DECLARE_TEST(NNLS) { // Essential NNLS properties, across different types. CALL_SUBTEST_2(test_nnls_random_problem()); CALL_SUBTEST_3(test_nnls_random_problem()); - using MatFixed = Matrix; - CALL_SUBTEST_4(test_nnls_random_problem()); + { + using MatFixed = Matrix; + CALL_SUBTEST_4(test_nnls_random_problem()); + } CALL_SUBTEST_5(test_nnls_with_half_precision()); // Robustness tests: