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 autolearn=ham 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-7-bit Received: by 10.68.219.170 with SMTP id pp10mr24494025pbc.1.1341918381297; Tue, 10 Jul 2012 04:06:21 -0700 (PDT) Path: l9ni11304pbj.0!nntp.google.com!news2.google.com!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Does Ada need elemental functions to make it suitable for scientific work? Date: Tue, 10 Jul 2012 12:06:20 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="c5d47e33cdb0a6fb95c07f57c1728133"; logging-data="32136"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188skdOPWU1+bpVj89/sYYMLKVPV74PzwU=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (darwin) Cancel-Lock: sha1:RIgtEx6xOj7AsKTLivdYjc1X+0c= sha1:MaKFzxnyAZIUo/0LEC7hepS1i+U= Content-Type: text/plain Date: 2012-07-10T12:06:20+01:00 List-Id: "Nasser M. Abbasi" writes: > In Fortran, I can just write V**2, where V is a vector. In Ada, I > can't do that. Since ** is not defined on this array type and this > number type. > > I would have to write a loop to iterate over V and do V(I)**2 on each > element. > > This for me, is a step backward. This is how Fortran77 was. > > I know I am a newbie in Ada, and I could have overlooked a simple > solution to do this. But I really do not want to write packages and > define operators each time and for each type I make to have it work as > elemental function each time. > > This is something that should be build into the language. The relevant AI is, I think, AI95-00296[1]. The !discussion says that "The component by component operations of * / and ** on vectors have been deleted [from ISO/IEC 13813] on the grounds that they are not useful. (They might be useful for manipulating arrays in general but we are concerned with arrays used as vectors for linear algebra.) "Operations for vector products were considered but not added. This is because, as usually defined, they only apply in three-dimensional space." GNAT would allow you to implement them fairly easily using System.Generic_Array_Operations (which is a GNAT internal package that survived the transition to GNAT GPL 2012!). You could make the case that they are in fact useful and should be incorporated, but of course that won't happen until the 202x revision. [1] http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00296.txt?rev=1.23