22 m2 = MatrixType::Random(rows, cols),
25 ColVectorType cv1 = ColVectorType::Random(rows);
26 RowVectorType rv1 = RowVectorType::Random(cols);
28 Scalar s1 = internal::random<Scalar>(),
29 s2 = internal::random<Scalar>();
47 VERIFY_IS_APPROX(m1.colwise().sum(), m1.colwise().redux(internal::scalar_sum_op<Scalar,Scalar>()));
60 VERIFY_IS_APPROX((m1.template block<0,Dynamic>(0,0,0,cols).colwise().sum()), RowVectorType::Zero(cols));
61 VERIFY_IS_APPROX((m1.template block<Dynamic,0>(0,0,rows,0).rowwise().sum()), ColVectorType::Zero(rows));
62 VERIFY_IS_APPROX((m1.template block<0,Dynamic>(0,0,0,cols).colwise().prod()), RowVectorType::Ones(cols));
63 VERIFY_IS_APPROX((m1.template block<Dynamic,0>(0,0,rows,0).rowwise().prod()), ColVectorType::Ones(rows));
65 VERIFY_IS_APPROX(m1.block(0,0,0,cols).colwise().sum(), RowVectorType::Zero(cols));
66 VERIFY_IS_APPROX(m1.block(0,0,rows,0).rowwise().sum(), ColVectorType::Zero(rows));
67 VERIFY_IS_APPROX(m1.block(0,0,0,cols).colwise().prod(), RowVectorType::Ones(cols));
68 VERIFY_IS_APPROX(m1.block(0,0,rows,0).rowwise().prod(), ColVectorType::Ones(rows));
71 const Scalar& ref_m1 = m.matrix().array().coeffRef(0);
72 const Scalar& ref_m2 = m.matrix().array().coeffRef(0,0);
73 const Scalar& ref_a1 = m.array().matrix().coeffRef(0);
74 const Scalar& ref_a2 = m.array().matrix().coeffRef(0,0);
75 VERIFY(&ref_a1 == &ref_m1);
76 VERIFY(&ref_a2 == &ref_m2);
79 m1.array().coeffRef(0,0) = 1;
83 m1.array().matrix().coeffRef(0,0) = 3;
85 m1.array().matrix()(0,0) = 4;
98 Index r = internal::random<Index>(0, rows-1),
99 c = internal::random<Index>(0, cols-1);
102 m2 = MatrixType::Random(rows, cols),
111 VERIFY(! (m1.array() < m3.array()).
all() );
112 VERIFY(! (m1.array() > m3.array()).
all() );
116 VERIFY( (m1.array() != (
m1(r,
c)+1) ).any() );
117 VERIFY( (m1.array() > (
m1(r,
c)-1) ).any() );
118 VERIFY( (m1.array() < (
m1(r,
c)+1) ).any() );
119 VERIFY( (m1.array() ==
m1(r,
c) ).any() );
120 VERIFY( m1.cwiseEqual(m1(r,
c)).any() );
125 Scalar mid = (m1.cwiseAbs().minCoeff() + m1.cwiseAbs().maxCoeff())/
Scalar(2);
129 VERIFY_IS_APPROX( (m1.array().abs()<MatrixType::Constant(rows,cols,mid).array())
130 .select(MatrixType::Zero(rows,cols),
m1), m3);
132 VERIFY_IS_APPROX( (m1.array().abs()<MatrixType::Constant(rows,cols,mid).array())
134 VERIFY_IS_APPROX( (m1.array().abs()>=MatrixType::Constant(rows,cols,mid).array())
145 RealScalar
a = m1.cwiseAbs().mean();
146 VERIFY( ((m1.array()<-
a).
matrix() || (m1.array()>
a).
matrix()).count() == (m1.cwiseAbs().array()>
a).count());
188 Scalar maxM1 = m1.maxCoeff();
189 Scalar minM1 = m1.minCoeff();
191 VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, minM1), m1.cwiseMin(MatrixType::Constant(rows,cols, minM1)));
194 VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, maxM1), m1.cwiseMax(MatrixType::Constant(rows,cols, maxM1)));
198 VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, minM1), m1.cwiseMin( minM1));
203 VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, maxM1), m1.cwiseMax( maxM1));
216 template<
typename MatrixTraits>
void resize(
const MatrixTraits&
t)
226 MatrixType
m(rows,
cols);
228 Array2DType
a2(rows,
cols);
229 Array1DType
a1(rows);
231 m.array().resize(rows+1,
cols+1);
233 a2.matrix().resize(rows+1,
cols+1);
234 VERIFY(a2.rows()==rows+1 && a2.cols()==
cols+1);
235 v.array().resize(
cols);
237 a1.matrix().resize(
cols);
244 ArrayXf
a = RowVectorXf(3);
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp< internal::scalar_max_op< Scalar, Scalar >, const Derived, const OtherDerived > cwiseMax(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
#define CALL_SUBTEST_6(FUNC)
#define CALL_SUBTEST_4(FUNC)
Matrix< RealScalar, Dynamic, Dynamic > M
static const Eigen::internal::all_t all
Expression of a mathematical vector or matrix as an array object.
#define CALL_SUBTEST_3(FUNC)
void regrrssion_bug_1410()
#define CALL_SUBTEST_7(FUNC)
const unsigned int LvalueBit
EIGEN_DEVICE_FUNC ArrayBase< Derived > & array()
EIGEN_DEVICE_FUNC MatrixBase< Derived > & matrix()
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Expression of an array as a mathematical vector or matrix.
#define VERIFY_IS_APPROX(a, b)
void lpNorm(const VectorType &v)
#define CALL_SUBTEST_1(FUNC)
void resize(const MatrixTraits &t)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Array< int, Dynamic, 1 > v
#define CALL_SUBTEST_8(FUNC)
void regression_bug_654()
NumTraits< Scalar >::Real RealScalar
#define VERIFY_IS_MUCH_SMALLER_THAN(a, b)
#define CALL_SUBTEST_5(FUNC)
#define EIGEN_TEST_MAX_SIZE
void array_for_matrix(const MatrixType &m)
General-purpose arrays with easy API for coefficient-wise operations.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE RowXpr row(Index i)
EIGEN_DECLARE_TEST(array_for_matrix)
#define CALL_SUBTEST_2(FUNC)
void cwise_min_max(const MatrixType &m)
Jet< T, N > sqrt(const Jet< T, N > &f)
Jet< T, N > pow(const Jet< T, N > &f, double g)
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
The matrix class, also used for vectors and row-vectors.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp< internal::scalar_min_op< Scalar, Scalar >, const Derived, const OtherDerived > cwiseMin(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
void comparisons(const MatrixType &m)