Re: [eigen] matrix::linspace |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] matrix::linspace*From*: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>*Date*: Tue, 26 Jan 2010 16:54:11 -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; bh=lshU0pg44slHgFaj5kO8lxD2KsMWN0FURH+400kZs6Q=; b=gqkLAKNgyF3TfHMl8fVAFmMeDwXZAP6pFgY0FWDTb6YvK3Xu4ZdGWAk9JxpNujVqE5 QMBljHN2OnDe1JZsrEwbg91pYQeBVIYwN9MHgoD5jf8JvZNu5MC3P6uuHfGeMDqWZ0g0 ouXx0GslXdHP9vd7JolLj5MQ5HudTmSi5kykE=*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; b=uPiU6kzIdwfP+cEctlq0jt2/8q9wVnrM+/3o3GCmzxB/OCSyzNFOm/ydHF+Rtiyn3v yZGcX8A3lzbZeI0x+nZNRBv5LPg8vH9vQNR+tTcLizN2OZv6ADqad0pyAJ0psomLQckT unABjoXljsBNquKgeCXTZ6BktwrWmmCu2xF/c=

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

**Follow-Ups**:**Re: [eigen] matrix::linspace***From:*Hauke Heibel

**Re: [eigen] matrix::linspace***From:*Jitse Niesen

**References**:**[eigen] matrix::linspace***From:*Hauke Heibel

**Re: [eigen] matrix::linspace***From:*Benoit Jacob

**Re: [eigen] matrix::linspace***From:*Hauke Heibel

**Re: [eigen] matrix::linspace***From:*Hauke Heibel

**Re: [eigen] matrix::linspace***From:*Benoit Jacob

**Re: [eigen] matrix::linspace***From:*Hauke Heibel

**Re: [eigen] matrix::linspace***From:*Benoit Jacob

**Re: [eigen] matrix::linspace***From:*Hauke Heibel

**Re: [eigen] matrix::linspace***From:*Benoit Jacob

**Re: [eigen] matrix::linspace***From:*Hauke Heibel

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] std::vector specialization** - Next by Date:
**Re: [eigen] matrix::linspace** - Previous by thread:
**Re: [eigen] matrix::linspace** - Next by thread:
**Re: [eigen] matrix::linspace**

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