Re: [eigen] What is the 'correct' way to pass matrix results? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] What is the 'correct' way to pass matrix results?
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Wed, 18 May 2011 18:35:45 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=u87IwRsC6KoQzEX1UXMHgOprxM995gVcKCceirvDBSw=; b=rLEYfVCyHJ2UtgJ6O0BigjYV9HnfFgeGCJCFmI9WAV7lXm6lHP24bKMrT5LLymi/o2 wxDlI7c8y0c/sctBPBMR5+L6Q5yPwrih9mZJtAFU2R6Fw2geBk1S1ctu8SRFNqjfneZK 6KsRm+xr1NBi8V15pVRzvYMoGIrQoAtwTUXqk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=rE7z3Eixg4UEfdtBuxqwB6t8FFJt/kqWn8jbj/h0qfevPg81ftY7osjGZBBqw3nP74 USObWzDucxvZR7KTEx9sHSBF+3eVB4NC/2WmhLXpjvZ0MEQnuAI9GAlN0bEuekiXSv2s LOwfhiSL7+oq/0nrWHCsctxBS32pfSPQo6YMw=
On Wed, May 18, 2011 at 4:37 PM, Christoph Hertzberg
<chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> On 18.05.2011 13:42, Hauke Heibel wrote:
>>
>> Hi Christoph,
>>
>> There is no single correct solution. It depends on your requirements
>> and your working environment.
>>
>> On Wed, May 18, 2011 at 12:43 PM, Christoph Hertzberg
>> <chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>>
>>> 1) Implement an expression template -- this might be ok if your code is
>>> in pre-final stage ... or if you return using C++0x auto return type;
>>> otherwise, I think it is a bit too complicated.
>>
>> I agree, that writing an expression is quite complicated but I
>> disagree that using an expression is complicated. Its usage gets only
>> complicated, when you try to store the expression into a temporary
>> which is not a PlainObject, i.e. when you exactly need to know the
>> type of an expression. In most cases you probably do not need this
>> knowledge.
>
> Well, I need to know the type if I want to return it -- unless I use C++0x
> in which case I can return auto (and can also use auto for temporary
> expressions).
Ah, I see. But even here you need to know what you want to return.
Consider this example:
template <typename Derived>
<whatgoeshere??> foo(const MatrixBase<Derived>& m)
{
return m*m;
}
in C++0x that would be
template <typename Derived>
auto foo(const MatrixBase<Derived>& m) -> decltype(m*m)
{
return m*m;
}
where you provide type information via decltype. What I mean is that
as far as I can see, you are lost when the function becomes more
complex and have to fall back to hand written expressions.
- Hauke