Feature Request: Static .reshaped<nrows,ncols>()
Describe the feature you would like to be implemented.
If I understand correctly, the DenseBase::reshaped(nrows,ncols) assumes that nrows and ncols may be dynamic at runtime.
I think I can use Eigen::Reshaped<Derived,nrows,ncols>(m.derived()) with nrows and ncols known at compile time. But the Derived template parameter confuses me how to call this easily without the helper function (as seen in the doc)
template<typename Derived, int nrows, int ncols>
Eigen::Reshaped<Derived, nrows, ncols>
reshape_helper(Eigen::MatrixBase<Derived>& m)
{
return Eigen::Reshaped<Derived, nrows, ncols>(m.derived());
}
Then I can call reshape_helper(X,10,2) or reshape_helper( X.transpose(), 10,2) etc.
I would like to be able to do X.reshaped<10,2>() or X.transpose().reshaped<10,2>() et.
Would such a feature be useful for other users? Why?
This avoids creating this helper function and follows the same templating style for block and other operations with static sizes.
Hopefully this results in faster code by allowing compile-time code optimization through reshaped operations.
Any hints on how to implement the requested feature?
I guess use the reshape_helper internally?
Additional resources
Would love to know if what I'd like is already possible in someway that doesn't involve the helper. Or if there's a way to get Eigen::Reshaped to figure out its Derived parameter automatically for any input matrix/expression.