Re: [eigen] Malloc-free dynamic matrices |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Malloc-free dynamic matrices
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 2 Mar 2010 08:45:03 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=mE06obWLcS+U4FwWx6iNFSx52BKZsfuq5mZ8Kp58ZhE=; b=FwhJGhiDov4zSlv0xxy2u8GQ6jO1hAf2l9sFVPdzUZgCGSCZUyTCVQjgwmT8Wx0nt2 KXpio6813k0X9fyeCmFXG4F4u5zRUlvp3fE7C5+wQ4G0yy7PvXWS7kYdxfxu0P9dreZl 485cEjIVA2hN9GBVlOsaMo8MtEIWdqGSSOFn4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=d8gBLMRCYlshnF9VQ40C7xqUjogxlgmjm35X7INdDZpZy+iqxA0fpqMhuBMIMOzkEV jfTg9HeTNnLwTNQzfv+4KE/BAkHOq2hpD3PaBzr8orV8VAcWUghRdOkZSyrxkbwTKYAi EEfJr9H9ZoOUsd8pSl+AkbowObPdckYRj+viM=
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),
Fixed.
> 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...
Benoit
>
> Greets,
> Marton
>