[eigen] Feature request: Add compile-time access to Eigen::Map dimensionality

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


I would like to propose compile-time access to Eigen::Map dimensionality to align the Map API with the TensorMap API. Possible implementation:

const static int NumDimensions = IsVectorAtCompileTime ? 1 : 2;

(If there are more Eigen-idiomatic methods to achieve this functionality suggestions are most welcome)

My use case is this: I have a class Inputs<Ts....> that is templated over a list of tensor maps. The class is constructed with a corresponding number of Tensors, and these Tensors sliced via Eigen::TensorMap and processed in parallel by a thread pool. NumDimensions is used to determine what are spatial dimensions and what are batch dimensions. The leading dimensions (dimension zero to NumIndices) are treated as batch dimensions, while the rest are treated as spatial dimensions.

With this proposal, Eigen::Map and Eigen::TensorMap share the same API for type and dimension (Scalar and NumDimensions), so that Eigen::Map can used together with TensorMaps without meta programming.

In addition, compile time access to image dimensionality is important for medical image processing libraries (my background). 

I am happy to contribute a patch with whatever the maintainers deem the best name (NumDimensions or NumIndices or something else), the most appropriate implementation, and the best place to put it (e.g. in matrix class or only in map class). 

Kind Regards,

Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/