Re: [eigen] cast ArrayXd* to ArrayXXd*

[ Thread Index | Date Index | More Archives ]

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.


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

Mail converted by MHonArc 2.6.19+