From: Warren <ve3wwg@gmail.com>
Subject: Re: Inferring array index type from array object
Date: Wed, 30 Jun 2010 16:43:38 +0000 (UTC)
Date: 2010-06-30T16:43:38+00:00 [thread overview]
Message-ID: <Xns9DA78177A9C91WarrensBlatherings@81.169.183.62> (raw)
In-Reply-To: 102a43e8-21ea-4606-8b0d-6d492f9e07f8@v13g2000prn.googlegroups.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1986 bytes --]
Adam Beneschan expounded in news:102a43e8-21ea-4606-8b0d-6d492f9e07f8
@v13g2000prn.googlegroups.com:
> On Jun 29, 2:00�pm, Warren <ve3...@gmail.com> wrote:
>> Warren expounded
>> > Adam Beneschan expounded
>> > @b4g2000pra.googlegroups.com:
..
>> >> Isn't that just 1.0 / X? �
>>
>> > Ok, it seems to be, as the GSL (Gnu Scientific Library)
>> > defines it as:
>>
>> > gsl_complex
>> > gsl_complex_inverse (gsl_complex a)
>> > { � � � � � � � � � � � � � � � /* z=1/
> a */
>> > � double s = 1.0 / gsl_complex_abs (a);
>>
>> > � gsl_complex z;
>> > � GSL_SET_COMPLEX (&z, (GSL_REAL (a) * s) * s, -(GSL_IMAG (a) * s) *
>> s);
>> > � return z;
>> > }
>>
>> gsl_complex
>> gsl_complex_div (gsl_complex a, gsl_complex b)
>> { � � � � � � � � � � � � � � � /* z=a/b
> */
>> � double ar = GSL_REAL (a), ai = GSL_IMAG (a);
>> � double br = GSL_REAL (b), bi = GSL_IMAG (b);
>>
>> � double s = 1.0 / gsl_complex_abs (b);
>>
>> � double sbr = s * br;
>> � double sbi = s * bi;
>>
>> � double zr = (ar * sbr + ai * sbi) * s;
>> � double zi = (ai * sbr - ar * sbi) * s;
>>
>> � gsl_complex z;
>> � GSL_SET_COMPLEX (&z, zr, zi);
>> � return z;
>>
>> }
>>
>> Given a=1.0, the inverse function is definitely
>> higher performance. �It's simpler calculation
>> probably implies more accuracy as well.
>
> That last makes no sense to me. The code to compute A / Z for real A
> has got to be essentially the same as computing 1.0 / Z and then
> multiplying the real and imaginary parts of the result by A---how else
> would it be done? So while you might gain slightly in efficiency by
> not performing an extra step, I don't see how you can gain in
> accuracy---I've never heard of accuracy ever getting lost by
> multiplying a floating-point number by 1.0.
I'll concede your accuracy point. Efficiency however is
still important for some applications, like realtime signal
processing.
Warren
next prev parent reply other threads:[~2010-06-30 16:43 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-23 7:30 Inferring array index type from array object Maciej Sobczak
2010-06-23 8:01 ` Dmitry A. Kazakov
2010-06-23 9:03 ` J-P. Rosen
2010-06-23 12:24 ` Georg Bauhaus
2010-06-23 12:52 ` J-P. Rosen
2010-06-23 19:09 ` Simon Wright
2010-06-24 7:25 ` Georg Bauhaus
2010-06-23 14:38 ` Robert A Duff
2010-06-23 15:17 ` J-P. Rosen
2010-06-23 17:17 ` Robert A Duff
2010-06-24 6:16 ` J-P. Rosen
2010-06-23 12:13 ` Niklas Holsti
2010-06-23 14:27 ` Peter C. Chapin
2010-06-23 20:24 ` Niklas Holsti
2010-06-23 16:33 ` Warren
2010-06-23 17:49 ` Dmitry A. Kazakov
2010-06-23 18:45 ` Warren
2010-06-23 20:39 ` Niklas Holsti
2010-06-28 13:44 ` Warren
2010-06-28 22:18 ` Niklas Holsti
2010-06-29 1:49 ` Adam Beneschan
2010-06-29 2:10 ` (see below)
2010-06-29 16:56 ` Warren
2010-06-29 17:50 ` John B. Matthews
2010-06-29 19:31 ` Warren
2010-06-29 20:06 ` Jeffrey R. Carter
2010-06-29 20:16 ` Warren
2010-06-29 20:22 ` Adam Beneschan
2010-06-29 20:39 ` Dmitry A. Kazakov
2010-06-29 20:55 ` Warren
2010-06-29 21:00 ` Warren
2010-06-29 21:47 ` John B. Matthews
2010-06-29 21:52 ` Damien Carbonne
2010-06-29 22:22 ` Adam Beneschan
2010-06-30 16:43 ` Warren [this message]
2010-06-29 21:18 ` Jeffrey R. Carter
2010-06-30 5:01 ` Simon Wright
2010-06-30 14:29 ` Adam Beneschan
2010-06-29 20:28 ` Damien Carbonne
2010-06-29 21:20 ` John B. Matthews
2010-06-23 13:12 ` Gautier write-only
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox