Re: [eigen] still the solve() API debate

[ Thread Index | Date Index | More Archives ]

On Fri, Sep 11, 2009 at 4:54 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> 2009/9/11 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
>> On Fri, Sep 11, 2009 at 3:36 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>>>> Ok, I just caught up with re-reading... that's indeed ugly. But as you
>>>> guys already observed, in new compiler versions we already have rvalue
>>>> references. Benoit, what about your idea of passing Matrices by
>>>> reference and MatrixBase by value? You suggested to do that in the
>>>> "MatrixBase::swap - why const" thread? This approach would allow an
>>>> easy transition towards rvalues references in the future.
>>> That would be perfect, if you figure it out.
>> Great, now I am confused again - just while thinking about it. :)
>> Why not simply define swap as
>> template <typename OtherDerived>
>> void swap(MatrixBase<OtherDerived> m);
>> I mean in any case. It does not really matter whether a matrix is
>> passed or not - what we will copy is always only MatrixBase and that's
>> tiny, right?
> It can't be that simple: indeed MatrixBase is empty, it doesn't have
> data members. If things could work like this, then when copying the
> MatrixBase object we wouldn't copy any information, hence the matrix
> "m" would be completely forgotten.
> That said you raise my curiosity, i almost want to try a small program
> to see what happens (but in any case that can't work!) too bad i must
> prepare a lecture now.

indeed, that cannot work, because what you get is an empty object and
so accessing its coefficients will generate a segfault whatever
OtherDerived is (a Matrix or an expression). Even using .rows() on
this object will generate an invalid read (unless it is known at
compile time).


Mail converted by MHonArc 2.6.19+