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,4692663255b51613 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!q36g2000yqn.googlegroups.com!not-for-mail From: Phil Clayton Newsgroups: comp.lang.ada Subject: Re: on using array index, vectorized operation Date: Tue, 29 Mar 2011 15:49:59 -0700 (PDT) Organization: http://groups.google.com Message-ID: <051388c7-8f38-46fb-afdd-da2759ecdd0a@q36g2000yqn.googlegroups.com> References: NNTP-Posting-Host: 91.110.254.39 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1301438999 301 127.0.0.1 (29 Mar 2011 22:49:59 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 29 Mar 2011 22:49:59 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q36g2000yqn.googlegroups.com; posting-host=91.110.254.39; posting-account=v7gx3AoAAABfjb9m5b7l_Lt2KVEgQBIe User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.9.1.9) Gecko/20100330 Fedora/3.5.9-1.fc12 Firefox/3.5.9,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:19558 Date: 2011-03-29T15:49:59-07:00 List-Id: On Mar 29, 10:17=A0pm, "Nasser M. Abbasi" wrote: > On 3/29/2011 1:11 PM, Phil Clayton wrote: > > > =A0Unfortunately, if you use real arrays for the i+1 in your > > example, you'll have real subscripts. =A0That may be acceptable when > > modelling e.g. in Matlab but not in an implementation. > > I am a little confused on the above. > > What do you mean by "you'll have real subscripts" ? > > Are you talking about Fortran now? Lets forget Matlab, since > Matlab is special case. (default is double for everything, etc...) > > For Fortran, why would the subscripts have to be floating point > numbers if the array content happened to be floating point values? > > Or are you talking about Ada here? Yes, I meant the Ada example after being updated to use vectorized subscripting. Sorry for the confusion. > > P.S. I still think Ada should allow us to write something like > > > =A0 =A0u (2 .. 5) :=3D (for i in 2 .. 5 =3D> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0u (i) - > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(a / 2.0) * (u (i+1) - u (i-1)) = + > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(a ** 2) / 2.0 * > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(u (i-1) - 2.0 * u (i) + u(i+1))= ); > > > (which avoids the temporary variable that the equivalent loop > > requires). > > Thats nice if possible to do. But just being able to write =A0in Ada > an index array as a variable and then write > > i :=3D 2..5; =A0-- using the correct range etc... syntax =A0for Ada > > and then write > > =A0 u(i) :=3D u(i) + u(i-1) - ...... > > would be nice. > > which is the 'standard' way in Fortran and Matlab type synatx. Yes, nicer still for the kind of algorithm you have. > > This enables on-the-fly vectorization by promoting scalar > > operations inline in expressions. =A0For example, if you didn't have a > > version of some function F vectorized in its second argument, you > > could write > > > =A0 =A0(for I in B'Range =3D> =A0F(A, B(I), C)) > > I do think that Fortran still has more support and build-in > functions (called intrinsics) and syntax to working with vectors > and matrices than Ada does, at least it seems it requires less > work to set things up. > > But again, this is what Fortran was originally designed for, so this is > not too surprising. Each language has its strong and not too strong > areas. I believe these vectorization features first appeared in Fortran 90, about 33 years after the very first FORTRAN. I guess that gives Ada until 2016 if it is to follow suit... Phil