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.block(0,0,0,cols).colwise().sum(), RowVectorType::Zero(cols));
61 VERIFY_IS_APPROX(m1.block(0,0,rows,0).rowwise().prod(), ColVectorType::Ones(rows));
64 const Scalar& ref_m1 = m.matrix().array().coeffRef(0);
65 const Scalar& ref_m2 = m.matrix().array().coeffRef(0,0);
66 const Scalar& ref_a1 = m.array().matrix().coeffRef(0);
67 const Scalar& ref_a2 = m.array().matrix().coeffRef(0,0);
68 VERIFY(&ref_a1 == &ref_m1);
69 VERIFY(&ref_a2 == &ref_m2);
72 m1.array().coeffRef(0,0) = 1;
76 m1.array().matrix().coeffRef(0,0) = 3;
78 m1.array().matrix()(0,0) = 4;
91 Index r = internal::random<Index>(0, rows-1),
92 c = internal::random<Index>(0, cols-1);
95 m2 = MatrixType::Random(rows, cols),
104 VERIFY(! (m1.array() < m3.array()).all() );
105 VERIFY(! (m1.array() > m3.array()).all() );
109 VERIFY( (m1.array() != (
m1(r,
c)+1) ).any() );
110 VERIFY( (m1.array() > (
m1(r,
c)-1) ).any() );
111 VERIFY( (m1.array() < (
m1(r,
c)+1) ).any() );
112 VERIFY( (m1.array() ==
m1(r,
c) ).any() );
113 VERIFY( m1.cwiseEqual(m1(r,
c)).any() );
118 Scalar mid = (m1.cwiseAbs().minCoeff() + m1.cwiseAbs().maxCoeff())/
Scalar(2);
122 VERIFY_IS_APPROX( (m1.array().abs()<MatrixType::Constant(rows,cols,mid).array())
123 .select(MatrixType::Zero(rows,cols),
m1), m3);
125 VERIFY_IS_APPROX( (m1.array().abs()<MatrixType::Constant(rows,cols,mid).array())
127 VERIFY_IS_APPROX( (m1.array().abs()>=MatrixType::Constant(rows,cols,mid).array())
138 RealScalar
a = m1.cwiseAbs().mean();
139 VERIFY( ((m1.array()<-
a).
matrix() || (m1.array()>
a).
matrix()).count() == (m1.cwiseAbs().array()>
a).count());
181 Scalar maxM1 = m1.maxCoeff();
182 Scalar minM1 = m1.minCoeff();
184 VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, minM1), m1.cwiseMin(MatrixType::Constant(rows,cols, minM1)));
187 VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, maxM1), m1.cwiseMax(MatrixType::Constant(rows,cols, maxM1)));
191 VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, minM1), m1.cwiseMin( minM1));
196 VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, maxM1), m1.cwiseMax( maxM1));
209 template<
typename MatrixTraits>
void resize(
const MatrixTraits&
t)
219 MatrixType
m(rows,
cols);
221 Array2DType a2(rows,
cols);
222 Array1DType a1(rows);
224 m.array().resize(rows+1,
cols+1);
226 a2.matrix().resize(rows+1,
cols+1);
227 VERIFY(a2.rows()==rows+1 && a2.cols()==
cols+1);
228 v.array().resize(
cols);
230 a1.matrix().resize(
cols);
237 ArrayXf
a = RowVectorXf(3);
285 CALL_SUBTEST_2(
lpNorm(Vector2f()) );
286 CALL_SUBTEST_7(
lpNorm(Vector3d()) );
287 CALL_SUBTEST_8(
lpNorm(Vector4f()) );
291 CALL_SUBTEST_5(
lpNorm(VectorXf(0)) );
292 CALL_SUBTEST_4(
lpNorm(VectorXcf(0)) );
298 CALL_SUBTEST_6( regression_bug_654<0>() );
299 CALL_SUBTEST_6( regrrssion_bug_1410<0>() );
Matrix< RealScalar, Dynamic, Dynamic > M
Expression of a mathematical vector or matrix as an array object.
void regrrssion_bug_1410()
const unsigned int LvalueBit
EIGEN_DEVICE_FUNC ArrayBase< Derived > & array()
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
EIGEN_DEVICE_FUNC MatrixBase< Derived > & matrix()
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Matrix< SCALARA, Dynamic, Dynamic > A
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
Expression of an array as a mathematical vector or matrix.
#define VERIFY_IS_APPROX(a, b)
void lpNorm(const VectorType &v)
void resize(const MatrixTraits &t)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
void test_array_for_matrix()
void regression_bug_654()
NumTraits< Scalar >::Real RealScalar
#define VERIFY_IS_MUCH_SMALLER_THAN(a, b)
#define EIGEN_TEST_MAX_SIZE
void array_for_matrix(const MatrixType &m)
General-purpose arrays with easy API for coefficient-wise operations.
void cwise_min_max(const MatrixType &m)
EIGEN_DEVICE_FUNC RowXpr row(Index i)
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_max_op< Scalar, Scalar >, const Derived, const OtherDerived > cwiseMax(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
void comparisons(const MatrixType &m)