68 ArrayXd
a = ArrayXd::LinSpaced(
n, 0,
n - 1);
71 ArrayXXi
A = ArrayXXi::NullaryExpr(
n,
n, std::ref(
encode));
78 std::vector<int> veci(4);
84 "209 208 207 206 205 204 203\n"
85 "309 308 307 306 305 304 303\n"
86 "409 408 407 406 405 404 403\n"
87 "509 508 507 506 505 504 503\n"
88 "609 608 607 606 605 604 603"));
98 "902 903 904 905 906 907 908 909\n"
99 "802 803 804 805 806 807 808 809\n"
100 "702 703 704 705 706 707 708 709\n"
101 "602 603 604 605 606 607 608 609\n"
102 "502 503 504 505 506 507 508 509"));
111 "300 301 302 303 304 305 306 307 308 309\n"
112 "100 101 102 103 104 105 106 107 108 109\n"
113 "600 601 602 603 604 605 606 607 608 609\n"
114 "500 501 502 503 504 505 506 507 508 509"));
118 "300 301 302 303 304 305 306 307 308 309\n"
119 "300 301 302 303 304 305 306 307 308 309\n"
120 "300 301 302 303 304 305 306 307 308 309\n"
121 "300 301 302 303 304 305 306 307 308 309\n"
122 "300 301 302 303 304 305 306 307 308 309"));
142 VERIFY_EQ_INT((
A(
seqN(2, 5), 5)).OuterStrideAtCompileTime,
A.col(5).OuterStrideAtCompileTime);
144 VERIFY_EQ_INT((
A(5,
seqN(2, 5))).InnerStrideAtCompileTime,
A.row(5).InnerStrideAtCompileTime);
145 VERIFY_EQ_INT((
A(5,
seqN(2, 5))).OuterStrideAtCompileTime,
A.row(5).OuterStrideAtCompileTime);
146 VERIFY_EQ_INT((
B(1,
seqN(1, 2))).InnerStrideAtCompileTime,
B.row(1).InnerStrideAtCompileTime);
147 VERIFY_EQ_INT((
B(1,
seqN(1, 2))).OuterStrideAtCompileTime,
B.row(1).OuterStrideAtCompileTime);
179 seqN(2, fix<5>, fix<-2>())));
181 seq(std::integral_constant<int, 1>(), std::integral_constant<int, 5>(), std::integral_constant<int, 2>()),
182 seq(fix<1>, fix<5>, fix<2>())));
184 seqN(2, fix<5>, fix<-2>())));
186 seq(std::integral_constant<int, 1>(), std::integral_constant<int, 5>(), std::integral_constant<int, 2>()),
187 seq(fix<1>, fix<5>, fix<2>())));
191 is_same_seq_type(
seq(std::integral_constant<int, 1>(), std::integral_constant<int, 5>()),
seq(fix<1>, fix<5>)));
193 VERIFY((
A(
seqN(2, fix<5>), 5)).RowsAtCompileTime == 5);
201 VERIFY(
int((
A(
all, eii)).ColsAtCompileTime) ==
int(eii.SizeAtCompileTime));
206 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>)));
216 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>)));
219 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>)));
239 const ArrayXXi& cA(
A);
252 ArrayXXi A1 =
A, A2 = ArrayXXi::Random(4, 4);
254 range25 << 3, 2, 4, 5;
255 A1(
seqN(3, 4),
seq(2, 5)) = A2;
259 A1(
seq(6, 3, -1), range25) = A2;
280 VERIFY((
A(
all, std::array<int, 4>{{1, 3, 2, 4}})).ColsAtCompileTime == 4);
282 VERIFY_IS_APPROX((
A(std::array<int, 3>{{1, 3, 5}}, std::array<int, 4>{{9, 6, 3, 0}})),
284 VERIFY_IS_EQUAL(
A(std::array<int, 3>{1, 3, 5}, std::array<int, 4>{3, 1, 6, 5}).RowsAtCompileTime, 3);
285 VERIFY_IS_EQUAL(
A(std::array<int, 3>{1, 3, 5}, std::array<int, 4>{3, 1, 6, 5}).ColsAtCompileTime, 4);
293 ArrayXd
r = ArrayXd::Random(
size);
294 ArrayXi idx = ArrayXi::EqualSpaced(
size, 0, 1);
295 std::shuffle(idx.begin(), idx.end(), std::random_device());
297 int c_array[3] = {idx[0], idx[1], idx[2]};
298 std::vector<int> std_vector{idx[0], idx[1], idx[2]};
309 const ArrayXd& r_ref =
r;
322 ArrayXXd
R = ArrayXXd::Random(
rows,
cols);
323 ArrayXi r_idx = ArrayXi::EqualSpaced(
rows, 0, 1);
324 ArrayXi c_idx = ArrayXi::EqualSpaced(
cols, 0, 1);
325 std::shuffle(r_idx.begin(), r_idx.end(), std::random_device());
326 std::shuffle(c_idx.begin(), c_idx.end(), std::random_device());
328 int c_array_rows[3] = {r_idx[0], r_idx[1], r_idx[2]};
329 int c_array_cols[4] = {c_idx[0], c_idx[1], c_idx[2], c_idx[3]};
330 std::vector<int> std_vector_rows{r_idx[0], r_idx[1], r_idx[2]};
331 std::vector<int> std_vector_cols{c_idx[0], c_idx[1], c_idx[2], c_idx[3]};
337 R(c_array_rows, c_array_cols));
339 R(std_vector_rows, std_vector_cols));
341 R(eigen_matrix_rows, eigen_matrix_cols));
346 const ArrayXXd& R_ref =
R;
348 VERIFY_IS_CWISE_EQUAL(R_ref({r_idx[0], r_idx[1], r_idx[2]}, {c_idx[0], c_idx[1], c_idx[2], c_idx[3]}),
349 R_ref(c_array_rows, c_array_cols));
350 VERIFY_IS_CWISE_EQUAL(R_ref({r_idx[0], r_idx[1], r_idx[2]}, {c_idx[0], c_idx[1], c_idx[2], c_idx[3]}),
351 R_ref(std_vector_rows, std_vector_cols));
352 VERIFY_IS_CWISE_EQUAL(R_ref({r_idx[0], r_idx[1], r_idx[2]}, {c_idx[0], c_idx[1], c_idx[2], c_idx[3]}),
353 R_ref(eigen_matrix_rows, eigen_matrix_cols));
355 VERIFY_IS_CWISE_EQUAL(R_ref(std_vector_rows, std_vector_cols), R_ref(eigen_matrix_rows, eigen_matrix_cols));
356 VERIFY_IS_CWISE_EQUAL(R_ref(eigen_matrix_rows, eigen_matrix_cols), R_ref(c_array_rows, c_array_cols));
365 const Index I_ = 3, J_ = 4;
375 VERIFY(
is_same_eq(
A.block(1, 1, 3, 4),
A.block(1, 1, fix<Dynamic>(3), fix<Dynamic>(4))));
394 const ArrayXXi& cA(
A);
397 VERIFY(
is_same_eq(cA.topLeftCorner<3, 4>(), cA.topLeftCorner(fix<3>, fix<4>)));
398 VERIFY(
is_same_eq(cA.bottomLeftCorner<3, 4>(), cA.bottomLeftCorner(fix<3>, fix<4>)));
399 VERIFY(
is_same_eq(cA.bottomRightCorner<3, 4>(), cA.bottomRightCorner(fix<3>, fix<4>)));
400 VERIFY(
is_same_eq(cA.topRightCorner<3, 4>(), cA.topRightCorner(fix<3>, fix<4>)));
415 enum {
X = 0,
Y = 1 };
436 using Op = internal::scalar_constant_op<double>;
439 double constant_val = internal::random<double>();
441 VectorXpr vectorXpr(10, 1,
op);
450 short i_short =
static_cast<short>(
i);
451 std::size_t i_sizet(
i);
465 Matrix3i A3 = Matrix3i::Random();
467 ind << 1, 1, 1, 1, 1;
474 A(
all, eii).col(0) =
A.col(eii(0));
490 std::array<int, 2> test_indices = {0, 1};
492 for (
int col = 0;
col <
int(test_indices.size()); ++
col)
505 int row_start = internal::random<int>(0,
rows - 1);
506 int row_inc = internal::random<int>(1,
rows - row_start);
507 int row_size = internal::random<int>(1, (
rows - row_start) / row_inc);
508 auto row_seq =
seqN(row_start, row_size, row_inc);
511 int col_start = internal::random<int>(0,
cols - 1);
512 int col_inc = internal::random<int>(1,
cols - col_start);
513 int col_size = internal::random<int>(1, (
cols - col_start) / col_inc);
514 auto col_seq =
seqN(col_start, col_size, col_inc);
521 m1(row_seq, col_seq).
eval() *
m2(col_seq, row_seq).
eval());
523 VectorXd
v1 = VectorXd::Random(
cols);
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
std::vector< int > ind
Definition: Slicing_stdvector_cxx11.cpp:1
@ R
Definition: StatisticsVector.h:21
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
void reverse(const MatrixType &m)
Definition: array_reverse.cpp:17
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Scalar * b
Definition: benchVecAdd.cpp:17
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:48
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:48
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:64
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
EIGEN_DEVICE_FUNC Derived & setOnes(Index size)
Definition: CwiseNullaryOp.h:708
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:198
constexpr EIGEN_DEVICE_FUNC const Scalar * data() const
Definition: PlainObjectBase.h:273
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:192
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:191
Definition: matrices.h:74
static constexpr Eigen::internal::all_t all
Definition: IndexedViewHelper.h:86
static constexpr const last_t last
Definition: IndexedViewHelper.h:48
static constexpr lastp1_t lastp1
Definition: IndexedViewHelper.h:72
const unsigned int DirectAccessBit
Definition: Constants.h:159
const unsigned int RowMajorBit
Definition: Constants.h:70
#define X
Definition: icosphere.cpp:20
#define MATCH(X, R)
Definition: indexed_view.cpp:37
bool is_same_seq(const T1 &a, const T2 &b)
Definition: indexed_view.cpp:45
test::IndexPair decode(Index ij)
Definition: indexed_view.cpp:26
std::enable_if_t< internal::is_same< T1, T2 >::value, bool > is_same_seq_type(const T1 &a, const T2 &b)
Definition: indexed_view.cpp:56
int encode(Index i, Index j)
Definition: indexed_view.cpp:24
#define VERIFY_EQ_INT(A, B)
Definition: indexed_view.cpp:60
std::enable_if_t< internal::is_same< T1, T2 >::value, bool > is_same_eq(const T1 &a, const T2 &b)
Definition: indexed_view.cpp:40
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
const Scalar * a
Definition: level2_cplx_impl.h:32
char char * op
Definition: level2_impl.h:374
#define VERIFY_IS_CWISE_EQUAL(a, b)
Definition: main.h:375
#define VERIFY(a)
Definition: main.h:362
#define STATIC_CHECK(COND)
Definition: main.h:380
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:367
EIGEN_STRONG_INLINE Packet2d shuffle(const Packet2d &m, const Packet2d &n, int mask)
Definition: LSX/PacketMath.h:150
auto lastN(SizeType size, IncrType incr) -> decltype(seqN(Eigen::placeholders::last -(size - fix< 1 >()) *incr, size, incr))
Definition: ArithmeticSequence.h:188
ArithmeticSequence< typename internal::cleanup_index_type< FirstType >::type, typename internal::cleanup_index_type< SizeType >::type, typename internal::cleanup_seq_incr< IncrType >::type > seqN(FirstType first, SizeType size, IncrType incr)
Definition: ArithmeticSequence.h:105
auto seq(FirstType f, LastType l) -> decltype(seqN(typename internal::cleanup_index_type< FirstType >::type(f),(typename internal::cleanup_index_type< LastType >::type(l) - typename internal::cleanup_index_type< FirstType >::type(f)+fix< 1 >())))
Definition: ArithmeticSequence.h:152
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const int Dynamic
Definition: Constants.h:25
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
void transpose()
Definition: skew_symmetric_matrix3.cpp:135
std::pair< Index, Index > IndexPair
Definition: indexed_view.cpp:21
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Definition: sparse_permutations.cpp:47
Definition: Constants.h:534
const char Y
Definition: test/EulerAngles.cpp:32
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2