Re: [eigen] aliasing system |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] aliasing system*From*: Benoît Jacob <jacob@xxxxxxxxxxxxxxx>*Date*: Thu, 6 Sep 2007 18:07:53 +0200

Yes, I thought of that. But in some cases it's more complicated than that. For example: matrix.xpr().row(0) += 2 * matrix.row(1) + matrix.row(2) Here, there is no problem. No need to use alias(). Yet your approach based on the memory addresses of objects will detect that the same matrix is being involved on both sides, so it'll decide (wrongly) that an alias is needed. That would be very, very bad for performance because the whole matrix would be copied, not only row(0) ! Since there is no fully working solution, I prefer keeping things simple and clear, than trying to outsmart users with a solution that doesn't always work. Cheers, Benoit On Thursday 06 September 2007 17:57:59 Andre Krause wrote: > Benoît Jacob wrote: > > On Thursday 06 September 2007 16:02:15 Andre Krause wrote: > >> so then if there is no way to avoid this problem - what about a sort of > >> #pragma warning or assertion that gets thrown / printed in DEBUG mode > >> only, if a user tries to do > >> > >> m = m*m; > >> > >> is there some template magic available to detect this? > > > > Very good idea. Yes, I think that can be done with partial template > > specialization. Will try. > > wouldnt it be easier to compare the memory adresses of the objects? > > suppose we have 2x2 matrices > u, v, w, and we do: > u = v * w; > > it will hopefully unroll to some function call to > > > typedef Matrix<float, 2,2> M; > > void _ET_magic_generated_func(M& u, const M& v, const M& w) > { > #ifdef _DEBUG > if(&u == &v || &u == &w) > std::cerr << "some warning!!"; > #endif > > u11 = v11*w11 + v12*w21; > u21 = v21*w11 + v22*w21; > u12 = v11*w12 + v12*w22; > u22 = v21*w12 + v22*w22; > } > > > now, if we do the bad thing of > > m = m*m; > > it will detect that the pointers are identical and thus matrix product > will get wrong result.

**Attachment:
signature.asc**

**Follow-Ups**:**Re: [eigen] aliasing system***From:*Schleimer, Ben

**Re: [eigen] aliasing system***From:*Schleimer, Ben

**References**:**[eigen] aliasing system***From:*Benoît Jacob

**Re: [eigen] aliasing system***From:*Benoît Jacob

**Re: [eigen] aliasing system***From:*Andre Krause

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] aliasing system** - Next by Date:
**Re: [eigen] aliasing system** - Previous by thread:
**Re: [eigen] aliasing system** - Next by thread:
**Re: [eigen] aliasing system**

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