[eigen] Malloc-free dynamic matrices

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


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

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


Attachment: malloc-free-resize.patch
Description: Binary data

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