Hi all,
currently, many Eigen methods have a dynamic-size and a fixed-size version,
e.g.
VectorBlock<Derived> segment(Index start, Index size);
VectorBlock<Derived, Size> segment<int Size>(Index start);
It would make generic programming a lot easier to add an overload
VectorBlock<Derived, Size> segment<int Size>(Index start, Index size);
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
eigen_assert(Length == Dynamic || Length == length);
return VectorBlock<Derived, Size>(derived(), start, size);
}
The first two methods could then refer to this one:
VectorBlock<Derived> segment(Index start, Index size)
{
return segment<Dynamic>(start, size);
}
VectorBlock<Derived, Size> segment<int Size>(Index start)
{
EIGEN_STATIC_ASSERT(Size != Dynamic)
return segment<Size>(start, Size);
}
This change would enable use cases such as the following (contrived)
example:
template <int M>
struct Foo
{
Foo(Index m) : a(m*2) {}
void bar()
{
Index m = a.size() / 2;
a.segment<M>(0, m) += a.segment<M>(m, m);
}
enum { Rows = M == Dynamic ? Dynamic : M*2 };
Eigen::Array<float, Rows, 1> a;
};
Marton