I have created a function to display the shape of a Tensor on eigen.
template<typename Scalar_, int rank>
void shape(const Eigen::Tensor<Scalar_, rank>& x)
{
cout << "( ";
for (int i(0); i<x.NumDimensions; i++){
cout << x.dimensions()[i];
cout << ",";
}
cout << ")";
}
To use it I have to do :
Tensor <double,2> t (2,2)
shape(t)
I would like to integrate it directly into the tensor class so that we can call it like this:
Tensor <double,2> t (2,2)
t.shape
How to extend Eigen's Tensor class to add functions?