10 #ifdef EIGEN_TEST_PART_2
12 #define EIGEN_MAX_CPP_VER 11
15 #ifdef EIGEN_TEST_PART_3
17 #define EIGEN_MAX_CPP_VER 03
22 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
23 #pragma GCC diagnostic ignored "-Wdeprecated"
26 #if defined(__GNUC__) && (__GNUC__ >=9)
27 #pragma GCC diagnostic ignored "-Wdeprecated-copy"
29 #if defined(__clang__) && (__clang_major__ >= 10)
30 #pragma clang diagnostic ignored "-Wdeprecated-copy"
46 return int(
i*100 +
j);
54 bool match(
const T& xpr, std::string
ref, std::string str_xpr =
"") {
56 std::stringstream
str;
59 std::cout << str_xpr <<
"\n" << xpr <<
"\n\n";
63 #define MATCH(X,R) match(X, R, #X)
65 template<
typename T1,
typename T2>
69 return (
a ==
b).all();
72 template<
typename T1,
typename T2>
75 bool ok =
a.first()==
b.first() &&
a.size() ==
b.size() &&
Index(
a.incrObject())==
Index(
b.incrObject());;
78 std::cerr <<
"seqN(" <<
a.first() <<
", " <<
a.size() <<
", " <<
Index(
a.incrObject()) <<
") != ";
79 std::cerr <<
"seqN(" <<
b.first() <<
", " <<
b.size() <<
", " <<
Index(
b.incrObject()) <<
")\n";
84 template<
typename T1,
typename T2>
93 #define VERIFY_EQ_INT(A,B) VERIFY_IS_APPROX(int(A),int(B))
102 ArrayXd
a = ArrayXd::LinSpaced(
n,0,
n-1);
105 #if EIGEN_COMP_CXXVER>=14
108 ArrayXXi
A = ArrayXXi::NullaryExpr(
n,
n, std::ptr_fun(&
encode));
115 Array4i eii(4); eii << 3, 1, 6, 5;
116 std::valarray<int> vali(4);
Map<ArrayXi>(&vali[0],4) = eii;
117 std::vector<int> veci(4);
Map<ArrayXi>(veci.data(),4) = eii;
120 "309 308 307 306 305 304 303")
124 "209 208 207 206 205 204 203\n"
125 "309 308 307 306 305 304 303\n"
126 "409 408 407 406 405 404 403\n"
127 "509 508 507 506 505 504 503\n"
128 "609 608 607 606 605 604 603")
140 "902 903 904 905 906 907 908 909\n"
141 "802 803 804 805 806 807 808 809\n"
142 "702 703 704 705 706 707 708 709\n"
143 "602 603 604 605 606 607 608 609\n"
144 "502 503 504 505 506 507 508 509")
155 "300 301 302 303 304 305 306 307 308 309\n"
156 "100 101 102 103 104 105 106 107 108 109\n"
157 "600 601 602 603 604 605 606 607 608 609\n"
158 "500 501 502 503 504 505 506 507 508 509")
163 "300 301 302 303 304 305 306 307 308 309\n"
164 "300 301 302 303 304 305 306 307 308 309\n"
165 "300 301 302 303 304 305 306 307 308 309\n"
166 "300 301 302 303 304 305 306 307 308 309\n"
167 "300 301 302 303 304 305 306 307 308 309")
188 VERIFY_EQ_INT( (
A(
seqN(2,5), 5)).OuterStrideAtCompileTime ,
A.col(5).OuterStrideAtCompileTime);
190 VERIFY_EQ_INT( (
A(5,
seqN(2,5))).InnerStrideAtCompileTime ,
A.row(5).InnerStrideAtCompileTime);
191 VERIFY_EQ_INT( (
A(5,
seqN(2,5))).OuterStrideAtCompileTime ,
A.row(5).OuterStrideAtCompileTime);
192 VERIFY_EQ_INT( (
B(1,
seqN(1,2))).InnerStrideAtCompileTime ,
B.row(1).InnerStrideAtCompileTime);
193 VERIFY_EQ_INT( (
B(1,
seqN(1,2))).OuterStrideAtCompileTime ,
B.row(1).OuterStrideAtCompileTime);
225 VERIFY(
is_same_seq(
seqN(2,std::integral_constant<int,5>(),std::integral_constant<int,-2>()),
seqN(2,fix<5>,fix<-2>()) ) );
226 VERIFY(
is_same_seq(
seq(std::integral_constant<int,1>(),std::integral_constant<int,5>(),std::integral_constant<int,2>()),
227 seq(fix<1>,fix<5>,fix<2>()) ) );
229 VERIFY(
is_same_seq_type(
seq(std::integral_constant<int,1>(),std::integral_constant<int,5>(),std::integral_constant<int,2>()),
230 seq(fix<1>,fix<5>,fix<2>()) ) );
239 VERIFY( (
A(
seqN(2,fix<5>), 5)).RowsAtCompileTime == 5);
247 VERIFY(
int( (
A(
all, eii)).ColsAtCompileTime) ==
int(eii.SizeAtCompileTime));
252 VERIFY_IS_APPROX(
A(
seq(
n-1,2,-2),
seqN(
n-1-6,3,-1)),
A(
seq(
last,2,fix<-2>),
seqN(
last-6,3,fix<-1>)) );
260 VERIFY_IS_APPROX(
A(
seq(1,
n-1-2,2),
seq(1,
n-1-2,2)),
A(
seq(1,
last-2,2),
seq(1,
last-2,fix<2>)) );
261 VERIFY_IS_APPROX(
A(
seq(
n-1-5,
n-1-2,2),
seq(
n-1-5,
n-1-2,2)),
A(
seq(
last-5,
last-2,2),
seq(
last-5,
last-2,fix<2>)) );
262 VERIFY_IS_APPROX(
A(
seq(
n-1-5,7,2),
seq(
n-1-5,7,2)),
A(
seq(
last-5,7,2),
seq(
last-5,7,fix<2>)) );
281 const ArrayXXi& cA(
A);
294 ArrayXXi
A1=
A,
A2 = ArrayXXi::Random(4,4);
295 ArrayXi range25(4); range25 << 3,2,4,5;
320 VERIFY(
a(lastN(fix<3>())).SizeAtCompileTime == 3 );
322 VERIFY( (
A(
all, std::array<int,4>{{1,3,2,4}})).ColsAtCompileTime == 4);
324 VERIFY_IS_APPROX( (
A(std::array<int,3>{{1,3,5}}, std::array<int,4>{{9,6,3,0}})),
A(
seqN(1,3,2),
seqN(9,4,-3)) );
326 #if EIGEN_HAS_STATIC_ARRAY_TEMPLATE
327 VERIFY_IS_APPROX(
A({3, 1, 6, 5},
all),
A(std::array<int,4>{{3, 1, 6, 5}},
all) );
328 VERIFY_IS_APPROX(
A(
all,{3, 1, 6, 5}),
A(
all,std::array<int,4>{{3, 1, 6, 5}}) );
329 VERIFY_IS_APPROX(
A({1,3,5},{3, 1, 6, 5}),
A(std::array<int,3>{{1,3,5}},std::array<int,4>{{3, 1, 6, 5}}) );
349 const Index I_ = 3, J_ = 4;
359 VERIFY(
is_same_eq(
A.block(1,1,3,4),
A.block(1,1,fix<Dynamic>(3),fix<Dynamic>(4))) );
363 VERIFY(
is_same_eq(
A.bottomRightCorner<3,4>(),
A.bottomRightCorner(fix<3>,fix<4>)) );
378 const ArrayXXi& cA(
A);
381 VERIFY(
is_same_eq( cA.topLeftCorner<3,4>(), cA.topLeftCorner(fix<3>,fix<4>)) );
382 VERIFY(
is_same_eq( cA.bottomLeftCorner<3,4>(), cA.bottomLeftCorner(fix<3>,fix<4>)) );
383 VERIFY(
is_same_eq( cA.bottomRightCorner<3,4>(), cA.bottomRightCorner(fix<3>,fix<4>)) );
384 VERIFY(
is_same_eq( cA.topRightCorner<3,4>(), cA.topRightCorner(fix<3>,fix<4>)) );
424 Matrix3i
A3 = Matrix3i::Random();
425 ArrayXi
ind(5);
ind << 1,1,1,1,1;
432 A(
all, eii).col(0) =
A.col(eii(0));