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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,ab436e97ff76821f X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Received: by 10.224.182.77 with SMTP id cb13mr1410301qab.5.1343315443207; Thu, 26 Jul 2012 08:10:43 -0700 (PDT) Received: by 10.66.88.168 with SMTP id bh8mr1478468pab.10.1343315000111; Thu, 26 Jul 2012 08:03:20 -0700 (PDT) MIME-Version: 1.0 Path: a15ni105485768qag.0!nntp.google.com!q21no18069944qas.0!news-out.google.com!p10ni64936613pbh.1!nntp.google.com!border1.nntp.dca.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.straub-nv.de!reality.xs3.de!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Does Ada need elemental functions to make it suitable for scientific work? Date: Thu, 19 Jul 2012 20:51:33 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <18c77859-480c-41f5-bb1c-df7ad067f4f3@googlegroups.com> <637de084-0e71-4077-a1c5-fc4200cad3cf@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1342749097 14129 69.95.181.76 (20 Jul 2012 01:51:37 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 20 Jul 2012 01:51:37 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2012-07-19T20:51:33-05:00 List-Id: "Nasser M. Abbasi" wrote in message news:jtgpos$20g$2@speranza.aioe.org... > On 7/10/2012 3:02 AM, gautier.de.montmollin@gmail.com wrote: >> Le mardi 10 juillet 2012 07:22:58 UTC+2, Ada novice a �crit : >> >>> Believe me, for someone who do numerical computations on a daily basis, >>> an operation >>like V**2 is a NECESSITY. It's a pity that Ada does not offer such a >>facility. >>I do not blame those who stick to Matlab (or Fortran?) for doing numerical >>computations. >> >> Wait... There are *such* facilities and several built-in operations >> *like* that: >> http://www.ada-auth.org/standards/12rm/html/RM-G-3-1.html >> >> Apparently it is not enough. But it is possible to make a proposal for >> the next standard (and short term for the next GNAT version). >> > > That is a start. But not enough by any means. All functions should be > vectorized. Even user defined ones. That would be a complete change in philosophy for Ada. The expectation is that everything that can reasonably be done in libraries will be done that way. Note that Ada didn't add advanced containers directly in the syntax. It might be reasonable to propose to add additional operators to the Ada language to make this more possible. We did look at that for Ada 2005 and decided not to do it, mainly because most of the interesting operators are not unary or binary. (Think integration and differentiation.) > In Ada, I can't even take the sin of a vector Of course you can, with a trivial loop. for E of Vect loop E := Sin(E); end loop; And this has the distinct advantage of making it clear to other readers what it is that you are doing. > ---------------------- > with Ada.Numerics.Elementary_Functions; > use Ada.Numerics.Elementary_Functions; > > procedure foo3 is > type array_t is array(1..5) OF float; > D : constant array_t :=(0.1,0.2,0.3,0.4,0.5); > V : array_t; > begin > -- V := sin(D); -- ERROR > > for I in D'Range loop -- must use a LOOP > V(I) := sin(D(I)); > end loop; > end foo3; > -------------------- > > I can ofcourse overload sin, hide the loop inside my own sine > and then do > > V:= myPackage.sin(D); > > All of this is possible in Ada. Right. And this is what you are supposed to do. Note that in any case the Sin you are calling is not specially known to the compiler, so there is no benefit to having the compiler vectorize it: it will end up writing the loop anyway. (And hardware implementations of Sin generally do not meet Ada's checking and accuracy requirements, so it's hard to use them even if the compiler could recognize them.) > It is just a little (alot?) more effort compared to what is out there. Writing functions is what you do in Ada. And Ada is always about readability, including for those who aren't familar with your code. Things like Matlab have a very different purpose than Ada and of course are going to be easier to write. Ease of writing is not now and never will be a goal for Ada! Randy.