Re: [eigen] Re: VectorBase issue

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


Just updating the list:
we discussed that with Gael on #eigen and found that the best solution was 
static asserts, and we devised a way to have static asserts that produce 
really good error messages. Gael wrote and committed that.
-Benoit

On Wednesday 04 June 2008 00:03:17 Benoît Jacob wrote:
> 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 uniform.
>
> > 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 method?
>
> Like this:
>
> Scalar& coeffRef(int i)
> {
> stupid_human_you_called_on_a_matrix_a_method_that_is_only_available_for_vec
>tors(); 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.
>
> Cheers,
> Benoit


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



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