Re: [eigen] Block sparse matrices and std vector compilation error

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




On Wed, Nov 26, 2014 at 2:59 PM, Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:

<DeveloperNotes>

We should probably add a constructor of Block<const X> from Block<X> to make (*) work. OTOH, explicitly storing Block objects is not good style anyways, IMO.

Defining Block objects locally is perfectly fine and sometimes help to make the code clearer. In this case, it is recommended to either use auto or Block ctor, that is:

auto b = a.block(...); // C++11
Block<MatrixXd> b(a, ...); // C++03

Doing:

Block<MatrixXd> b = a.block(...);

is error prone and should not be encouraged.

Storing Block objects within containers or as class attributes is indeed more questionable.
 

For Block<SparseMatrix> we should probably make it more clear that it does not have an assignment operator at all (implement an operator= which raises a static assertion).
And for Block<*> it would be nice if we could tell the compiler that it is not actually copy-assignable (I'm afraid, there is no easy way to tell this without having C++-concepts (which did not even make it into C++11)).

Block is really like a reference. Perhaps it would help to make this analogy clearer in the doc.

gael
 

</DeveloperNotes>


Cheers
Christoph


--
----------------------------------------------
Dipl.-Inf., Dipl.-Math. Christoph Hertzberg
Cartesium 0.049
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: +49 (421) 218-64252
----------------------------------------------





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