12 #include <Eigen/CXX11/Tensor> 27 tensor2 = tensor1.
reshape(dim1);
29 tensor3 = tensor1.
reshape(dim2);
31 tensor4 = tensor1.
reshape(dim1).reshape(dim3);
33 for (
int i = 0;
i < 2; ++
i) {
34 for (
int j = 0;
j < 3; ++
j) {
35 for (
int k = 0; k < 7; ++k) {
46 #if defined(EIGEN_HAS_INDEX_LIST) 47 using Eigen::type2index;
53 Eigen::IndexList<type2index<2>, type2index<3>, type2index<7>> dim;
56 for (
int i = 0;
i < 2; ++
i) {
57 for (
int j = 0;
j < 3; ++
j) {
58 for (
int k = 0; k < 7; ++k) {
68 MatrixXf
m1(2,3*5*7*11);
69 MatrixXf
m2(3*5*7*11,13);
72 MatrixXf m3 = m1 *
m2;
81 tensor3 = tensor1.
reshape(newDims1).contract(tensor2.reshape(newDims2), contract_along);
84 for (
int i = 0;
i < 2; ++
i) {
85 for (
int j = 0;
j < 13; ++
j) {
101 float scratch[2*3*1*7*1];
105 for (
int i = 0;
i < 2; ++
i) {
106 for (
int j = 0;
j < 3; ++
j) {
107 for (
int k = 0; k < 7; ++k) {
115 template<
typename T,
int DataLayout>
124 slice1 = tensor.
slice(indices, sizes);
130 slice2 = tensor.
slice(indices2, sizes2);
131 for (
int i = 0;
i < 2; ++
i) {
132 for (
int j = 0;
j < 2; ++
j) {
133 for (
int k = 0; k < 3; ++k) {
151 template<
typename T,
int DataLayout>
159 Mtx m3 = m1.block(1, 2, 3, 3) * m2.block(0, 2, 3, 1);
171 tensor3 = tensor1.
slice(indices1, sizes1).contract(tensor2.slice(indices2, sizes2), contract_along);
174 for (
int i = 0;
i < 3; ++
i) {
175 for (
int j = 0;
j < 1; ++
j) {
183 for (
int i = 0;
i < 35; ++
i) {
188 template<
typename T,
int DataLayout>
205 result.
slice(first_slice, sizes12) = tensor1;
211 result.
slice(third_slice, sizes3) = tensor3;
215 result.
slice(fourth_slice, sizes4) = tensor4;
217 for (
int j = 0;
j < 2; ++
j) {
218 for (
int k = 0; k < 7; ++k) {
219 for (
int i = 0;
i < 2; ++
i) {
225 for (
int i = 0;
i < 4; ++
i) {
226 for (
int j = 2;
j < 5; ++
j) {
227 for (
int k = 0; k < 5; ++k) {
230 for (
int k = 5; k < 7; ++k) {
238 result.
slice(fifth_slice, sizes5) = tensor5.
slice(fifth_slice, sizes5);
239 for (
int i = 0;
i < 4; ++
i) {
240 for (
int j = 2;
j < 5; ++
j) {
241 for (
int k = 0; k < 7; ++k) {
248 template<
typename T,
int DataLayout>
285 for (
int i = 0;
i < 3; ++
i) {
286 for (
int j = 0;
j < 2; ++
j) {
295 for (
int l = 0;
l < 11; ++
l) {
296 for (
int k = 0; k < 2; ++k) {
307 for (
int i = 0;
i < 3; ++
i) {
308 for (
int j = 0;
j < 5; ++
j) {
309 for (
int k = 0; k < 7; ++k) {
310 for (
int l = 0;
l < 2; ++
l) {
311 int slice_index =
i + 3 * (
j + 5 * (k + 7 *
l));
322 for (
int l = 0;
l < 11; ++
l) {
323 for (
int k = 0; k < 7; ++k) {
324 for (
int j = 0;
j < 5; ++
j) {
325 for (
int i = 0;
i < 2; ++
i) {
326 int slice_index =
l + 11 * (k + 7 * (
j + 5 *
i));
343 template<
typename T,
int DataLayout>
358 Index2 indicesStart(5,7);
359 Index2 indicesStop(0,4);
360 slice = tensor2.
stridedSlice(indicesStart, indicesStop, strides);
361 for (
int j = 0;
j < 2; ++
j) {
362 for (
int k = 0; k < 3; ++k) {
371 Index2 indicesStart(5,4);
372 Index2 indicesStop(5,5);
373 slice = tensor2.
stridedSlice(indicesStart, indicesStop, strides);
377 Tensor2f
slice(7,11);
379 Index2 indicesStart(-3,20);
380 Index2 indicesStop(20,-11);
381 slice = tensor2.
stridedSlice(indicesStart, indicesStop, strides);
382 for (
int j = 0;
j < 7; ++
j) {
383 for (
int k = 0; k < 11; ++k) {
390 Tensor5f slice1(1,1,1,1,1);
394 slice1 = tensor.
stridedSlice(indicesStart, indicesStop, strides);
399 Tensor5f
slice(1,1,2,2,3);
400 Index5 start(1, 1, 3, 4, 5);
401 Index5 stop(2, 2, 5, 6, 8);
404 for (
int i = 0;
i < 2; ++
i) {
405 for (
int j = 0;
j < 2; ++
j) {
406 for (
int k = 0; k < 3; ++k) {
414 Tensor5f
slice(1,1,2,2,3);
415 Index5 strides3(1, 1, -2, 1, -1);
416 Index5 indices3Start(1, 1, 4, 4, 7);
417 Index5 indices3Stop(2, 2, 0, 6, 4);
418 slice = tensor.
stridedSlice(indices3Start, indices3Stop, strides3);
419 for (
int i = 0;
i < 2; ++
i) {
420 for (
int j = 0;
j < 2; ++
j) {
421 for (
int k = 0; k < 3; ++k) {
429 Tensor5f
slice(1,1,2,2,3);
430 Index5 strides3(1, 1, 2, 1, 1);
431 Index5 indices3Start(1, 1, 4, 4, 7);
432 Index5 indices3Stop(2, 2, 0, 6, 4);
433 slice = tensor.
stridedSlice(indices3Start, indices3Stop, strides3);
437 template<
typename T,
int DataLayout>
451 Index2 indicesStart(3,4);
452 Index2 indicesStop(5,7);
455 tensor.slice(indicesStart,lengths)=slice;
456 tensor2.
stridedSlice(indicesStart,indicesStop,strides)=slice;
458 for(
int i=0;
i<7;
i++)
for(
int j=0;
j<11;
j++){
463 template<
typename T,
int DataLayout>
477 for (
int i = 0;
i < 11; ++
i) {
482 template<
typename T,
int DataLayout>
494 tensor.
slice(indices1, sizes1) = slice1;
501 tensor.
slice(indices2, sizes2) = slice2;
508 tensor.
slice(indices3, sizes3) = slice3;
515 tensor.
slice(indices4, sizes4) = slice4;
522 tensor.
slice(indices5, sizes5) = slice5;
529 tensor.
slice(indices6, sizes6) = slice6;
533 for (
int i = 0;
i < 2; ++
i) {
534 for (
int j = 0;
j < 3; ++
j) {
535 for (
int k = 0; k < 5; ++k) {
542 #define CALL_SUBTEST_PART(PART) \ 545 #define CALL_SUBTESTS_TYPES_LAYOUTS(PART, NAME) \ 546 CALL_SUBTEST_PART(PART)((NAME<float, ColMajor>())); \ 547 CALL_SUBTEST_PART(PART)((NAME<float, RowMajor>())); \ 548 CALL_SUBTEST_PART(PART)((NAME<bool, ColMajor>())); \ 549 CALL_SUBTEST_PART(PART)((NAME<bool, RowMajor>()))
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
static void test_simple_reshape()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorStridingSlicingOp< const StartIndices, const StopIndices, const Strides, const Tensor< Scalar_, NumIndices_, Options_, IndexType_ > > stridedSlice(const StartIndices &startIndices, const StopIndices &stopIndices, const Strides &strides) const
static void test_reshape_as_lvalue()
static void test_empty_slice()
A matrix or vector expression mapping an existing array of data.
static void test_strided_slice_write()
static void test_const_slice()
std::vector< Array2i > sizes
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor< Scalar_, NumIndices_, Options_, IndexType_ > & setRandom()
static void test_slice_as_lvalue()
static void test_composition()
A cost model used to limit the number of threads used for evaluating tensor expression.
#define CALL_SUBTESTS_TYPES_LAYOUTS(PART, NAME)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorReshapingOp< const NewDimensions, const Tensor< Scalar_, NumIndices_, Options_, IndexType_ > > reshape(const NewDimensions &newDimensions) const
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StoragePointerType data()
#define VERIFY_IS_APPROX(a, b)
static const Line3 l(Rot3(), 1, 1)
static void test_reshape_in_expr()
#define VERIFY_IS_EQUAL(a, b)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DenseIndex TotalSize() const
static void test_slice_raw_data()
#define CALL_SUBTEST_1(FUNC)
A tensor expression mapping an existing array of data.
Tensor< float, 1 >::DimensionPair DimPair
static void test_strided_slice()
EIGEN_ALWAYS_INLINE DSizes< IndexType, NumDims > strides(const DSizes< IndexType, NumDims > &dimensions)
static void test_simple_slice()
static void test_slice_in_expr()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorSlicingOp< const StartIndices, const Sizes, const Tensor< Scalar_, NumIndices_, Options_, IndexType_ > > slice(const StartIndices &startIndices, const Sizes &sizes) const
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set offsets
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar * data()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(std::size_t n) const
int EIGEN_BLAS_FUNC() copy(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
A reference to a tensor expression The expression will be evaluated lazily (as much as possible)...
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
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.
static void test_static_reshape()
static const int DataLayout
EIGEN_DECLARE_TEST(cxx11_tensor_morphing)