mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-19 16:19:37 +08:00
Factorize VERIFY_EVALUATION_COUNT in unit tests
This commit is contained in:
parent
5c84dd5665
commit
6318d53b41
@ -11,21 +11,12 @@
|
|||||||
#define EIGEN_NO_ASSERTION_CHECKING
|
#define EIGEN_NO_ASSERTION_CHECKING
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int nb_temporaries;
|
#define TEST_ENABLE_TEMPORARY_TRACKING
|
||||||
|
|
||||||
#define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { if(size!=0) nb_temporaries++; }
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <Eigen/Cholesky>
|
#include <Eigen/Cholesky>
|
||||||
#include <Eigen/QR>
|
#include <Eigen/QR>
|
||||||
|
|
||||||
#define VERIFY_EVALUATION_COUNT(XPR,N) {\
|
|
||||||
nb_temporaries = 0; \
|
|
||||||
XPR; \
|
|
||||||
if(nb_temporaries!=N) std::cerr << "nb_temporaries == " << nb_temporaries << "\n"; \
|
|
||||||
VERIFY( (#XPR) && nb_temporaries==N ); \
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename MatrixType,template <typename,int> class CholType> void test_chol_update(const MatrixType& symm)
|
template<typename MatrixType,template <typename,int> class CholType> void test_chol_update(const MatrixType& symm)
|
||||||
{
|
{
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
|
20
test/main.h
20
test/main.h
@ -69,6 +69,26 @@
|
|||||||
// shuts down ICC's remark #593: variable "XXX" was set but never used
|
// shuts down ICC's remark #593: variable "XXX" was set but never used
|
||||||
#define TEST_SET_BUT_UNUSED_VARIABLE(X) EIGEN_UNUSED_VARIABLE(X)
|
#define TEST_SET_BUT_UNUSED_VARIABLE(X) EIGEN_UNUSED_VARIABLE(X)
|
||||||
|
|
||||||
|
#ifdef TEST_ENABLE_TEMPORARY_TRACKING
|
||||||
|
|
||||||
|
static long int nb_temporaries;
|
||||||
|
|
||||||
|
inline void on_temporary_creation(long int size) {
|
||||||
|
// here's a great place to set a breakpoint when debugging failures in this test!
|
||||||
|
if(size!=0) nb_temporaries++;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { on_temporary_creation(size); }
|
||||||
|
|
||||||
|
#define VERIFY_EVALUATION_COUNT(XPR,N) {\
|
||||||
|
nb_temporaries = 0; \
|
||||||
|
XPR; \
|
||||||
|
if(nb_temporaries!=N) std::cerr << "nb_temporaries == " << nb_temporaries << "\n"; \
|
||||||
|
VERIFY( (#XPR) && nb_temporaries==N ); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// the following file is automatically generated by cmake
|
// the following file is automatically generated by cmake
|
||||||
#include "split_test_helper.h"
|
#include "split_test_helper.h"
|
||||||
|
|
||||||
|
@ -7,24 +7,10 @@
|
|||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
static long int nb_temporaries;
|
#define TEST_ENABLE_TEMPORARY_TRACKING
|
||||||
|
|
||||||
inline void on_temporary_creation(long int size) {
|
|
||||||
// here's a great place to set a breakpoint when debugging failures in this test!
|
|
||||||
if(size!=0) nb_temporaries++;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { on_temporary_creation(size); }
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#define VERIFY_EVALUATION_COUNT(XPR,N) {\
|
|
||||||
nb_temporaries = 0; \
|
|
||||||
XPR; \
|
|
||||||
if(nb_temporaries!=N) std::cerr << "nb_temporaries == " << nb_temporaries << "\n"; \
|
|
||||||
VERIFY( (#XPR) && nb_temporaries==N ); \
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename MatrixType> void product_notemporary(const MatrixType& m)
|
template<typename MatrixType> void product_notemporary(const MatrixType& m)
|
||||||
{
|
{
|
||||||
/* This test checks the number of temporaries created
|
/* This test checks the number of temporaries created
|
||||||
|
17
test/ref.cpp
17
test/ref.cpp
@ -12,25 +12,10 @@
|
|||||||
#undef EIGEN_DEFAULT_TO_ROW_MAJOR
|
#undef EIGEN_DEFAULT_TO_ROW_MAJOR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static long int nb_temporaries;
|
#define TEST_ENABLE_TEMPORARY_TRACKING
|
||||||
|
|
||||||
inline void on_temporary_creation(long int) {
|
|
||||||
// here's a great place to set a breakpoint when debugging failures in this test!
|
|
||||||
nb_temporaries++;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { on_temporary_creation(size); }
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#define VERIFY_EVALUATION_COUNT(XPR,N) {\
|
|
||||||
nb_temporaries = 0; \
|
|
||||||
XPR; \
|
|
||||||
if(nb_temporaries!=N) std::cerr << "nb_temporaries == " << nb_temporaries << "\n"; \
|
|
||||||
VERIFY( (#XPR) && nb_temporaries==N ); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// test Ref.h
|
// test Ref.h
|
||||||
|
|
||||||
template<typename MatrixType> void ref_matrix(const MatrixType& m)
|
template<typename MatrixType> void ref_matrix(const MatrixType& m)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user