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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ab436e97ff76821f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.223.40 with SMTP id qr8mr275572pbc.0.1342053027017; Wed, 11 Jul 2012 17:30:27 -0700 (PDT) Path: l9ni11511pbj.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: robin.vowels@gmail.com Newsgroups: comp.lang.ada Subject: Re: Does Ada need elemental functions to make it suitable for scientific work? Date: Wed, 11 Jul 2012 17:22:36 -0700 (PDT) Organization: http://groups.google.com Message-ID: <0deb87e9-dadb-4ece-9287-5ed110dfca1d@googlegroups.com> References: <18c77859-480c-41f5-bb1c-df7ad067f4f3@googlegroups.com> <637de084-0e71-4077-a1c5-fc4200cad3cf@googlegroups.com> NNTP-Posting-Host: 123.2.70.40 Mime-Version: 1.0 X-Trace: posting.google.com 1342053026 2911 127.0.0.1 (12 Jul 2012 00:30:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 12 Jul 2012 00:30:26 +0000 (UTC) Cc: nma@12000.org In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=123.2.70.40; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-07-11T17:22:36-07:00 List-Id: On Tuesday, 10 July 2012 18:39:58 UTC+10, Nasser M. Abbasi wrote: > On 7/10/2012 3:02 AM, gautier.de...@gmail.com wrote: > > Le mardi 10 juillet 2012 07:22:58 UTC+2, Ada novice a =E9crit : > > > >> Believe me, for someone who do numerical computations on a daily= basis, an operation > >like V**2 is a NECESSITY. It&#39;s a pity that Ada does not offer= such a facility. > >I do not blame those who stick to Matlab (or Fortran?) for doing nume= rical 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 f= or > > the next standard (and short term for the next GNAT version). > > >=20 > That is a start. But not enough by any means. All functions should be > vectorized. Even user defined ones. >=20 > In Ada, I can't even take the sin of a vector But you can in PL/I. > ---------------------- > with Ada.Numerics.Elementary_Functions; > use Ada.Numerics.Elementary_Functions; >=20 > procedure foo3 is > type array_t is array(1..5) OF float; > D : constant array_t :=3D(0.1,0.2,0.3,0.4,0.5); > V : array_t; > =20 > begin > -- V :=3D sin(D); -- ERROR >=20 > for I in D'Range loop -- must use a LOOP > V(I) :=3D sin(D(I)); > end loop; > =20 > end foo3; > -------------------- >=20 > I can ofcourse overload sin, hide the loop inside my own sine > and then do >=20 > V:=3D myPackage.sin(D); >=20 > All of this is possible in Ada. It is just a little (alot?) > more effort compared to what is out there. >=20 > octave/Matlab: > -------------------------- > D=3D[0.1,0.2,0.3,0.4,0.5]; > sin(D) >=20 > ans =3D > 0.0998 0.1987 0.2955 0.3894 0.4794 > --------------------------- and PL/I. > > The snag with that *specific* operation, v**2 meaning "v(i)**2 = for each i", > >is that it is counter-intuitive from a linear algebra point of view. = You > >would rather expect v**2 =3D v*v. Now another snag is should "*&= quot; be the > >dot or the cross product ?... > > > > These kind of things are thought-out carefully before landing into a= n Ada standard... > > >=20 > But these issue have been solved long time time. (like maybe > 30 years ago? and are well defined for all cases: More like 45 years ago, for PL/I has had that facility since 1966. For vectors, matrices (in fact multi-dimensional arrays), and for cross-sections of arrays.