10 #define EIGEN_NO_STATIC_ASSERT // otherwise we fail at compile time on unused paths 13 template<
typename MatrixType,
typename Index,
typename Scalar>
20 VERIFY_IS_APPROX(m1.block(r1,c1,r2-r1+1,c2-c1+1).cwiseMin(s1), m1.cwiseMin(s1).block(r1,c1,r2-r1+1,c2-c1+1));
21 VERIFY_IS_APPROX(m1.block(r1,c1,r2-r1+1,c2-c1+1).cwiseMax(s1), m1.cwiseMax(s1).block(r1,c1,r2-r1+1,c2-c1+1));
26 template<
typename MatrixType,
typename Index,
typename Scalar>
33 template<
typename T1,
typename T2>
54 m2 = MatrixType::Random(rows, cols),
56 ones = MatrixType::Ones(rows, cols);
57 VectorType
v1 = VectorType::Random(rows);
59 Scalar s1 = internal::random<Scalar>();
61 Index r1 = internal::random<Index>(0,rows-1);
62 Index r2 = internal::random<Index>(
r1,rows-1);
63 Index c1 = internal::random<Index>(0,cols-1);
64 Index c2 = internal::random<Index>(c1,cols-1);
72 m1.row(r1) += s1 * m1_copy.row(r2);
75 m1.row(r1).row(0) += s1 * m1_copy.row(r2);
78 m1.col(c1) += s1 * m1_copy.col(c2);
80 m1.col(c1).col(0) += s1 * m1_copy.col(c2);
87 RowVectorType br1(m1.block(r1,0,1,cols));
88 VectorType bc1(m1.block(0,c1,rows,1));
93 m1.block(r1,c1,r2-r1+1,c2-c1+1) = s1 * m2.block(0, 0, r2-r1+1,c2-c1+1);
94 m1.block(r1,c1,r2-r1+1,c2-c1+1)(r2-
r1,c2-c1) = m2.block(0, 0, r2-r1+1,c2-c1+1)(0,0);
96 const Index BlockRows = 2;
97 const Index BlockCols = 5;
99 if (rows>=5 && cols>=8)
102 m1.template block<BlockRows,BlockCols>(1,1) *= s1;
104 m1.template block<BlockRows,BlockCols>(1,1)(0, 3) = m1.template block<2,5>(1,1)(1,2);
110 m1.template block<BlockRows,Dynamic>(1,1,BlockRows,BlockCols) *= s1;
111 m1.template block<BlockRows,Dynamic>(1,1,BlockRows,BlockCols)(0,3) = m1.template block<2,5>(1,1)(1,2);
115 VERIFY(
is_same_block(m1.block(3,3,BlockRows,BlockCols), m1.block(3,3,fix<Dynamic>(BlockRows),fix<Dynamic>(BlockCols))));
116 VERIFY(
is_same_block(m1.template block<BlockRows,Dynamic>(1,1,BlockRows,BlockCols), m1.block(1,1,fix<BlockRows>,BlockCols)));
117 VERIFY(
is_same_block(m1.template block<BlockRows,BlockCols>(1,1,BlockRows,BlockCols), m1.block(1,1,fix<BlockRows>(),fix<BlockCols>)));
118 VERIFY(
is_same_block(m1.template block<BlockRows,BlockCols>(1,1,BlockRows,BlockCols), m1.block(1,1,fix<BlockRows>,fix<BlockCols>(BlockCols))));
133 i = internal::random<Index>(0,rows-2);
155 VERIFY_IS_EQUAL( (m1.block(r1,c1,rows-r1,cols-c1).block(r2-r1,c2-c1,rows-r2,cols-c2)) , (m1.block(r2,c2,rows-r2,cols-c2)) );
156 VERIFY_IS_EQUAL( (m1.block(r1,c1,r2-r1+1,c2-c1+1).row(0)) , (m1.row(r1).segment(c1,c2-c1+1)) );
157 VERIFY_IS_EQUAL( (m1.block(r1,c1,r2-r1+1,c2-c1+1).col(0)) , (m1.col(c1).segment(r1,r2-r1+1)) );
158 VERIFY_IS_EQUAL( (m1.block(r1,c1,r2-r1+1,c2-c1+1).transpose().col(0)) , (m1.row(r1).segment(c1,c2-c1+1)).transpose() );
159 VERIFY_IS_EQUAL( (m1.transpose().block(c1,r1,c2-c1+1,r2-r1+1).col(0)) , (m1.row(r1).segment(c1,c2-c1+1)).transpose() );
162 VERIFY_IS_APPROX( ((m1+m2).
block(r1,c1,rows-r1,cols-c1).
block(r2-r1,c2-c1,rows-r2,cols-c2)) , ((m1+m2).
block(r2,c2,rows-r2,cols-c2)) );
175 VERIFY_IS_APPROX( m1.col(c1).reverse().segment(r1,r2-r1+1).eval(),m1.col(c1).reverse().eval().segment(r1,r2-r1+1).eval() );
185 DynamicMatrixType dm;
186 DynamicVectorType dv;
188 dm = m1.block(r1,c1,rows-r1,cols-c1).block(r2-r1,c2-c1,rows-r2,cols-c2);
192 dm = m1.block(r1,c1,r2-r1+1,c2-c1+1).row(0).transpose();
193 dv = m1.row(r1).segment(c1,c2-c1+1);
197 dm = m1.col(c1).segment(r1,r2-r1+1);
198 dv = m1.block(r1,c1,r2-r1+1,c2-c1+1).col(0);
202 dm = m1.block(r1,c1,r2-r1+1,c2-c1+1).transpose().col(0);
203 dv = m1.row(r1).segment(c1,c2-c1+1);
207 dm = m1.row(r1).segment(c1,c2-c1+1).transpose();
208 dv = m1.transpose().block(c1,r1,c2-c1+1,r2-r1+1).col(0);
211 VERIFY_IS_EQUAL( (m1.template block<Dynamic,1>(1,0,0,1)), m1.block(1,0,0,1));
212 VERIFY_IS_EQUAL( (m1.template block<1,Dynamic>(0,1,1,0)), m1.block(0,1,1,0));
213 VERIFY_IS_EQUAL( ((m1*1).
template block<Dynamic,1>(1,0,0,1)), m1.block(1,0,0,1));
214 VERIFY_IS_EQUAL( ((m1*1).
template block<1,Dynamic>(0,1,1,0)), m1.block(0,1,1,0));
216 if (rows>=2 && cols>=2)
231 if (rows>=2 || cols>=2) {
232 VERIFY_IS_EQUAL(
int(m1.middleCols(0,0).IsRowMajor),
int(m1.IsRowMajor) );
236 VERIFY_IS_EQUAL(
int(m1.middleRows(0,0).IsRowMajor),
int(m1.IsRowMajor) );
243 template<
typename MatrixType>
249 Index innerStride = m.innerStride();
250 Index outerStride = m.outerStride();
251 Index rowStride = m.rowStride();
252 Index colStride = m.colStride();
257 VERIFY(m.coeff(
i,
j) == data[
i*rowStride +
j*colStride]);
259 if(!MatrixType::IsVectorAtCompileTime)
264 ?
i*outerStride +
j*innerStride
265 :
j*outerStride +
i*innerStride]);
268 if(MatrixType::IsVectorAtCompileTime)
270 VERIFY(innerStride ==
int((&m.coeff(1))-(&m.coeff(0))));
272 VERIFY(m.coeff(
i) == data[
i*innerStride]);
276 template<
typename MatrixType>
282 Index r1 = internal::random<Index>(0,rows-1);
283 Index r2 = internal::random<Index>(
r1,rows-1);
284 Index c1 = internal::random<Index>(0,cols-1);
285 Index c2 = internal::random<Index>(c1,cols-1);
311 #ifndef EIGEN_DEFAULT_TO_ROW_MAJOR
#define VERIFY_RAISES_ASSERT(a)
#define CALL_SUBTEST_6(FUNC)
#define CALL_SUBTEST_4(FUNC)
void adjoint(const MatrixType &m)
#define CALL_SUBTEST_3(FUNC)
#define CALL_SUBTEST_7(FUNC)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NRowsBlockXpr< internal::get_fixed_value< NRowsType >::value >::Type topRows(NRowsType n)
static const Pose3 T2(Rot3::Rodrigues(0.3, 0.2, 0.1), P2)
const unsigned int RowMajorBit
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NColsBlockXpr< internal::get_fixed_value< NColsType >::value >::Type middleCols(Index startCol, NColsType numCols)
#define VERIFY_IS_APPROX(a, b)
#define VERIFY_IS_EQUAL(a, b)
#define CALL_SUBTEST_1(FUNC)
void data_and_stride(const MatrixType &m)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
#define CALL_SUBTEST_8(FUNC)
NumTraits< Scalar >::Real RealScalar
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NRowsBlockXpr< internal::get_fixed_value< NRowsType >::value >::Type middleRows(Index startRow, NRowsType n)
#define CALL_SUBTEST_5(FUNC)
static const Similarity3 T1(R, Point3(3.5, -8.2, 4.2), 1)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedSegmentReturnType< internal::get_fixed_value< NType >::value >::Type segment(Index start, NType n)
void compare_using_data_and_stride(const MatrixType &m)
#define CALL_SUBTEST_2(FUNC)
internal::nested_eval< T, 1 >::type eval(const T &xpr)
The matrix class, also used for vectors and row-vectors.
EIGEN_DECLARE_TEST(block)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NColsBlockXpr< internal::get_fixed_value< NColsType >::value >::Type leftCols(NColsType n)
void block(const MatrixType &m)
internal::enable_if< internal::is_same< T1, T2 >::value, bool >::type is_same_block(const T1 &a, const T2 &b)
Eigen::internal::enable_if<!NumTraits< typename MatrixType::Scalar >::IsComplex, typename MatrixType::Scalar >::type block_real_only(const MatrixType &m1, Index r1, Index r2, Index c1, Index c2, const Scalar &s1)