mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-23 10:09:36 +08:00
Workaround a bunch of stupid warnings in unit tests
This commit is contained in:
parent
fab0235369
commit
d1d7a1ade9
@ -82,14 +82,14 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
|
|||||||
symm += a1 * a1.adjoint();
|
symm += a1 * a1.adjoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
SquareMatrixType symmUp = symm.template triangularView<Upper>();
|
|
||||||
SquareMatrixType symmLo = symm.template triangularView<Lower>();
|
|
||||||
|
|
||||||
// to test if really Cholesky only uses the upper triangular part, uncomment the following
|
// to test if really Cholesky only uses the upper triangular part, uncomment the following
|
||||||
// FIXME: currently that fails !!
|
// FIXME: currently that fails !!
|
||||||
//symm.template part<StrictlyLower>().setZero();
|
//symm.template part<StrictlyLower>().setZero();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
SquareMatrixType symmUp = symm.template triangularView<Upper>();
|
||||||
|
SquareMatrixType symmLo = symm.template triangularView<Lower>();
|
||||||
|
|
||||||
LLT<SquareMatrixType,Lower> chollo(symmLo);
|
LLT<SquareMatrixType,Lower> chollo(symmLo);
|
||||||
VERIFY_IS_APPROX(symm, chollo.reconstructedMatrix());
|
VERIFY_IS_APPROX(symm, chollo.reconstructedMatrix());
|
||||||
vecX = chollo.solve(vecB);
|
vecX = chollo.solve(vecB);
|
||||||
@ -113,6 +113,21 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
|
|||||||
VERIFY_IS_APPROX(MatrixType(chollo.matrixU().transpose().conjugate()), MatrixType(chollo.matrixL()));
|
VERIFY_IS_APPROX(MatrixType(chollo.matrixU().transpose().conjugate()), MatrixType(chollo.matrixL()));
|
||||||
VERIFY_IS_APPROX(MatrixType(cholup.matrixL().transpose().conjugate()), MatrixType(cholup.matrixU()));
|
VERIFY_IS_APPROX(MatrixType(cholup.matrixL().transpose().conjugate()), MatrixType(cholup.matrixU()));
|
||||||
VERIFY_IS_APPROX(MatrixType(cholup.matrixU().transpose().conjugate()), MatrixType(cholup.matrixL()));
|
VERIFY_IS_APPROX(MatrixType(cholup.matrixU().transpose().conjugate()), MatrixType(cholup.matrixL()));
|
||||||
|
|
||||||
|
// test some special use cases of SelfCwiseBinaryOp:
|
||||||
|
MatrixType m1 = MatrixType::Random(rows,cols), m2(rows,cols);
|
||||||
|
m2 = m1;
|
||||||
|
m2 += symmLo.template selfadjointView<Lower>().llt().solve(matB);
|
||||||
|
VERIFY_IS_APPROX(m2, m1 + symmLo.template selfadjointView<Lower>().llt().solve(matB));
|
||||||
|
m2 = m1;
|
||||||
|
m2 -= symmLo.template selfadjointView<Lower>().llt().solve(matB);
|
||||||
|
VERIFY_IS_APPROX(m2, m1 - symmLo.template selfadjointView<Lower>().llt().solve(matB));
|
||||||
|
m2 = m1;
|
||||||
|
m2.noalias() += symmLo.template selfadjointView<Lower>().llt().solve(matB);
|
||||||
|
VERIFY_IS_APPROX(m2, m1 + symmLo.template selfadjointView<Lower>().llt().solve(matB));
|
||||||
|
m2 = m1;
|
||||||
|
m2.noalias() -= symmLo.template selfadjointView<Lower>().llt().solve(matB);
|
||||||
|
VERIFY_IS_APPROX(m2, m1 - symmLo.template selfadjointView<Lower>().llt().solve(matB));
|
||||||
}
|
}
|
||||||
|
|
||||||
// LDLT
|
// LDLT
|
||||||
@ -166,21 +181,6 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
|
|||||||
symm = -symm;
|
symm = -symm;
|
||||||
}
|
}
|
||||||
|
|
||||||
// test some special use cases of SelfCwiseBinaryOp:
|
|
||||||
MatrixType m1 = MatrixType::Random(rows,cols), m2(rows,cols);
|
|
||||||
m2 = m1;
|
|
||||||
m2 += symmLo.template selfadjointView<Lower>().llt().solve(matB);
|
|
||||||
VERIFY_IS_APPROX(m2, m1 + symmLo.template selfadjointView<Lower>().llt().solve(matB));
|
|
||||||
m2 = m1;
|
|
||||||
m2 -= symmLo.template selfadjointView<Lower>().llt().solve(matB);
|
|
||||||
VERIFY_IS_APPROX(m2, m1 - symmLo.template selfadjointView<Lower>().llt().solve(matB));
|
|
||||||
m2 = m1;
|
|
||||||
m2.noalias() += symmLo.template selfadjointView<Lower>().llt().solve(matB);
|
|
||||||
VERIFY_IS_APPROX(m2, m1 + symmLo.template selfadjointView<Lower>().llt().solve(matB));
|
|
||||||
m2 = m1;
|
|
||||||
m2.noalias() -= symmLo.template selfadjointView<Lower>().llt().solve(matB);
|
|
||||||
VERIFY_IS_APPROX(m2, m1 - symmLo.template selfadjointView<Lower>().llt().solve(matB));
|
|
||||||
|
|
||||||
// update/downdate
|
// update/downdate
|
||||||
CALL_SUBTEST(( test_chol_update<SquareMatrixType,LLT>(symm) ));
|
CALL_SUBTEST(( test_chol_update<SquareMatrixType,LLT>(symm) ));
|
||||||
CALL_SUBTEST(( test_chol_update<SquareMatrixType,LDLT>(symm) ));
|
CALL_SUBTEST(( test_chol_update<SquareMatrixType,LDLT>(symm) ));
|
||||||
@ -304,7 +304,8 @@ template<typename MatrixType> void cholesky_verify_assert()
|
|||||||
|
|
||||||
void test_cholesky()
|
void test_cholesky()
|
||||||
{
|
{
|
||||||
int s;
|
int s = 0;
|
||||||
|
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
CALL_SUBTEST_1( cholesky(Matrix<double,1,1>()) );
|
CALL_SUBTEST_1( cholesky(Matrix<double,1,1>()) );
|
||||||
CALL_SUBTEST_3( cholesky(Matrix2d()) );
|
CALL_SUBTEST_3( cholesky(Matrix2d()) );
|
||||||
|
@ -53,8 +53,9 @@ template<typename MatrixType> void determinant(const MatrixType& m)
|
|||||||
|
|
||||||
void test_determinant()
|
void test_determinant()
|
||||||
{
|
{
|
||||||
int s;
|
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
|
int s = 0;
|
||||||
|
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
CALL_SUBTEST_1( determinant(Matrix<float, 1, 1>()) );
|
CALL_SUBTEST_1( determinant(Matrix<float, 1, 1>()) );
|
||||||
CALL_SUBTEST_2( determinant(Matrix<double, 2, 2>()) );
|
CALL_SUBTEST_2( determinant(Matrix<double, 2, 2>()) );
|
||||||
CALL_SUBTEST_3( determinant(Matrix<double, 3, 3>()) );
|
CALL_SUBTEST_3( determinant(Matrix<double, 3, 3>()) );
|
||||||
@ -62,6 +63,6 @@ void test_determinant()
|
|||||||
CALL_SUBTEST_5( determinant(Matrix<std::complex<double>, 10, 10>()) );
|
CALL_SUBTEST_5( determinant(Matrix<std::complex<double>, 10, 10>()) );
|
||||||
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
||||||
CALL_SUBTEST_6( determinant(MatrixXd(s, s)) );
|
CALL_SUBTEST_6( determinant(MatrixXd(s, s)) );
|
||||||
}
|
|
||||||
EIGEN_UNUSED_VARIABLE(s)
|
EIGEN_UNUSED_VARIABLE(s)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -101,7 +101,8 @@ template<typename MatrixType> void eigensolver_verify_assert(const MatrixType& m
|
|||||||
|
|
||||||
void test_eigensolver_complex()
|
void test_eigensolver_complex()
|
||||||
{
|
{
|
||||||
int s;
|
int s = 0;
|
||||||
|
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
CALL_SUBTEST_1( eigensolver(Matrix4cf()) );
|
CALL_SUBTEST_1( eigensolver(Matrix4cf()) );
|
||||||
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
||||||
@ -109,7 +110,6 @@ void test_eigensolver_complex()
|
|||||||
CALL_SUBTEST_3( eigensolver(Matrix<std::complex<float>, 1, 1>()) );
|
CALL_SUBTEST_3( eigensolver(Matrix<std::complex<float>, 1, 1>()) );
|
||||||
CALL_SUBTEST_4( eigensolver(Matrix3f()) );
|
CALL_SUBTEST_4( eigensolver(Matrix3f()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
CALL_SUBTEST_1( eigensolver_verify_assert(Matrix4cf()) );
|
CALL_SUBTEST_1( eigensolver_verify_assert(Matrix4cf()) );
|
||||||
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
||||||
CALL_SUBTEST_2( eigensolver_verify_assert(MatrixXcd(s,s)) );
|
CALL_SUBTEST_2( eigensolver_verify_assert(MatrixXcd(s,s)) );
|
||||||
@ -117,7 +117,7 @@ void test_eigensolver_complex()
|
|||||||
CALL_SUBTEST_4( eigensolver_verify_assert(Matrix3f()) );
|
CALL_SUBTEST_4( eigensolver_verify_assert(Matrix3f()) );
|
||||||
|
|
||||||
// Test problem size constructors
|
// Test problem size constructors
|
||||||
CALL_SUBTEST_5(ComplexEigenSolver<MatrixXf>(s));
|
CALL_SUBTEST_5(ComplexEigenSolver<MatrixXf> tmp(s));
|
||||||
|
|
||||||
EIGEN_UNUSED_VARIABLE(s)
|
EIGEN_UNUSED_VARIABLE(s)
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,9 @@ template<typename MatrixType> void generalized_eigensolver_real(const MatrixType
|
|||||||
|
|
||||||
void test_eigensolver_generalized_real()
|
void test_eigensolver_generalized_real()
|
||||||
{
|
{
|
||||||
int s;
|
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
|
int s = 0;
|
||||||
|
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
CALL_SUBTEST_1( generalized_eigensolver_real(Matrix4f()) );
|
CALL_SUBTEST_1( generalized_eigensolver_real(Matrix4f()) );
|
||||||
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
||||||
CALL_SUBTEST_2( generalized_eigensolver_real(MatrixXd(s,s)) );
|
CALL_SUBTEST_2( generalized_eigensolver_real(MatrixXd(s,s)) );
|
||||||
@ -54,7 +55,6 @@ void test_eigensolver_generalized_real()
|
|||||||
CALL_SUBTEST_2( generalized_eigensolver_real(MatrixXd(2,2)) );
|
CALL_SUBTEST_2( generalized_eigensolver_real(MatrixXd(2,2)) );
|
||||||
CALL_SUBTEST_3( generalized_eigensolver_real(Matrix<double,1,1>()) );
|
CALL_SUBTEST_3( generalized_eigensolver_real(Matrix<double,1,1>()) );
|
||||||
CALL_SUBTEST_4( generalized_eigensolver_real(Matrix2d()) );
|
CALL_SUBTEST_4( generalized_eigensolver_real(Matrix2d()) );
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_UNUSED_VARIABLE(s)
|
EIGEN_UNUSED_VARIABLE(s)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -88,7 +88,8 @@ template<typename MatrixType> void eigensolver_verify_assert(const MatrixType& m
|
|||||||
|
|
||||||
void test_eigensolver_generic()
|
void test_eigensolver_generic()
|
||||||
{
|
{
|
||||||
int s;
|
int s = 0;
|
||||||
|
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
CALL_SUBTEST_1( eigensolver(Matrix4f()) );
|
CALL_SUBTEST_1( eigensolver(Matrix4f()) );
|
||||||
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
||||||
@ -108,7 +109,7 @@ void test_eigensolver_generic()
|
|||||||
CALL_SUBTEST_4( eigensolver_verify_assert(Matrix2d()) );
|
CALL_SUBTEST_4( eigensolver_verify_assert(Matrix2d()) );
|
||||||
|
|
||||||
// Test problem size constructors
|
// Test problem size constructors
|
||||||
CALL_SUBTEST_5(EigenSolver<MatrixXf>(s));
|
CALL_SUBTEST_5(EigenSolver<MatrixXf> tmp(s));
|
||||||
|
|
||||||
// regression test for bug 410
|
// regression test for bug 410
|
||||||
CALL_SUBTEST_2(
|
CALL_SUBTEST_2(
|
||||||
|
@ -110,7 +110,8 @@ template<typename MatrixType> void selfadjointeigensolver(const MatrixType& m)
|
|||||||
|
|
||||||
void test_eigensolver_selfadjoint()
|
void test_eigensolver_selfadjoint()
|
||||||
{
|
{
|
||||||
int s;
|
int s = 0;
|
||||||
|
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
// very important to test 3x3 and 2x2 matrices since we provide special paths for them
|
// very important to test 3x3 and 2x2 matrices since we provide special paths for them
|
||||||
CALL_SUBTEST_1( selfadjointeigensolver(Matrix2d()) );
|
CALL_SUBTEST_1( selfadjointeigensolver(Matrix2d()) );
|
||||||
@ -135,8 +136,8 @@ void test_eigensolver_selfadjoint()
|
|||||||
|
|
||||||
// Test problem size constructors
|
// Test problem size constructors
|
||||||
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
||||||
CALL_SUBTEST_8(SelfAdjointEigenSolver<MatrixXf>(s));
|
CALL_SUBTEST_8(SelfAdjointEigenSolver<MatrixXf> tmp1(s));
|
||||||
CALL_SUBTEST_8(Tridiagonalization<MatrixXf>(s));
|
CALL_SUBTEST_8(Tridiagonalization<MatrixXf> tmp2(s));
|
||||||
|
|
||||||
EIGEN_UNUSED_VARIABLE(s)
|
EIGEN_UNUSED_VARIABLE(s)
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ void test_evaluators()
|
|||||||
VERIFY_IS_APPROX(w,v_const.transpose().eval());
|
VERIFY_IS_APPROX(w,v_const.transpose().eval());
|
||||||
|
|
||||||
// Testing Array evaluator
|
// Testing Array evaluator
|
||||||
|
{
|
||||||
ArrayXXf a(2,3);
|
ArrayXXf a(2,3);
|
||||||
ArrayXXf b(3,2);
|
ArrayXXf b(3,2);
|
||||||
a << 1,2,3, 4,5,6;
|
a << 1,2,3, 4,5,6;
|
||||||
@ -48,6 +49,7 @@ void test_evaluators()
|
|||||||
|
|
||||||
// mix CwiseNullaryOp and transpose
|
// mix CwiseNullaryOp and transpose
|
||||||
VERIFY_IS_APPROX_EVALUATOR(w, Vector2d::Zero().transpose());
|
VERIFY_IS_APPROX_EVALUATOR(w, Vector2d::Zero().transpose());
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// test product expressions
|
// test product expressions
|
||||||
@ -114,6 +116,12 @@ void test_evaluators()
|
|||||||
VERIFY_IS_APPROX_EVALUATOR2(resXX, prod(mXX,mXX), mXX*mXX);
|
VERIFY_IS_APPROX_EVALUATOR2(resXX, prod(mXX,mXX), mXX*mXX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ArrayXXf a(2,3);
|
||||||
|
ArrayXXf b(3,2);
|
||||||
|
a << 1,2,3, 4,5,6;
|
||||||
|
const ArrayXXf a_const(a);
|
||||||
|
|
||||||
// this does not work because Random is eval-before-nested:
|
// this does not work because Random is eval-before-nested:
|
||||||
// copy_using_evaluator(w, Vector2d::Random().transpose());
|
// copy_using_evaluator(w, Vector2d::Random().transpose());
|
||||||
|
|
||||||
@ -272,6 +280,7 @@ void test_evaluators()
|
|||||||
copy_using_evaluator(mat1.diagonal<-1>(), mat1.diagonal(1));
|
copy_using_evaluator(mat1.diagonal<-1>(), mat1.diagonal(1));
|
||||||
mat2.diagonal<-1>() = mat2.diagonal(1);
|
mat2.diagonal<-1>() = mat2.diagonal(1);
|
||||||
VERIFY_IS_APPROX(mat1, mat2);
|
VERIFY_IS_APPROX(mat1, mat2);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// test swapping
|
// test swapping
|
||||||
|
@ -86,7 +86,8 @@ template<typename MatrixType> void inverse(const MatrixType& m)
|
|||||||
|
|
||||||
void test_inverse()
|
void test_inverse()
|
||||||
{
|
{
|
||||||
int s;
|
int s = 0;
|
||||||
|
s = s; // ICC shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
CALL_SUBTEST_1( inverse(Matrix<double,1,1>()) );
|
CALL_SUBTEST_1( inverse(Matrix<double,1,1>()) );
|
||||||
CALL_SUBTEST_2( inverse(Matrix2d()) );
|
CALL_SUBTEST_2( inverse(Matrix2d()) );
|
||||||
|
@ -96,6 +96,10 @@ void jacobisvd_test_all_computation_options(const MatrixType& m)
|
|||||||
jacobisvd_check_full(m, fullSvd);
|
jacobisvd_check_full(m, fullSvd);
|
||||||
jacobisvd_solve<MatrixType, QRPreconditioner>(m, ComputeFullU | ComputeFullV);
|
jacobisvd_solve<MatrixType, QRPreconditioner>(m, ComputeFullU | ComputeFullV);
|
||||||
|
|
||||||
|
#if defined __INTEL_COMPILER
|
||||||
|
// remark #111: statement is unreachable
|
||||||
|
#pragma warning disable 111
|
||||||
|
#endif
|
||||||
if(QRPreconditioner == FullPivHouseholderQRPreconditioner)
|
if(QRPreconditioner == FullPivHouseholderQRPreconditioner)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -257,7 +261,7 @@ void jacobisvd_preallocate()
|
|||||||
MatrixXf m = v.asDiagonal();
|
MatrixXf m = v.asDiagonal();
|
||||||
|
|
||||||
internal::set_is_malloc_allowed(false);
|
internal::set_is_malloc_allowed(false);
|
||||||
VERIFY_RAISES_ASSERT(VectorXf v(10);)
|
VERIFY_RAISES_ASSERT(VectorXf tmp(10);)
|
||||||
JacobiSVD<MatrixXf> svd;
|
JacobiSVD<MatrixXf> svd;
|
||||||
internal::set_is_malloc_allowed(true);
|
internal::set_is_malloc_allowed(true);
|
||||||
svd.compute(m);
|
svd.compute(m);
|
||||||
@ -320,6 +324,8 @@ void test_jacobisvd()
|
|||||||
|
|
||||||
int r = internal::random<int>(1, 30),
|
int r = internal::random<int>(1, 30),
|
||||||
c = internal::random<int>(1, 30);
|
c = internal::random<int>(1, 30);
|
||||||
|
r = r; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
|
c = c;
|
||||||
CALL_SUBTEST_7(( jacobisvd<MatrixXf>(MatrixXf(r,c)) ));
|
CALL_SUBTEST_7(( jacobisvd<MatrixXf>(MatrixXf(r,c)) ));
|
||||||
CALL_SUBTEST_8(( jacobisvd<MatrixXcd>(MatrixXcd(r,c)) ));
|
CALL_SUBTEST_8(( jacobisvd<MatrixXcd>(MatrixXcd(r,c)) ));
|
||||||
(void) r;
|
(void) r;
|
||||||
|
27
test/main.h
27
test/main.h
@ -49,11 +49,6 @@
|
|||||||
|
|
||||||
#define DEFAULT_REPEAT 10
|
#define DEFAULT_REPEAT 10
|
||||||
|
|
||||||
#ifdef __ICC
|
|
||||||
// disable warning #279: controlling expression is constant
|
|
||||||
#pragma warning disable 279
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Eigen
|
namespace Eigen
|
||||||
{
|
{
|
||||||
static std::vector<std::string> g_test_stack;
|
static std::vector<std::string> g_test_stack;
|
||||||
@ -170,7 +165,7 @@ namespace Eigen
|
|||||||
#define EIGEN_INTERNAL_DEBUGGING
|
#define EIGEN_INTERNAL_DEBUGGING
|
||||||
#include <Eigen/QR> // required for createRandomPIMatrixOfRank
|
#include <Eigen/QR> // required for createRandomPIMatrixOfRank
|
||||||
|
|
||||||
static inline void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string)
|
inline void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string)
|
||||||
{
|
{
|
||||||
if (!condition)
|
if (!condition)
|
||||||
{
|
{
|
||||||
@ -297,7 +292,7 @@ inline bool test_isUnitary(const MatrixBase<Derived>& m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
static bool test_is_equal(const T& actual, const U& expected)
|
inline bool test_is_equal(const T& actual, const U& expected)
|
||||||
{
|
{
|
||||||
if (actual==expected)
|
if (actual==expected)
|
||||||
return true;
|
return true;
|
||||||
@ -313,8 +308,11 @@ static bool test_is_equal(const T& actual, const U& expected)
|
|||||||
* A partial isometry is a matrix all of whose singular values are either 0 or 1.
|
* A partial isometry is a matrix all of whose singular values are either 0 or 1.
|
||||||
* This is very useful to test rank-revealing algorithms.
|
* This is very useful to test rank-revealing algorithms.
|
||||||
*/
|
*/
|
||||||
|
// Forward declaration to avoid ICC warning
|
||||||
template<typename MatrixType>
|
template<typename MatrixType>
|
||||||
static void createRandomPIMatrixOfRank(typename MatrixType::Index desired_rank, typename MatrixType::Index rows, typename MatrixType::Index cols, MatrixType& m)
|
void createRandomPIMatrixOfRank(typename MatrixType::Index desired_rank, typename MatrixType::Index rows, typename MatrixType::Index cols, MatrixType& m);
|
||||||
|
template<typename MatrixType>
|
||||||
|
void createRandomPIMatrixOfRank(typename MatrixType::Index desired_rank, typename MatrixType::Index rows, typename MatrixType::Index cols, MatrixType& m)
|
||||||
{
|
{
|
||||||
typedef typename internal::traits<MatrixType>::Index Index;
|
typedef typename internal::traits<MatrixType>::Index Index;
|
||||||
typedef typename internal::traits<MatrixType>::Scalar Scalar;
|
typedef typename internal::traits<MatrixType>::Scalar Scalar;
|
||||||
@ -351,8 +349,11 @@ static void createRandomPIMatrixOfRank(typename MatrixType::Index desired_rank,
|
|||||||
m = qra.householderQ() * d * qrb.householderQ();
|
m = qra.householderQ() * d * qrb.householderQ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward declaration to avoid ICC warning
|
||||||
template<typename PermutationVectorType>
|
template<typename PermutationVectorType>
|
||||||
static void randomPermutationVector(PermutationVectorType& v, typename PermutationVectorType::Index size)
|
void randomPermutationVector(PermutationVectorType& v, typename PermutationVectorType::Index size);
|
||||||
|
template<typename PermutationVectorType>
|
||||||
|
void randomPermutationVector(PermutationVectorType& v, typename PermutationVectorType::Index size)
|
||||||
{
|
{
|
||||||
typedef typename PermutationVectorType::Index Index;
|
typedef typename PermutationVectorType::Index Index;
|
||||||
typedef typename PermutationVectorType::Scalar Scalar;
|
typedef typename PermutationVectorType::Scalar Scalar;
|
||||||
@ -392,7 +393,7 @@ void EIGEN_CAT(test_,EIGEN_TEST_FUNC)();
|
|||||||
|
|
||||||
using namespace Eigen;
|
using namespace Eigen;
|
||||||
|
|
||||||
static void set_repeat_from_string(const char *str)
|
inline void set_repeat_from_string(const char *str)
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
g_repeat = int(strtoul(str, 0, 10));
|
g_repeat = int(strtoul(str, 0, 10));
|
||||||
@ -404,7 +405,7 @@ static void set_repeat_from_string(const char *str)
|
|||||||
g_has_set_repeat = true;
|
g_has_set_repeat = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_seed_from_string(const char *str)
|
inline void set_seed_from_string(const char *str)
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
g_seed = int(strtoul(str, 0, 10));
|
g_seed = int(strtoul(str, 0, 10));
|
||||||
@ -488,5 +489,7 @@ int main(int argc, char *argv[])
|
|||||||
// -> this warning is raised even for legal usage as: g_test_stack.push_back("foo"); where g_test_stack is a std::vector<std::string>
|
// -> this warning is raised even for legal usage as: g_test_stack.push_back("foo"); where g_test_stack is a std::vector<std::string>
|
||||||
// remark #1418: external function definition with no prior declaration
|
// remark #1418: external function definition with no prior declaration
|
||||||
// -> this warning is raised for all our test functions. Declaring them static would fix the issue.
|
// -> this warning is raised for all our test functions. Declaring them static would fix the issue.
|
||||||
#pragma warning disable 383 1418
|
// warning #279: controlling expression is constant
|
||||||
|
// remark #1572: floating-point equality and inequality comparisons are unreliable
|
||||||
|
#pragma warning disable 279 383 1418 1572
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
static int nb_temporaries;
|
static int nb_temporaries;
|
||||||
|
|
||||||
void on_temporary_creation(int size) {
|
inline void on_temporary_creation(int size) {
|
||||||
// here's a great place to set a breakpoint when debugging failures in this test!
|
// here's a great place to set a breakpoint when debugging failures in this test!
|
||||||
if(size!=0) nb_temporaries++;
|
if(size!=0) nb_temporaries++;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,8 @@ template<typename MatrixType> void product_selfadjoint(const MatrixType& m)
|
|||||||
|
|
||||||
void test_product_selfadjoint()
|
void test_product_selfadjoint()
|
||||||
{
|
{
|
||||||
int s;
|
int s = 0;
|
||||||
|
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
for(int i = 0; i < g_repeat ; i++) {
|
for(int i = 0; i < g_repeat ; i++) {
|
||||||
CALL_SUBTEST_1( product_selfadjoint(Matrix<float, 1, 1>()) );
|
CALL_SUBTEST_1( product_selfadjoint(Matrix<float, 1, 1>()) );
|
||||||
CALL_SUBTEST_2( product_selfadjoint(Matrix<float, 2, 2>()) );
|
CALL_SUBTEST_2( product_selfadjoint(Matrix<float, 2, 2>()) );
|
||||||
|
@ -73,7 +73,8 @@ template<typename MatrixType> void trmv(const MatrixType& m)
|
|||||||
|
|
||||||
void test_product_trmv()
|
void test_product_trmv()
|
||||||
{
|
{
|
||||||
int s;
|
int s = 0;
|
||||||
|
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
for(int i = 0; i < g_repeat ; i++) {
|
for(int i = 0; i < g_repeat ; i++) {
|
||||||
CALL_SUBTEST_1( trmv(Matrix<float, 1, 1>()) );
|
CALL_SUBTEST_1( trmv(Matrix<float, 1, 1>()) );
|
||||||
CALL_SUBTEST_2( trmv(Matrix<float, 2, 2>()) );
|
CALL_SUBTEST_2( trmv(Matrix<float, 2, 2>()) );
|
||||||
|
@ -48,7 +48,8 @@ template<typename MatrixType> void real_qz(const MatrixType& m)
|
|||||||
|
|
||||||
void test_real_qz()
|
void test_real_qz()
|
||||||
{
|
{
|
||||||
int s;
|
int s = 0;
|
||||||
|
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
CALL_SUBTEST_1( real_qz(Matrix4f()) );
|
CALL_SUBTEST_1( real_qz(Matrix4f()) );
|
||||||
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
||||||
|
@ -133,6 +133,7 @@ void test_redux()
|
|||||||
{
|
{
|
||||||
// the max size cannot be too large, otherwise reduxion operations obviously generate large errors.
|
// the max size cannot be too large, otherwise reduxion operations obviously generate large errors.
|
||||||
int maxsize = (std::min)(100,EIGEN_TEST_MAX_SIZE);
|
int maxsize = (std::min)(100,EIGEN_TEST_MAX_SIZE);
|
||||||
|
maxsize = maxsize; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
EIGEN_UNUSED_VARIABLE(maxsize);
|
EIGEN_UNUSED_VARIABLE(maxsize);
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
CALL_SUBTEST_1( matrixRedux(Matrix<float, 1, 1>()) );
|
CALL_SUBTEST_1( matrixRedux(Matrix<float, 1, 1>()) );
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
static int nb_temporaries;
|
static int nb_temporaries;
|
||||||
|
|
||||||
void on_temporary_creation(int size) {
|
inline void on_temporary_creation(int size) {
|
||||||
// here's a great place to set a breakpoint when debugging failures in this test!
|
// here's a great place to set a breakpoint when debugging failures in this test!
|
||||||
if(size!=0) nb_temporaries++;
|
if(size!=0) nb_temporaries++;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,8 @@ void test_selfadjoint()
|
|||||||
{
|
{
|
||||||
for(int i = 0; i < g_repeat ; i++)
|
for(int i = 0; i < g_repeat ; i++)
|
||||||
{
|
{
|
||||||
int s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE); EIGEN_UNUSED_VARIABLE(s);
|
int s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE);
|
||||||
|
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
|
|
||||||
CALL_SUBTEST_1( selfadjoint(Matrix<float, 1, 1>()) );
|
CALL_SUBTEST_1( selfadjoint(Matrix<float, 1, 1>()) );
|
||||||
CALL_SUBTEST_2( selfadjoint(Matrix<float, 2, 2>()) );
|
CALL_SUBTEST_2( selfadjoint(Matrix<float, 2, 2>()) );
|
||||||
|
@ -25,10 +25,11 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
|||||||
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
||||||
Scalar eps = 1e-6;
|
Scalar eps = 1e-6;
|
||||||
|
|
||||||
|
Scalar s1 = internal::random<Scalar>();
|
||||||
|
{
|
||||||
SparseMatrixType m(rows, cols);
|
SparseMatrixType m(rows, cols);
|
||||||
DenseMatrix refMat = DenseMatrix::Zero(rows, cols);
|
DenseMatrix refMat = DenseMatrix::Zero(rows, cols);
|
||||||
DenseVector vec1 = DenseVector::Random(rows);
|
DenseVector vec1 = DenseVector::Random(rows);
|
||||||
Scalar s1 = internal::random<Scalar>();
|
|
||||||
|
|
||||||
std::vector<Vector2i> zeroCoords;
|
std::vector<Vector2i> zeroCoords;
|
||||||
std::vector<Vector2i> nonzeroCoords;
|
std::vector<Vector2i> nonzeroCoords;
|
||||||
@ -90,6 +91,7 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
|||||||
VERIFY_IS_APPROX(m.row(r) + m.row(r), refMat.row(r) + refMat.row(r));
|
VERIFY_IS_APPROX(m.row(r) + m.row(r), refMat.row(r) + refMat.row(r));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
// test insert (inner random)
|
// test insert (inner random)
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ void check_sparse_solving(Solver& solver, const typename Solver::MatrixType& A,
|
|||||||
typedef typename Mat::Scalar Scalar;
|
typedef typename Mat::Scalar Scalar;
|
||||||
|
|
||||||
DenseRhs refX = dA.lu().solve(db);
|
DenseRhs refX = dA.lu().solve(db);
|
||||||
|
{
|
||||||
Rhs x(b.rows(), b.cols());
|
Rhs x(b.rows(), b.cols());
|
||||||
Rhs oldb = b;
|
Rhs oldb = b;
|
||||||
|
|
||||||
@ -56,14 +56,15 @@ void check_sparse_solving(Solver& solver, const typename Solver::MatrixType& A,
|
|||||||
VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!");
|
VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!");
|
||||||
|
|
||||||
VERIFY(x.isApprox(refX,test_precision<Scalar>()));
|
VERIFY(x.isApprox(refX,test_precision<Scalar>()));
|
||||||
|
}
|
||||||
|
|
||||||
// test Block as the result and rhs:
|
// test dense Block as the result and rhs:
|
||||||
{
|
{
|
||||||
DenseRhs x(db.rows(), db.cols());
|
DenseRhs x(db.rows(), db.cols());
|
||||||
DenseRhs b(db), oldb(db);
|
DenseRhs oldb(db);
|
||||||
x.setZero();
|
x.setZero();
|
||||||
x.block(0,0,x.rows(),x.cols()) = solver.solve(b.block(0,0,b.rows(),b.cols()));
|
x.block(0,0,x.rows(),x.cols()) = solver.solve(db.block(0,0,db.rows(),db.cols()));
|
||||||
VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!");
|
VERIFY(oldb.isApprox(db) && "sparse solver testing: the rhs should not be modified!");
|
||||||
VERIFY(x.isApprox(refX,test_precision<Scalar>()));
|
VERIFY(x.isApprox(refX,test_precision<Scalar>()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,8 +211,8 @@ void test_triangular()
|
|||||||
int maxsize = (std::min)(EIGEN_TEST_MAX_SIZE,20);
|
int maxsize = (std::min)(EIGEN_TEST_MAX_SIZE,20);
|
||||||
for(int i = 0; i < g_repeat ; i++)
|
for(int i = 0; i < g_repeat ; i++)
|
||||||
{
|
{
|
||||||
int r = internal::random<int>(2,maxsize); EIGEN_UNUSED_VARIABLE(r);
|
int r = internal::random<int>(2,maxsize); r=r; // shuts down ICC's remark #593: variable "s" was set but never used
|
||||||
int c = internal::random<int>(2,maxsize); EIGEN_UNUSED_VARIABLE(c);
|
int c = internal::random<int>(2,maxsize); c=c;
|
||||||
|
|
||||||
CALL_SUBTEST_1( triangular_square(Matrix<float, 1, 1>()) );
|
CALL_SUBTEST_1( triangular_square(Matrix<float, 1, 1>()) );
|
||||||
CALL_SUBTEST_2( triangular_square(Matrix<float, 2, 2>()) );
|
CALL_SUBTEST_2( triangular_square(Matrix<float, 2, 2>()) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user