Re: [eigen] type of comma initializer ?

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


On 01/12/11 11:59:54, Gael Guennebaud wrote:
> Hi,
> 
> (A << 1)
> 
> returns a CommaInitializer<typeof(A)> which stores a reference to A
> and fill it through the comma operator.
> 
> So basically, you cannot write such a Mat_init function.
> 
> I'm a bit puzzled by what would be the use case for that ?

e.g. a class Discrete_Distribution where the constructor takes such an 
object, e.g.

class Discrete_Distribution {
  MatrixXd Density;
public:
  Discrete_Distribution(INIT_TYPE& D) {   // ????
    Density.resize(D.size());    // ????
    Density << D;
};

To be used as

Discrete_Distribution  MyProb((0.1,0.3,0.1,0.4)); // ????

so probably I have to write
MatrixXd  ProbIni(4);
ProbIni << 0.1,0.3,0.1,0.4;
and call a contructor taking an const MatrixXd& parameter.

Or, I'll have to wait for the tuple template in C++0X ?

Thanks,
Helmut.


> 
> gael
> 
> 
> On Wed, Jan 12, 2011 at 11:43 AM, Helmut Jarausch
> <jarausch@xxxxxxxxxxxxxxxxxxx> wrote:
> > Hi,
> >
> > I'd like to put the initialization of a Matrix like
> >
> > Matrix<int,3,1> A;
> >
> > A << 1,2,3;
> >
> > into a function. I'd like to pass the object "1,2,3" as a 
> parameter.
> > What's the type of this expression. Or, what to fill in for
> > <UNKNOWN_TYPE> below?
> >
> > void Mat_init(Matrix<int,3,1>& X, <UNKNOWN_TYPE>&  Ini) {
> >  X << Ini;
> > }
> >
> > Many thanks for a hint,
> > Helmut.
> >
> >
> >
> 
> 
> 



-- 
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany



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