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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC 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-7-bit Path: g2news1.google.com!news4.google.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!138.195.8.3.MISMATCH!news.ecp.fr!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: Re: on using array index, vectorized operation Date: Sun, 27 Mar 2011 15:00:22 -0700 Organization: Aioe.org NNTP Server Message-ID: References: <5efa3275-a42b-4d97-ac75-428f8cdf895d@j13g2000pro.googlegroups.com> Reply-To: nma@12000.org NNTP-Posting-Host: tUYQ4Ty9mMw9Pdc8TJRFQA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news1.google.com comp.lang.ada:18515 Date: 2011-03-27T15:00:22-07:00 List-Id: Thanks Pascal and Shark8; Yes, Pascal solution is a big improvment. Here is what I have now: (will use the attributes 'succ and 'pred later, but for now, I just wanted to see the concept first) Also, notice, I need to use integer, not natural, for the indices, since those can become negative in general. ------------- example ---------- procedure foo is type buffer_t is array(integer range<>) of float; u : buffer_t(-1..10) := (others=>0.0); subtype r is integer range u'first+1 .. u'last-1; subtype r_plus_1 is integer range r'first+1 .. r'last+1; begin u(r) := u(r) - u(r_plus_1); end foo; ---------------------- The above is workable solution for me, at least I avoid the loops. Only problem now is that I need to figure the castings I need to do to make the compile happy, Since now I get the error: $ gnatmake foo.adb gcc-4.4 -c foo.adb foo.adb:10:14: there is no applicable operator "-" for type "buffer_t" defined at line 2 gnatmake: "foo.adb" compilation error $ Will look at this now, how best to solve this? I understand that it want me to define a "-" operator for buffer_t. I really do not want to cast things, I need to find the best solution to this. May be I need to define a function "-" for buffer_t ? Ok, back to editing and trying things :) But I am happy now that at least I can avoid explicit loops if needed. --Nasser