From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5f5a48f21d7f7525 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!.POSTED!not-for-mail From: Warren Newsgroups: comp.lang.ada Subject: Re: Inferring array index type from array object Date: Wed, 30 Jun 2010 16:43:38 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <6b20ed09-efc1-4df7-90f9-5e141482e8d0@d37g2000yqm.googlegroups.com> <1305oqccr1h2t$.x33x4oxwd84d$.dlg@40tude.net> <88ec2vF3uqU1@mid.individual.net> <88f9osFmcmU1@mid.individual.net> <88sld2F9m8U1@mid.individual.net> <73a0af1d-7213-44af-90fa-ed6de4c64ce8@b4g2000pra.googlegroups.com> <102a43e8-21ea-4606-8b0d-6d492f9e07f8@v13g2000prn.googlegroups.com> Injection-Date: Wed, 30 Jun 2010 16:43:38 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="9f8M0iN5t54V+4DF/iqO8g"; logging-data="12751"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lnDJciDehSR40NU8kaxJZFq8e9CXGHr4=" User-Agent: Xnews/5.04.25 X-Face: &6@]C2>ZS=NM|HE-^zWuryN#Z/2_.s9E|G&~DRi|sav9{E}XQJb*\_>=a5"q]\%A;5}LKP][1mA{gZ,Q!j Cancel-Lock: sha1:ZujRDiMAOWMovhLpE7Ho59yBki8= Xref: g2news2.google.com comp.lang.ada:13012 Date: 2010-06-30T16:43:38+00:00 List-Id: Adam Beneschan expounded in news:102a43e8-21ea-4606-8b0d-6d492f9e07f8 @v13g2000prn.googlegroups.com: > On Jun 29, 2:00�pm, Warren 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