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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham 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!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!feeder.erje.net!news2.arglkargh.de!news.musoftware.de!wum.musoftware.de!newsfeed.kamp.net!newsfeed.kamp.net!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!cleanfeed2-b.proxad.net!nnrp19-1.free.fr!not-for-mail Date: Tue, 29 Jun 2010 23:52:07 +0200 From: Damien Carbonne User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Inferring array index type from array object 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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4c2a6b0d$0$12729$426a74cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 29 Jun 2010 23:52:13 MEST NNTP-Posting-Host: 82.247.219.63 X-Trace: 1277848333 news-3.free.fr 12729 82.247.219.63:40330 X-Complaints-To: abuse@proxad.net Xref: g2news2.google.com comp.lang.ada:12978 Date: 2010-06-29T23:52:13+02:00 List-Id: Le 29/06/2010 23:00, Warren a �crit : > Warren expounded in news:Xns9DA6AC2A2C8BWarrensBlatherings@81.169.183.62: >>>> >>>> 1) The "inverse" of a complex number. >>> >>> Isn't that just 1.0 / X? >> > > Given a=1.0, the inverse function is definitely > higher performance. It's simpler calculation > probably implies more accuracy as well. > > Warren Ada has several overloaded versions of "/". GNAT seems to implement "/" (Real, Complex) using a simplified version of "/" (Complex, Complex). It looks (almost) like the example you gave. function "/" (Left : Real'Base; Right : Complex) return Complex is a : constant R := Left; c : constant R := Right.Re; d : constant R := Right.Im; begin return Complex'(Re => (a * c) / (c ** 2 + d ** 2), Im => -((a * d) / (c ** 2 + d ** 2))); end "/"; There are differences that may have an impact on speed. But the above version is simpler than this one: function "/" (Left, Right : Complex) return Complex is a : constant R := Left.Re; b : constant R := Left.Im; c : constant R := Right.Re; d : constant R := Right.Im; begin if c = 0.0 and then d = 0.0 then raise Constraint_Error; else return Complex'(Re => ((a * c) + (b * d)) / (c ** 2 + d ** 2), Im => ((b * c) - (a * d)) / (c ** 2 + d ** 2)); end if; end "/"; Damien