Re: [eigen] operator overloading vs expression templates, and the need to return references |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] operator overloading vs expression templates, and the need to return references
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Sat, 12 Sep 2009 10:08:41 -0400
- 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; bh=r58b/cwo/Ze7pzeuqI5kUKHRjz4DUdvj5BekeakE/Q8=; b=xh69eokCw+mkBloFzkznwPil4JVKXubCKH2cDsSNqArR3WLB2KVyXk2pW+vj/k3b2S W41BEkNDa5up/mEZgcoP6QnC6+s+I7hOfgfI169mDI/yJx5VxaZicdunDs+GCupYITIw 31K9dEmpM046Wa7NQVH68KDjycwUBTbXleiuk=
- 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; b=k+ewOuoUfsDnWj5YsAm14dj/W7L88L2/YYwRmfkwVmy1fv4NsoLrPmza1Htib1IrUN 3S6hXGf7FfPbdN3PkaCfvayFjDmeC2ye11Wm0JKR0267MBf1o1g7IYKdo07wSajL8Z/S d+QqhX+q/kZff0ANSS0QM3zpfgx+n/48DHg4I=
as Gael said, you can simply return by value at no cost as long as the
vector fits in 1 SIMD register. However such code would perform poorly
in non-vectorized mode, as you know.
if you want to play with something that only works when the function
is inlined, you can use __attribute__((always_inline))
Benoit
2009/9/12 Rohit Garg <rpg.314@xxxxxxxxx>:
>> understand correctly that's exactly what you want. But your above code
>> doesn't look safe at all to me: "temp" lives on the stack, when the
>> function returns the stack pointer is decremented and the content of
>> "temp" may then be overwritten.
> Yeah, i know it is dangerous, unless the function is inlined. Inlining
> it is about the only way of making this thing work. I guess i'll just
> have to live with it for now.
>
> --
> Rohit Garg
>
> http://rpg-314.blogspot.com/
>
> Senior Undergraduate
> Department of Physics
> Indian Institute of Technology
> Bombay
>
>
>