comp.lang.ada
 help / color / mirror / Atom feed
From: "Nasser M. Abbasi" <nma@12000.org>
Subject: Re: on using array index, vectorized operation
Date: Tue, 29 Mar 2011 14:17:08 -0700
Date: 2011-03-29T14:17:08-07:00	[thread overview]
Message-ID: <imti8i$lru$1@speranza.aioe.org> (raw)
In-Reply-To: a58d91ce-29f7-4306-b686-2a2562f0c40b@k30g2000yqb.googlegroups.com

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



  reply	other threads:[~2011-03-29 21:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-27  1:31 on using array index, vectorized operation Nasser M. Abbasi
2011-03-27 18:48 ` Nasser M. Abbasi
2011-03-27 20:01 ` Cyrille
2011-03-27 20:44   ` Nasser M. Abbasi
2011-03-27 21:02     ` Pascal Obry
2011-03-27 21:30     ` Shark8
2011-03-27 22:00       ` Nasser M. Abbasi
2011-03-27 22:37         ` Phil Clayton
2011-03-27 22:43           ` Nasser M. Abbasi
2011-03-27 22:59             ` Phil Clayton
2011-03-27 22:09     ` Phil Clayton
2011-03-27 22:12       ` Nasser M. Abbasi
2011-03-27 22:23       ` Nasser M. Abbasi
2011-03-29  2:50         ` Randy Brukardt
2011-03-29  4:55           ` Nasser M. Abbasi
2011-03-29 20:11             ` Phil Clayton
2011-03-29 21:17               ` Nasser M. Abbasi [this message]
2011-03-29 22:49                 ` Phil Clayton
2011-03-29 23:47                   ` Nasser M. Abbasi
2011-03-30 13:00                     ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox