Re: [eigen] cast ArrayXd* to ArrayXXd* (comparision 2D>1D)

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


Hi

sorry for the long response time.
Whenever colwise()/rowwise() don't work you can use .replicate():
I inserted the corresponding lines below:

> //   won't do
//   arr2D.colwise() = ( arr1D<=0 ).select( 0, arr2D.colwise() );

    arr2D = (arr2D<0 || arr1D.replicate<1,5>() <= 0).select(0, arr2D);



//   arr2D = ( arr2D<0 ).select(     0, arr2D );
//   arr1D = ( arr1D<0 ).select( 1E-20, arr1D );

These work fine. You can also try this possibly faster call:
	arr2D = max(arr2D, 0.0);


    cout << ":2a:" << endl << (arr2D.colwise()+arr1D) << endl;  // works
    cout << ":2b:" << endl << (arr2D.colwise()>arr1D) << endl;  // fails

// Any of these work:
   cout << ":2c:" << endl << (arr2D.colwise() - arr1D > 0) << endl;
   cout << ":2d:" << endl << (arr2D > arr1D.replicate<1,5>()) << endl;
   cout << ":2e:" << endl << (arr2D > arr1D.replicate(1, 5)) << endl;

2c is a hack and not guaranteed to give exactly the results you want.


Hth,
Christoph


--
----------------------------------------------
Dipl.-Inf. 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/