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,4692663255b51613 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!j13g2000pro.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: on using array index, vectorized operation Date: Sun, 27 Mar 2011 14:30:46 -0700 (PDT) Organization: http://groups.google.com Message-ID: <5efa3275-a42b-4d97-ac75-428f8cdf895d@j13g2000pro.googlegroups.com> References: NNTP-Posting-Host: 67.0.68.134 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1301261446 23932 127.0.0.1 (27 Mar 2011 21:30:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 27 Mar 2011 21:30:46 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j13g2000pro.googlegroups.com; posting-host=67.0.68.134; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16 ( .NET CLR 3.5.30729; .NET4.0E),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:18514 Date: 2011-03-27T14:30:46-07:00 List-Id: On Mar 27, 2:44=A0pm, "Nasser M. Abbasi" wrote: > > Thanks, Yes, I could I suppose, but it is not really practical. > > Is there a way to make > > =A0 =A0 =A0 =A0 =A0 A'First .. A'Last > > into one variable, say 'i', so I can just write =A0i+1 or i-1 etc..? No; see Pascal's answer. I would actually suggest making it even more generic; something along the lines of: Subtype Subrange is XXX Range XXX'Succ(XXX'First)..XXX'Last; or Range XXX'First..XXX'Pred'(XXX'Last); as needed, where XXX is your index-type. >Using your solution, I would have to write > >u(u'first+1..u'last-1) :=3Du(u'first+1..u'last-1) - > (a/2.0)* (u(u'first+2..u'last) - u(u'first..u'last-2))+ > (a**2)/2.0* ( u(u'first..u'last-2)-2.0*u(u'first+1..u'last-1) + > u(u'first+2..u'last)); The above could probably* then be rewritten as: Declare SubType SubRange_1 is Natural Range U'Succ(U'First)..U'Pred(U'Last); SubType SubRange_2 is Natural Range U'Succ(SubRange_1'First)..U'Last; SubType SubRange_3 is Natural Range U'First..U'Pred(SubRange_1'Last); Begin u(SubRange_1):=3D u(SubRange_1) - (a/2.0) * ( u(SubRange_2) - u(SubRange_3) ) + (a**2)/2.0 * ( u(SubRange_3) - 2.0*u(SubRange_1) + u(SubRange_2) ); End; * I didn't run this through my compiler. I'm sorry about the poor naming of the subtypes, the technical [math] term escapes me at the moment, but I think it does illustrate what is going on.