Advertisement
Guest User

Tensor Custom Index / Normal index

a guest
Oct 9th, 2015
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <memory>
  3. #include <type_traits>
  4. #include <Eigen/CXX11/Tensor>
  5.  
  6.  
  7.  
  8. void main(){
  9.  
  10.     using T = Tensor<double, 3>;
  11.     T tensor(5,5,5);
  12.  
  13.     using CustomIndex = Matrix<unsigned int,3,1>;
  14.     CustomIndex indicesC(3,1,2);
  15.  
  16.     using NormalIndex = DSizes<ptrdiff_t, 3>;
  17.     NormalIndex indices(3,1,2);
  18.  
  19.  
  20.     EIGEN_ASM_COMMENT("Normal INDEX");
  21.     auto s = tensor.coeff(indices);
  22.     EIGEN_ASM_COMMENT("Normal INDEX END");
  23.     std::cout << s << std::endl;
  24.     EIGEN_ASM_COMMENT("CUSTOM INDEX");
  25.     auto s2 = tensor.coeff(indicesC);
  26.     EIGEN_ASM_COMMENT("CUSTOM INDEX END");
  27.     std::cout << s << s2 << std::endl;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement