Re: [eigen] Re: VectorBase issue

[ Thread Index | Date Index | More Archives ]

On Tuesday 03 June 2008 11:10:07 Gael Guennebaud wrote:
> 1 - first of all, since VectorBase inherits from nothing, we must
> duplicated the MatrixBase::derived() method and call it whenever we want to
> access a MatrixBase member.

Right. If I understand well you mean that we need a VectorBase::derived() 
method returning *this casted to Derived* --- or perhaps to MatrixBase*? 
Since the goal is to call MatrixBase methods, it is probably be better to 
just cast to MatrixBase*. One could still call that method derived(), this is 
slightly misleading but AFAICT not dangerous, and makes the source code look 

> Actually I think this is good in general since 
> it allows to overload a MatrixBase member in Derived, and the proper
> overload will be called.

Sorry, I don't understand what you mean. Can you explain?

> So, any suggestion ? should I give up with VectorBase ? and if not, which
> options looks the best for issue 2 ?

Hey, I have an idea so we can go on with VectorBase :)

How about just leaving all the methods, including the vector-specific ones, in 
MatrixBase; but then have the vector-specific ones call a special method from 
VectorBase -- so that compilation will fail if VectorBase doesn't have that 

Like this:

Scalar& coeffRef(int i)
return derived()._coeffRef(i);

So that the user will see a nice compiler error message :)

This works also the other way around, "only for matrices", "only for dynamic 
size", "only for fixed-size", "only for matrices that have any chance of 
being square" etc... we could have many such checks.

What do you think?

The main issue for me is not so much catching errors at compile time versus 
runtime, this is nice but not vital. What matters more to me is reducing 
compilation time, so if VectorBase can help with that it's more than welcome.


Attachment: signature.asc
Description: This is a digitally signed message part.

Mail converted by MHonArc 2.6.19+