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: g2news2.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!news.glorb.com!news2.glorb.com!news2.euro.net!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: Tue, 29 Mar 2011 14:17:08 -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: g2news2.google.com comp.lang.ada:19557 Date: 2011-03-29T14:17:08-07:00 List-Id: On 3/29/2011 1:11 PM, Phil Clayton wrote: > Unfortunately, if you use real arrays for the i+1 in your > example, you'll have real subscripts. That 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? > Phil > > P.S. I still think Ada should allow us to write something like > > u (2 .. 5) := (for i in 2 .. 5 => > 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))); > > (which avoids the temporary variable that the equivalent loop > requires). Thats nice if possible to do. But just being able to write in Ada an index array as a variable and then write i := 2..5; -- using the correct range etc... syntax for Ada and then write u(i) := u(i) + u(i-1) - ...... would be nice. which is the 'standard' way in Fortran and Matlab type synatx. > This enables on-the-fly vectorization by promoting scalar > operations inline in expressions. For example, if you didn't have a > version of some function F vectorized in its second argument, you > could write > > (for I in B'Range => F(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. --Nasser