Re: [eigen] array functionality... |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] array functionality...
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 9 Mar 2010 09:26:51 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=mCjMIVDMhNF0LrD7J6SQAwFtqN1iSE1usaACgAi1lSY=; b=mf3hwm3x1WOzYhR/lTNS8dDn4f5W0GD6rUFe8E7c0hpRJUppWG35XNYBBXM1igLEDj 7zEg6o56w1R9erTfkKkBPmaSiXoO93q3r7Oihp61eWKAFnJhmMxlbGXrymWN+tWxewlI FRDgliCWyTvUsBYPBfUTfLPWYyFJqNc5wBKqc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=tE+fkzjHFWwUJ4xK4JK1m9uwgDJOCPpGWamEbJy9MkqqJyyC8ZIFiqqLJXivsG9Vez OzRa8LbIP9HyTsWJ57MuG26EaEECaL1nhPfKrbHHK62WPztCddqlKJCjl5MBuIZtFfme Q8enUK5WRvgOkIyK1lnXgBRptrxusFSE2tZKE=
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
>
>
>