14 template<
class Iterator >
15 std::reverse_iterator<Iterator>
18 return std::reverse_iterator<Iterator>(
i);
22 template<
class ForwardIt>
25 if (firstIt != lastIt) {
26 ForwardIt next = firstIt;
27 while (++next != lastIt) {
35 template<
class ForwardIt>
44 template<
typename XprType>
47 template<
typename XprType>
50 template<
typename Iter>
62 template<
typename Xpr>
69 for(
typename Xpr::iterator it = xpr.begin(); it!=xpr.end(); ++it) {
VERIFY_IS_EQUAL(*it,xpr[
i++]); }
72 for(
typename Xpr::const_iterator it = xpr.cbegin(); it!=xpr.cend(); ++it) {
VERIFY_IS_EQUAL(*it,xpr[
i++]); }
75 for(
typename Xpr::const_iterator it = cxpr.begin(); it!=cxpr.end(); ++it) {
VERIFY_IS_EQUAL(*it,xpr[
i++]); }
78 for(
typename Xpr::const_iterator it = xpr.begin(); it!=xpr.end(); ++it) {
VERIFY_IS_EQUAL(*it,xpr[
i++]); }
82 typename Xpr::const_iterator cit = xpr.begin();
86 auto tmp1 = xpr.begin();
88 auto tmp2 = xpr.cbegin();
89 VERIFY(tmp2==xpr.cbegin());
93 VERIFY( xpr.end() -xpr.begin() == xpr.size() );
94 VERIFY( xpr.cend()-xpr.begin() == xpr.size() );
95 VERIFY( xpr.end() -xpr.cbegin() == xpr.size() );
96 VERIFY( xpr.cend()-xpr.cbegin() == xpr.size() );
99 VERIFY(xpr.begin() != xpr.end());
100 VERIFY(xpr.begin() < xpr.end());
101 VERIFY(xpr.begin() <= xpr.end());
102 VERIFY(!(xpr.begin() == xpr.end()));
103 VERIFY(!(xpr.begin() > xpr.end()));
104 VERIFY(!(xpr.begin() >= xpr.end()));
106 VERIFY(xpr.cbegin() != xpr.end());
107 VERIFY(xpr.cbegin() < xpr.end());
108 VERIFY(xpr.cbegin() <= xpr.end());
109 VERIFY(!(xpr.cbegin() == xpr.end()));
110 VERIFY(!(xpr.cbegin() > xpr.end()));
111 VERIFY(!(xpr.cbegin() >= xpr.end()));
113 VERIFY(xpr.begin() != xpr.cend());
114 VERIFY(xpr.begin() < xpr.cend());
115 VERIFY(xpr.begin() <= xpr.cend());
116 VERIFY(!(xpr.begin() == xpr.cend()));
117 VERIFY(!(xpr.begin() > xpr.cend()));
118 VERIFY(!(xpr.begin() >= xpr.cend()));
122 template<
typename Scalar,
int Rows,
int Cols>
133 ColMatrixType
A = ColMatrixType::Random(
rows,
cols);
134 const ColMatrixType& cA(
A);
135 RowMatrixType
B = RowMatrixType::Random(
rows,
cols);
162 j = internal::random<Index>(0,
A.cols()-1);
168 i = internal::random<Index>(0,
A.rows()-1);
212 RowMatrixType B_copy =
B;
213 auto Br =
B.reshaped();
230 j = internal::random<Index>(0,
A.cols()-1);
238 i = internal::random<Index>(0,
A.rows()-1);
254 i = internal::random<Index>(0,
A.rows()-1);
269 for(
auto&
x :
w) {
x =
v(
i++); }
277 j = internal::random<Index>(0,
A.cols()-1);
278 auto it =
A.col(
j).begin();
286 i = internal::random<Index>(0,
A.rows()-1);
287 auto it =
A.row(
i).begin();
292 j = internal::random<Index>(0,
A.cols()-1);
296 auto tmp = (
A+2*
A).
col(
j);
297 auto it = tmp.begin();
307 for (
auto it =
A.colwise().cbegin(); it !=
A.colwise().cend(); ++it, ++
j) {
312 for (
auto it =
A.colwise().begin(); it !=
A.colwise().end(); ++it, ++
j) {
313 (*it).coeffRef(0) = (*it).coeff(0);
314 it->coeffRef(0) = it->coeff(0);
321 for (
auto it =
A.colwise().cbegin(); it !=
A.colwise().cend(); ++it, ++
j) {
322 typename decltype(it)::value_type tmp = *it;
355 std::sort(
v.begin(),
v.end());
362 j = internal::random<Index>(0,
A.cols()-1);
365 std::sort(Acol.begin(),Acol.end());
369 std::sort(
A.col(
j).begin(),
A.col(
j).end());
376 i = internal::random<Index>(0,
A.rows()-1);
379 std::sort(Arow.begin(),Arow.end());
383 std::sort(
A.row(
i).begin(),
A.row(
i).end());
391 std::sort(B1.begin(),B1.end());
404 j = internal::random<Index>(0,
A.cols()-1);
406 std::partial_sum(Acol.begin(), Acol.end(),
v.begin());
410 std::partial_sum(Acol.begin(), Acol.end(), Acol.begin());
419 std::sort(
v1.begin(),
v1.end());
420 std::nth_element(
v.begin(),
v.begin()+
rows/2,
v.end());
425 std::sort(
v1.begin()+
rows/2,
v1.end());
426 std::nth_element(
v.begin()+
rows/2,
v.begin()+
rows/4,
v.end());
439 for(
auto c :
B.colwise()) {
460 RowVectorType
row = RowVectorType::Random(
cols);
472 i = internal::random<Index>(0,
A.rows()-1);
478 j = internal::random<Index>(0,
A.cols()-1);
487 STATIC_CHECK(( internal::is_same<VecOp::const_iterator, decltype(std::declval<const VecOp&>().cbegin())>::
value ));
488 STATIC_CHECK(( internal::is_same<VecOp::const_iterator, decltype(std::declval<const VecOp&>().cend ())>::
value ));
489 #if EIGEN_COMP_CXXVER>=14
490 STATIC_CHECK(( internal::is_same<VecOp::const_iterator, decltype(std::cbegin(std::declval<const VecOp&>()))>::
value ));
491 STATIC_CHECK(( internal::is_same<VecOp::const_iterator, decltype(std::cend (std::declval<const VecOp&>()))>::
value ));
509 class Iterator = decltype(::std::declval<const C&>().begin()),
510 class = decltype(::std::declval<const C&>().
end()),
511 class = decltype(++::std::declval<Iterator&>()),
512 class = decltype(*::std::declval<Iterator>()),
513 class =
typename C::const_iterator>
514 bool IsContainerType(
int ) {
return true; }
517 bool IsContainerType(
long ) {
return false; }
519 template <
typename Scalar,
int Rows,
int Cols>
520 void test_stl_container_detection(
int rows=Rows,
int cols=
Cols)
526 ColMatrixType
A = ColMatrixType::Random(
rows,
cols);
527 RowMatrixType
B = RowMatrixType::Random(
rows,
cols);
531 using ColMatrixColType = decltype(
A.col(
i));
532 using ColMatrixRowType = decltype(
A.row(
i));
533 using RowMatrixColType = decltype(
B.col(
i));
534 using RowMatrixRowType = decltype(
B.row(
i));
554 CALL_SUBTEST_1(( test_stl_iterators<int,Dynamic,Dynamic>(internal::random<int>(5,10), internal::random<int>(5,10)) ));
555 CALL_SUBTEST_1(( test_stl_iterators<int,Dynamic,Dynamic>(internal::random<int>(10,200), internal::random<int>(10,200)) ));