Re: [eigen] cast ArrayXd* to ArrayXXd* |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] cast ArrayXd* to ArrayXXd*
- From: Holger Herrlich <holgerherrlich05@xxxxxxxx>
- Date: Wed, 26 Sep 2012 18:48:15 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=arcor.de; s=mail-in; t=1348678153; bh=Pu1rqw9HofMz+EnnpScniaGlHSoF12Rp0VTVXnuzmY8=; h=Message-ID:Date:From:MIME-Version:To:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=lVOjKSj1RCf67RnEX6PNyuOoXWcNbGK78/lo/2GN3BcD6dfZ3yU6MCW5XR5WDmxIP 8Ur75GkFidCIKzWsbvs1r7HXQS1LrhkgJEA0gz6QC78ebRA3XgZrPrLRMm6WLMiN5s IvDGbUD4JtGT5T1vprENZ7SYmWpCIct9eXyeGTsk=
I finally needed it to run this: (and can avoid casting)
a1_2D->colwise() = *a1_1D;
*a2_2D = a2_2D->binaryExpr( *a1_2D, ptr_fun<double,double,double>(fn));
Well, I choose to use "new" because I don't know the array size at
calling the function. Also avoided the call by reference parameter while
it was not that clear how the interface to python looks like later on.
Holger
On 09/26/2012 04:22 PM, Christoph Hertzberg wrote:
> On 26.09.2012 14:50, Holger Herrlich wrote:
>>
>> Hi, did I really have to:
>>
>> Eigen::ArrayXXd* smInt;
>> Eigen::ArrayXd* tmp = fn_create();
>> smInt = new Eigen::ArrayXXd( *(tmp) );
>> delete(tmp.arrayXd);
>>
>> to cast from Array<double,len> to Array<double,len,1> when using
>> pointers?
>
> Well, there are many ways, but it would require a bit more context
> to find the best way in your case. Quite likely you don't need to use
> pointers at all (using plain pointers always bears the risk of memory
> leaks) and I don't know (m)any cases where ArrayXXd is accepted but
> ArrayXd is not (meaning I don't see why you need this cast).
>
> Christoph
>
>
>