Re: [eigen] sparse matrix wrapper flavour |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] sparse matrix wrapper flavour*From*: Benoît Jacob <jacob@xxxxxxxxxxxxxxx>*Date*: Thu, 26 Jun 2008 10:40:58 +0200

Hi, all this sounds very good, On Wednesday 25 June 2008 23:43:20 Gael Guennebaud wrote: > { > typename SparseWrapper<MyMatrixType, AccessPattern>::type w(m); > // use w according to the access pattern you requested > } > // at the deletion of the wrapper, m is automatically updated. I see, sounds good. > To avoid redundancy, I see two approaches to implement such wrappers: > 1 - they inherit the corresponding sparse matrix class and simply > overload the constructor, destructor and store a reference to m; > 2 - they store an object of the corresponding sparse matrix type and > define operator* and operator-> such that they behave like a pointer. > > I think both approaches are more or less equivalent: > (1) allows to overwrite some matrix functions if needed, > (2) implies a pointer like style that emphasis the fact your dealing > with something different Given the choice, I tend to prefer storing a member object rather than inheriting. In your particular case, if you go for inheritance, since your wrapper class will be a different type than the wrapped class, it will lead to more template instantiations when you construct expressions classes like e.g. wrapper.col(i). So, I vote for (2). The only thing is, make sure that the wrapper class doesn't have a member (method or data) with the same name as a member of the wrapped class. So that if the user forgets to use "->" instead of "." he will get a compiler error. Otherwise the bug could be very hard to spot! Cheers, Benoit

**Attachment:
signature.asc**

**Follow-Ups**:**Re: [eigen] sparse matrix wrapper flavour***From:*Schleimer, Ben

**References**:**[eigen] sparse matrix wrapper flavour***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**[eigen] sparse matrix wrapper flavour** - Next by Date:
**Re: [eigen] two things** - Previous by thread:
**[eigen] sparse matrix wrapper flavour** - Next by thread:
**Re: [eigen] sparse matrix wrapper flavour**

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