Re: [eigen] type of comma initializer ? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] type of comma initializer ?
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 12 Jan 2011 13:35:21 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=RwhGR6JROkp7EHVjo6rYz4XDKkyMbps4BbbqkE/E/VE=; b=Tm/mA5CHvbCWCUIALB6kv2ViPV/BddNG3xX+14TV8j77he9cREncQmXeZoLaNYivba 4WqEzV7b8TUGQtjeOJ2C8IhAlKZeTHkCfjM/kWrvz5RIVrFTIDSxp+2yUs05DHmr8xN2 hMqg40mcGLBBo17i2WjWn7wp6rFY1tGrGiivE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=fqlCq5wV/3jreodpiyu3rH+xcbGHbq3M4HsIzwmy+V+pAbr4e4yer6ZZlgruq7U7Ra nQfqG6aX3K7ASzvjr+Jw9m/uECqCZ+NG5vCCajFM9vgyAYbDkHBDa+6UiHr3rFkk17GB T3tvFj2yKnRQojxo0Ss4JTxY++9QGJiGw41WI=
you can also overwrite Discrete_Distribution::operator<<(x) to return
Density << x which is of type CommaInitializer<MatrixXd>.
gael
On Wed, Jan 12, 2011 at 12:12 PM, Helmut Jarausch
<jarausch@xxxxxxxxxxxxxxxxxxx> wrote:
> 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
>
>
>