Re: [eigen] Malloc-free dynamic matrices

[ Thread Index | Date Index | More Archives ]

2010/3/2 Márton Danóczy <marton78@xxxxxxxxx>:
> Hi,
> I have implemented an option for malloc-free matrices similar to
> Matrix<Scalar, Dynamic, Dynamic, Options, MaxRows, MaxCols>, but
> heap-allocated (i.e., potentially huge) and the max size not known at
> compile time. My use case is real-time data processing on an iPhone,
> where buffers are Eigen matrices that gets resized very often (every
> time the input has been polled).
> The only API changes are a new option NeverRealloc (the name is maybe
> not the best) and a method reserve(int size) that allocates the
> memory. Then, a Matrix<Scalar, Dynamic, Dynamic, NeverRealloc> keeps
> track of its allocated size via the member variable m_size and each
> mat.resize(rows, cols) only changes two ints instead of actually
> allocating memory. If rows*cols < m_size, an assertion error is
> raised.
> Would be great if someone could comment on the attached patch.
> Unfortunately, the test suite is currently broken (in
> test/mixingtypes.cpp),


> so I couldn't test it, but it works in my
> project.

I haven't yet looked very carefully at your patch but the idea sounds
reasonable and implementing this as a matrix option is a plausible
approach... my main concern right now is that it's touching and
complexifying a few very central places in Eigen, whereas the use case
is very special. For that reason I wonder if this should rather be
implemented as a new separate variant of the Matrix class itself...

I'll be waiting for other peoples opinions...


> Greets,
> Marton

Mail converted by MHonArc 2.6.19+