[eigen] Expression Template Question |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: [eigen] Expression Template Question*From*: Dalon Work <dwwork@xxxxxxxxx>*Date*: Mon, 20 Oct 2014 20:30:58 -0600*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=DDmVQRjZAq0rEGN3oDE2DFpoKohdfPulcLE28ibCLj8=; b=xv2e6xqHtPpgQN21zSgSwsAmNuFb+e8ae/HiYQB5WUfh5GnBx3l5Usj6d9UCLoZYcg +03zK6ALYo4/jXkYePK4amYeI0lVZambZjPReE+BmDsw+B9+RjdDRCnRvNg4y206cIqO o6ybEI9D6ohDtZOaPovF81Ef7Ycgr4gXqvdrQB7XLlXvL8J80zkewP92dhLC4yh1RFT0 QoxH1vY8ukEnuX46nmh0hrBQp0FULuwqfvaSxBpqATorlv9O9GDM2v2dZD+OkcTPVQt7 dKVgzbh1xnJma/Rpod4bKGo9ijHiH8z18d2nJjJ3i7ncAOU97r7Fg/T6ZXPybMe2qbPq LiVw==

I'm teaching myself the principles of how Eigen works by writing a small series of classes to copy its easier features, and have run into an issue that I'm not sure how to resolve. I am hoping for a little help understanding what is happening, and thought I should ask the experts.

I have an ArrayBase class defined as:

template <typename T, typename Derived> class ArrayBase;I have an ArrayBase class defined as:

template<typename OtherDerived>

inline const Derived& operator = (const ArrayBase<T,OtherDerived> &B)

{

for(int i=0;i<_size;i++){

static_cast<Derived*>(this)->operator[](i) =

static_cast<OtherDerived const &>(B).operator[](i);

}

return static_cast<Derived const &>(*this);

}

template <typename OtherDerived>

inline const AA_Add<T,Derived,OtherDerived > operator + (const OtherDerived &rhs) const

template<typename T,typename Lhs,typename Rhs>

class AA_Add : public ArrayBase<T,AA_Add<T,Lhs,Rhs> >

{

protected:

const Lhs &_lhs;

const Rhs &_rhs;

public:

inline AA_Add(const Lhs &lhs,const Rhs &rhs): _lhs(lhs), _rhs(rhs)

{

this->_size = rhs.size();

}

inline AA_Add(const AA_Add &A) : _lhs(A._lhs), _rhs(A._rhs){

this->_size = A._size;

}

inline virtual const T operator [] (const unsigned &i) const{

return _lhs[i] + _rhs[i];

}

};

And has assignment operator:

inline const Derived& operator = (const ArrayBase<T,OtherDerived> &B){

return ArrayBase<T,Derived >::operator = (B);

}

inline virtual const T operator [] (const unsigned &i) const

{

return this->_A[i];

}

}

I am not sure why this would be happening. Obviously the layered function calls are not getting stripped away, and I wonder if it is because I am using the [] operator (Eigen is hard to get through, but it doesn't look like it uses it) , or if it is because I'm returning the Addition class by value, or if I have stripped too much of the necessary complexity away.

Thanks in advance for your help.

Dalon

**Follow-Ups**:**Re: [eigen] Expression Template Question***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] 3.3-alpha1 for mid november?** - Next by Date:
**Re: [eigen] Expression Template Question** - Previous by thread:
**Re: [eigen] 3.3-alpha1 for mid november?** - Next by thread:
**Re: [eigen] Expression Template Question**

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