Re: [eigen] On lazy evaluation and temporary matrices |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] On lazy evaluation and temporary matrices*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Thu, 25 Nov 2010 08:25:36 +0100*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=87t5JOINgOxo0a31ls8FwM7kYGpfuOXEvMYtizu/nd4=; b=nCaEkVP3FmHyv/lO6tqLaFeZfBhhMmnhNRe/jPXk+cyDWb1Rvwari2oNR1asJ4N75B prFSJw6ol+TeGcf5ziRjX1QgdN9/gkDN3K4Ghh8trC16c8U0oSrQf0CZtDSF9G3xwvnT 4VK8Ose+tII+fOzhV98ATdwl5oYR9jqw6iHyA=*Domainkey-signature*: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=YkC339CMJCFy512zSkWSSO8mavTAYAmZIiMnmPlClxsKyeUp+voC2CppQIbaMbY24j 3Ksz7psH/VWFHqbnG+c/YSt4oRJZvoPisexbMMX59c+Kn9tel18RwBIg/5r3Jpy5uKDO Zy8FBkDoHfYqN+kmXzwg1Ujg9I0jj/QjNfht8=

Hi, first make sure to test it in "debug mode", i.e., without NDEBUG or EIGEN_DEBUG defined to enable the detection of some some alignment issues. If that does not help, try to disable vectorization by defining EIGEN_DONT_VECTORIZE. Is your code multithreaded? Also in your case the .eval() is superfluous. gael On Thu, Nov 25, 2010 at 2:45 AM, Jose Luis Blanco <joseluisblancoc@xxxxxxxxx> wrote: > Hi Thomas, > > Thanks, I added the EIGEN_ALIGN16 macro to all the number arrays, it > definitively makes sense... but it behaves exactly the same :-( > > Best, > JL > > PS: And yes, it's beta3*, actually an hg checkout from a few days ago... > > On Thu, Nov 25, 2010 at 2:22 AM, Thomas Capricelli > <orzel@xxxxxxxxxxxxxxx> wrote: >> It looks like an alignement problem. You should ensure "numbers" is aligned, >> see bottom of http://eigen.tuxfamily.org/dox-devel/ >> >> (I assume you use the devel branch.. 3.0beta*) >> >> regards, >> >> -- >> >> Thomas Capricelli <orzel@xxxxxxxxxxxxxxx> >> >> http://www.freehackers.org/thomas >> >> On Thursday 25 November 2010 02:01:48 Jose Luis Blanco wrote: >> >>> Hi guys, >> >>> >> >>> I need the help of someone knowing the inner workings of Eigen. I've >> >>> spent a few days stuck debugging an error in some silly computations >> >>> with Eigen matrices, and want to rule out potential errors... >> >>> Consider this code: >> >>> >> >>> ====================== >> >>> void func( Matrix<...> &m_out ) >> >>> { >> >>> Matrix<...> I = .... >> >>> const double numbers[] = { 1.0, x(), -y()*x() , whatever, .... }; >> >>> m_out = I * Matrix<...>(numbers); >> >>> } >> >>> >> >>> int main() >> >>> { >> >>> Matrix<...> M; >> >>> func(M); >> >>> cout << M << endl; >> >>> } >> >>> ====================== >> >>> >> >>> Is it a problem for the temporary object "Matrix<...>(numbers)" to be >> >>> created with a pointer to memory on the stack, while the evaluation of >> >>> the object for the matrix product is actually evaluated *out* of that >> >>> function (where obviously that pointer is invalid)?? >> >>> >> >>> I ask because I'm having a very erratic behavior in code like above >> >>> (on GCC doesn't work, it does on MSVC; adding a "cout << ..." for an >> >>> unrelated matrix changes the result, etc...). >> >>> Is it necessary to use instead: >> >>> >> >>> ( I * Matrix<...>(numbers) ).eval(); >> >>> >> >>> or not even with this .eval() is my code correct? >> >>> I'm still having random wrong matrix elements with and without eval(), >> >>> so I wanted to be sure on this part before keep on debugging... >> >>> >> >>> Thanks for your time! >> >>> JL >> >>> >> >>> >> >>> > > > > -- > ___________________________________________________________ > > Dr. Jose-Luis Blanco-Claraco > Dpt. Ing. Civil, Mat. y Fabric - Phone: +34 952 152435 > E.T.S.I. Industriales - Despacho 2.037 > Dpt. Ing. Sist. y Automática - Phone: +34 952 132848 > E.T.S.I. Telecomunicacion - Lab. 2.3.6 > Universidad de Malaga - Campus Universitario de Teatinos > 29071 Malaga, Spain > http://www.isa.uma.es/jlblanco > http://www.mrpt.org/ > ___________________________________________________________ > > >

**References**:**[eigen] On lazy evaluation and temporary matrices***From:*Jose Luis Blanco

**Re: [eigen] On lazy evaluation and temporary matrices***From:*Thomas Capricelli

**Re: [eigen] On lazy evaluation and temporary matrices***From:*Jose Luis Blanco

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] On lazy evaluation and temporary matrices** - Next by Date:
**[eigen] [Sparse] element acces in a cwise unary op on an Eigen::Sparse** - Previous by thread:
**Re: [eigen] On lazy evaluation and temporary matrices** - Next by thread:
**[eigen] [Sparse] element acces in a cwise unary op on an Eigen::Sparse**

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