11 #define TEST_ENABLE_TEMPORARY_TRACKING 12 #define EIGEN_NO_STATIC_ASSERT 24 Index r = internal::random<Index>(0, rows-1),
25 c = internal::random<Index>(0, cols-1);
27 ArrayType
m1 = ArrayType::Random(rows, cols),
31 ColVectorType colvec = ColVectorType::Random(rows);
32 RowVectorType rowvec = RowVectorType::Random(cols);
37 m2.colwise() += colvec;
45 m2.rowwise() += rowvec;
55 m2.colwise() -= colvec;
63 m2.rowwise() -= rowvec;
73 m2.colwise() *= colvec;
81 m2.rowwise() *= rowvec;
91 m2.colwise() /= colvec;
99 m2.rowwise() /= rowvec;
110 if(ArrayType::RowsAtCompileTime>2 || ArrayType::RowsAtCompileTime==
Dynamic)
112 m2.rowwise() /= m2.colwise().sum();
118 mb = (m1.real()<=0.7).colwise().all();
119 VERIFY( (mb.col(
c) == (m1.real().col(
c)<=0.7).all()).
all() );
120 mb = (m1.real()<=0.7).rowwise().all();
121 VERIFY( (mb.row(r) == (m1.real().row(r)<=0.7).all()).
all() );
123 mb = (m1.real()>=0.7).colwise().any();
124 VERIFY( (mb.col(
c) == (m1.real().col(
c)>=0.7).any()).
all() );
125 mb = (m1.real()>=0.7).rowwise().any();
126 VERIFY( (mb.row(r) == (m1.real().row(r)>=0.7).any()).
all() );
141 Index r = internal::random<Index>(0, rows-1),
142 c = internal::random<Index>(0, cols-1);
148 ColVectorType colvec = ColVectorType::Random(rows);
149 RowVectorType rowvec = RowVectorType::Random(cols);
150 RealColVectorType rcres;
151 RealRowVectorType rrres;
155 m2.colwise() = colvec;
158 m2.rowwise() = rowvec;
169 m2.colwise() += colvec;
180 m2.rowwise() += rowvec;
193 m2.colwise() -= colvec;
204 m2.rowwise() -= rowvec;
216 #define TEST_PARTIAL_REDUX_BASIC(FUNC,ROW,COL,PREPROCESS) { \ 217 ROW = m1 PREPROCESS .colwise().FUNC ; \ 218 for(Index k=0; k<cols; ++k) VERIFY_IS_APPROX(ROW(k), m1.col(k) PREPROCESS .FUNC ); \ 219 COL = m1 PREPROCESS .rowwise().FUNC ; \ 220 for(Index k=0; k<rows; ++k) VERIFY_IS_APPROX(COL(k), m1.row(k) PREPROCESS .FUNC ); \ 232 VERIFY_IS_APPROX(m1.cwiseAbs().colwise().sum(), m1.colwise().template lpNorm<1>());
233 VERIFY_IS_APPROX(m1.cwiseAbs().rowwise().sum(), m1.rowwise().template lpNorm<1>());
234 VERIFY_IS_APPROX(m1.cwiseAbs().colwise().maxCoeff(), m1.colwise().template lpNorm<Infinity>());
235 VERIFY_IS_APPROX(m1.cwiseAbs().rowwise().maxCoeff(), m1.rowwise().template lpNorm<Infinity>());
238 VERIFY_IS_APPROX(m1.cwiseAbs().colwise().sum().x(), m1.col(0).cwiseAbs().sum());
241 m2 = m1.colwise().normalized();
243 m2 = m1.rowwise().normalized();
248 m2.colwise().normalize();
251 m2.rowwise().normalize();
256 VERIFY_IS_APPROX( (m1 * m1.transpose()).colwise().sum(), m1m1.colwise().sum());
260 m2 = m1.rowwise() - (m1.colwise().sum()/
RealScalar(m1.rows())).eval();
261 m1 = m1.rowwise() - (m1.colwise().sum()/
RealScalar(m1.rows()));
266 VERIFY_IS_APPROX(m1.matrix().middleCols(0,0).rowwise().sum().eval(), MatrixX::Zero(rows,1));
267 VERIFY_IS_APPROX(m1.matrix().middleRows(0,0).colwise().sum().eval(), MatrixX::Zero(1,cols));
268 VERIFY_IS_APPROX(m1.matrix().middleCols(0,fix<0>).rowwise().sum().eval(), MatrixX::Zero(rows,1));
269 VERIFY_IS_APPROX(m1.matrix().middleRows(0,fix<0>).colwise().sum().eval(), MatrixX::Zero(1,cols));
271 VERIFY_IS_APPROX(m1.matrix().middleCols(0,0).rowwise().prod().eval(), MatrixX::Ones(rows,1));
272 VERIFY_IS_APPROX(m1.matrix().middleRows(0,0).colwise().prod().eval(), MatrixX::Ones(1,cols));
273 VERIFY_IS_APPROX(m1.matrix().middleCols(0,fix<0>).rowwise().prod().eval(), MatrixX::Ones(rows,1));
274 VERIFY_IS_APPROX(m1.matrix().middleRows(0,fix<0>).colwise().prod().eval(), MatrixX::Ones(1,cols));
276 VERIFY_IS_APPROX(m1.matrix().middleCols(0,0).rowwise().squaredNorm().eval(), MatrixX::Zero(rows,1));
280 VERIFY_IS_EQUAL(m1.real().middleRows(0,0).rowwise().maxCoeff().eval().rows(),0);
281 VERIFY_IS_EQUAL(m1.real().middleCols(0,0).colwise().maxCoeff().eval().cols(),0);
282 VERIFY_IS_EQUAL(m1.real().middleRows(0,fix<0>).rowwise().maxCoeff().eval().rows(),0);
283 VERIFY_IS_EQUAL(m1.real().middleCols(0,fix<0>).colwise().maxCoeff().eval().cols(),0);
#define VERIFY_RAISES_ASSERT(a)
#define CALL_SUBTEST_6(FUNC)
#define CALL_SUBTEST_4(FUNC)
static const Eigen::internal::all_t all
#define CALL_SUBTEST_3(FUNC)
EIGEN_DECLARE_TEST(vectorwiseop)
#define CALL_SUBTEST_7(FUNC)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
static const Vector2 mean(20, 40)
void vectorwiseop_matrix(const MatrixType &m)
#define VERIFY_EVALUATION_COUNT(XPR, N)
#define VERIFY_IS_APPROX(a, b)
#define VERIFY_IS_EQUAL(a, b)
#define CALL_SUBTEST_1(FUNC)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DONT_INLINE void prod(const Lhs &a, const Rhs &b, Res &c)
NumTraits< Scalar >::Real RealScalar
#define CALL_SUBTEST_5(FUNC)
#define EIGEN_TEST_MAX_SIZE
General-purpose arrays with easy API for coefficient-wise operations.
#define TEST_PARTIAL_REDUX_BASIC(FUNC, ROW, COL, PREPROCESS)
void vectorwiseop_array(const ArrayType &m)
#define CALL_SUBTEST_2(FUNC)
The matrix class, also used for vectors and row-vectors.