Re: [eigen] array functionality...

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


2010/3/9 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> On Tue, Mar 9, 2010 at 12:05 PM, Hauke Heibel
> <hauke.heibel@xxxxxxxxxxxxxx> wrote:
>> I need to verify this, but it feels as if the replicate implementation
>> is currently (at least on MSVC) slower than a hand crafted for loop
>> like:
>>
>> for (int i=0; i<size; ++i)
>>  norms(i) = (x - y.col()).matrix().squaredNorm();
>
> Just did that and the Eigen-fied version
>
> norms = (x.replicate(1,y.cols()) - y).matrix().squaredNorm()
>
> is way slower...

How about using a colwise() here?

norms = (x-y).matrix().colwise().squaredNorm()

(Dont remember for sure if squaredNorm is available in partial
reductions, but if it's not then it's easy to add, or you can replace
by this:

norms = (x-y).abs2().colwise().sum()

).

Benoit

>
> I probably need to look at the assembly.
>
> - Hauke
>
>
>



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