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!news3.google.com!feeder.news-service.com!94.75.214.39.MISMATCH!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:12:10 -0700 Organization: Aioe.org NNTP Server Message-ID: References: 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:18517 Date: 2011-03-27T15:12:10-07:00 List-Id: On 3/27/2011 3:09 PM, Phil Clayton wrote: > On Mar 27, 9:44 pm, "Nasser M. Abbasi" wrote: >> Let me explain. Here is lax-wendroff scheme for 1-D advection pde, where >> 'u' below is the solution: >> >> u(i):=u(i)-(a/2.0)*(u(i+1)-u(i-1))+(a**2)/2.0*(u(i-1)-2.0*u(i)+u(i+1)); >> >> Where in the above, 'i' is the index range that I set up myself before. >> >> In Ada, I put the above line inside a loop over 'i'. > > I notice that the rhs mentions u(i+1) and u(i-1) so depending on > whether you're decrementing or incrementing i, one of these will be > overwritten on a previous loop iteration. Presumably that isn't > intended (looking at your vectorized code)? > Yes, sorry, ofcourse in the actuall code I have LOOP over i u_new(i) = u(i)- ..... END LOOP But when I posted it to this newsgroup, I was editing things by hand to show. Here is the actual code http://12000.org/my_notes/solve_advection_1D_in_Ada/source/lax_wendroff_pkg.adb > >> Using your solution, I would have to write >> >> u(u'first+1..u'last-1) :=u(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)) ; > > Do we now have vectorized arithmetic operations, e.g. + on array > types? > > Phil --Nasser