Re: [eigen] matrix::linspace

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


2010/1/26 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> On Tue, Jan 26, 2010 at 7:56 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>> Hm. "high = (size-1)*s" is true to machine precision which is good
>> enough.
>
> This depends on your application. If you want something like this to work
>
> VectorXd x = VectorXd::LinSpaced(-1.0,1.0,10000);
> std:acos(x(0));
> std::acos(x(end));
>
> it better be in range or you'll end up with NaN when x(0)<-1 or
> x(end)>-1. But maybe that's too application specific.

I'd call that a problem specific to acos(), not to the problem at hand!

>
>> The only idea that I see is that every, say, 8 iterations, you
>> recompute the product with a multiplication (thus you get something
>> good to machine precision) and you forget about the 'accumulated'
>> value.
>
> This will seriously decrease performance.

Why? Take that as "partially unrolling the loop by 8". You're just
paying for an additional multiplication every 8 operations. Replace 8
by a larger value if that's still a concern.

>I am just reading a bit over here
>
> http://docs.sun.com/source/806-3568/ncg_goldberg.html
>
> and I might give the 'Kahan Summation Formula' a try. At least it does
> not include additional 'if' clauses.

Neither does my approach, once you take it as a partial unrolling. But
this approach will certainly decrease performance a lot, due to the
higher number of operations. I don't think that we're really in the
domain of application of this approach.

Benoit



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