Search code examples
c++eigentensoreigen3

What is a Eigen::array (not Eigen::Array)


I'm using eigen tensor library and it seems to me that shuffle() method wants as input an object Eigen::array<type,int>.

In my implementation I have a std::list of int I need to pass to shuffle (of course I know the second int param (the rank) only at runtime!)


Solution

  • Not long ago Eigen's Tensor module was C++03 compatible. That implies that std::array is not available. For that reason the Tensor module defined its own Eigen::array class that is in fact a typedef for std::array if C++11 is available.

    The file unsupported/Eigen/CXX11/src/util/EmulateArray.h contains something that boils down to (pseudo-code)

    #if C++11 not available
      // Define a custom std::array like Eigen::array class
    #else
      template <typename T, std::size_t N> using array = std::array<T, N>;
    #endif
    

    The Tensor module has dropped C++03 compatibility and parts of this code could probably be removed.