Fix compiler warnings in tests.
diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp
index f0a80df..1e361aa 100644
--- a/test/array_cwise.cpp
+++ b/test/array_cwise.cpp
@@ -251,9 +251,9 @@
unary_pow_test<double, long long>();
// 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<float, double>();
+ // unary_pow_test<float, double>();
}
void int_pow_test() {
diff --git a/test/fastmath.cpp b/test/fastmath.cpp
index 00a1a59..902dfd7 100644
--- a/test/fastmath.cpp
+++ b/test/fastmath.cpp
@@ -43,11 +43,11 @@
}
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<T>::min)()*(std::numeric_limits<T>::min)();
m(4) /= hidden_zero;
@@ -62,11 +62,11 @@
}
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 @@
}
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 a9fc9fd..2cd9dab 100644
--- a/test/sparse_basic.cpp
+++ b/test/sparse_basic.cpp
@@ -164,7 +164,7 @@
// 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 d65920b..b347c06 100644
--- a/unsupported/test/NNLS.cpp
+++ b/unsupported/test/NNLS.cpp
@@ -12,10 +12,11 @@
#include "main.h"
#include <unsupported/Eigen/NNLS>
+
/// 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 <typename MatrixType, typename VectorB, typename VectorX, typename Scalar>
-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 @@
}
template <typename MatrixType, typename VectorB, typename VectorX>
-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 @@
}
template <typename MatrixType>
-static void test_nnls_random_problem() {
+void test_nnls_random_problem() {
//
// SETUP
//
@@ -101,7 +102,7 @@
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 @@
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 @@
VERIFY_IS_EQUAL(x.size(), 0);
}
-static void test_nnls_handles_0x0_matrix() {
+void test_nnls_handles_0x0_matrix() {
//
// SETUP
//
@@ -167,7 +168,7 @@
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_wide_matrix() {
+void test_nnls_handles_wide_matrix() {
//
// SETUP
//
@@ -230,7 +231,7 @@
}
// 4x2 problem, unconstrained solution positive
-static void test_nnls_known_1() {
+void test_nnls_known_1() {
Matrix<double, 4, 2> A(4, 2);
Matrix<double, 4, 1> b(4);
Matrix<double, 2, 1> x(2);
@@ -242,7 +243,7 @@
}
// 4x3 problem, unconstrained solution positive
-static void test_nnls_known_2() {
+void test_nnls_known_2() {
Matrix<double, 4, 3> A(4, 3);
Matrix<double, 4, 1> b(4);
Matrix<double, 3, 1> x(3);
@@ -255,7 +256,7 @@
}
// Simple 4x4 problem, unconstrained solution non-negative
-static void test_nnls_known_3() {
+void test_nnls_known_3() {
Matrix<double, 4, 4> A(4, 4);
Matrix<double, 4, 1> b(4);
Matrix<double, 4, 1> x(4);
@@ -268,7 +269,7 @@
}
// Simple 4x3 problem, unconstrained solution non-negative
-static void test_nnls_known_4() {
+void test_nnls_known_4() {
Matrix<double, 4, 3> A(4, 3);
Matrix<double, 4, 1> b(4);
Matrix<double, 3, 1> x(3);
@@ -281,7 +282,7 @@
}
// Simple 4x3 problem, unconstrained solution indefinite
-static void test_nnls_known_5() {
+void test_nnls_known_5() {
Matrix<double, 4, 3> A(4, 3);
Matrix<double, 4, 1> b(4);
Matrix<double, 3, 1> x(3);
@@ -294,7 +295,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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<Index>(1, EIGEN_TEST_MAX_SIZE);
const Index rows = internal::random<Index>(cols, EIGEN_TEST_MAX_SIZE);
const MatrixXd A = MatrixXd::Random(rows, cols);
@@ -401,7 +402,7 @@
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<Index>(1, EIGEN_TEST_MAX_SIZE);
const Index rows = internal::random<Index>(cols, EIGEN_TEST_MAX_SIZE);
const MatrixXd A = MatrixXd::Random(rows, cols);
@@ -414,7 +415,7 @@
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<Index>(1, EIGEN_TEST_MAX_SIZE);
const Index rows2 = internal::random<Index>(cols2, EIGEN_TEST_MAX_SIZE);
const MatrixXd A2 = MatrixXd::Random(rows2, cols2);
@@ -449,8 +450,10 @@
// Essential NNLS properties, across different types.
CALL_SUBTEST_2(test_nnls_random_problem<MatrixXf>());
CALL_SUBTEST_3(test_nnls_random_problem<MatrixXd>());
- using MatFixed = Matrix<double, 12, 5>;
- CALL_SUBTEST_4(test_nnls_random_problem<MatFixed>());
+ {
+ using MatFixed = Matrix<double, 12, 5>;
+ CALL_SUBTEST_4(test_nnls_random_problem<MatFixed>());
+ }
CALL_SUBTEST_5(test_nnls_with_half_precision());
// Robustness tests: