mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -12,28 +12,26 @@
|
||||
#include "main.h"
|
||||
|
||||
typedef NestByValue<MatrixXd> CpyMatrixXd;
|
||||
typedef CwiseBinaryOp<internal::scalar_sum_op<double,double>,const CpyMatrixXd,const CpyMatrixXd> XprType;
|
||||
typedef CwiseBinaryOp<internal::scalar_sum_op<double, double>, const CpyMatrixXd, const CpyMatrixXd> XprType;
|
||||
|
||||
XprType get_xpr_with_temps(const MatrixXd& a)
|
||||
{
|
||||
XprType get_xpr_with_temps(const MatrixXd& a) {
|
||||
MatrixXd t1 = a.rowwise().reverse();
|
||||
MatrixXd t2 = a+a;
|
||||
MatrixXd t2 = a + a;
|
||||
return t1.nestByValue() + t2.nestByValue();
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(nestbyvalue)
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
Index rows = internal::random<Index>(1,EIGEN_TEST_MAX_SIZE);
|
||||
Index cols = internal::random<Index>(1,EIGEN_TEST_MAX_SIZE);
|
||||
MatrixXd a = MatrixXd::Random(rows,cols);
|
||||
EIGEN_DECLARE_TEST(nestbyvalue) {
|
||||
for (int i = 0; i < g_repeat; i++) {
|
||||
Index rows = internal::random<Index>(1, EIGEN_TEST_MAX_SIZE);
|
||||
Index cols = internal::random<Index>(1, EIGEN_TEST_MAX_SIZE);
|
||||
MatrixXd a = MatrixXd::Random(rows, cols);
|
||||
nb_temporaries = 0;
|
||||
XprType x = get_xpr_with_temps(a);
|
||||
VERIFY_IS_EQUAL(nb_temporaries,6);
|
||||
VERIFY_IS_EQUAL(nb_temporaries, 6);
|
||||
MatrixXd b = x;
|
||||
VERIFY_IS_EQUAL(nb_temporaries,6+1);
|
||||
VERIFY_IS_APPROX(b, a.rowwise().reverse().eval() + (a+a).eval());
|
||||
VERIFY_IS_EQUAL(nb_temporaries, 6 + 1);
|
||||
VERIFY_IS_APPROX(b, a.rowwise().reverse().eval() + (a + a).eval());
|
||||
// Block expressions work with dense NestByValue.
|
||||
VERIFY_IS_APPROX(b, a.nestByValue().rowwise().reverse().eval() + (a.nestByValue()+a.nestByValue()).eval());
|
||||
VERIFY_IS_APPROX(b, a.nestByValue().rowwise().reverse().eval() + (a.nestByValue() + a.nestByValue()).eval());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user