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

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


2009/9/11 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> On Fri, Sep 11, 2009 at 2:15 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>> Hey, what do you think about renaming .ref() by .inplace() in this
>> case? Then this API looks quite good to me:
>>
>> A.solve(b.inplace());
>>
>> I'd be OK with that API, actually I think that it's not even
>> significantly heavier than the plain-c++-reference option,
>> A.solveInPlace(b).
>
> But isn't that from an effort point of view again a little bit
> overkill. You would need to introduce a new class just in order to be
> able to write .inplace() instead of solveInPlace(). I would prefer
> A.solveInPlace(b)...
>
> Also, looking back at the discussion on clean output arguments - what
> was again the reason to pass a const reference to swap (first e-mail
> by Gael, case 3)?? The implementation is involving a const_cast! I
> mean swap changes the data. What am I missing?
>
> Currently, I completely fail to see arguments for ref(), inout() or
> similar... can we not just use the 'const' keyword to make it crystal
> clear when something is an output and when it is not?

The common answer to all your questions is that C++ has a very, very
stupid rule that one can't take a non-constant reference to a
temporary.

So when we do matrix.row(i).swap(matrix.row(j)), the method row()
returns a temporary and we can't take a non-const reference to it. So
my dirty workaround was to pass a const reference just to appease the
gods of c++ and then const-cast. Then Gael came by and proposed his
Reference (or Output) little class that is a trivial wrapper around a
reference, that we can pass by value. (It remains to be seen how we
can make swap use such an idea).

Same thing when we do A.solveInPlace(b.start(n)), start() returns a
temporary, same problem, whence the idea of inplace() or whatever we
call it.

Benoit



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