comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: efficient vector/matrix operations in Ada
Date: Tue, 14 Aug 2001 14:05:21 GMT
Date: 2001-08-14T14:05:21+00:00	[thread overview]
Message-ID: <Beae7.873$2u.25774@www.newsranger.com> (raw)
In-Reply-To: bebbba07.0108132056.7bcc7c95@posting.google.com

In article <bebbba07.0108132056.7bcc7c95@posting.google.com>, Russ says...
>
>Ted Dennison<dennison@telepath.com> wrote in message news:<aGXd7.88$2u.23428@www.newsranger.com>...
>> >    A  = B;
>> >    A += C;
>> >    A += D;
>> Perhaps to a reader who is *already* familiar with the idiom above that is 
>> true. I'm not, and it took me a couple of takes to see what you were doing 
>> here (and a bit of thought to figure out why). For someone starting from 
>> ground zero, I think the point is quite arguable.
>
>If you know even a tiny bit of C++, the "+=" notation is very obvious.

For one thing, the issue isn't that *one* of them is tough to decipher. The
issue is that the cumulative effect of all *three* of them is tough to deciper.

For another, you are again assuming someone comfortable with C++. If C++ is
going to remain your touchstone for readability, then there's no point at all in
having this discussion. Ada, or any other language with a different syntax, is
set up to loose from the get-go.

I hope you can see where I'm comming from here. If you want to know, "what's the
most readable way to do this efficiently in Ada", we can work with that. If you
want to know, "how can I make this look exactly like C++, because anything that
doesn't look that way is inferior", there's really nothing constructive anyone
here can do for you.

As for trying to be constructive, I think what I'd want to see in this situation
would be "Sum" routine with the following profile (uncompiled, and forgive me if
my posting s/w kills the formatting):
---------
type Matrices is array (Natural range <>) of Matrix;

procedure Sum
(Target :    out Matrix;
Source : in     Matrices
);
---------

That way the operation is carried out in one statement for clarity, and it can
have as many addends as you need, and can be implemented as efficiently as you
need. A call would loook something like:
----
Sum (Target => A, Source => (B, C, D));
----

That certianly looks clearer to me than your n lines of code (where n=# of
addends), all of which have to be read and mentally pieced together to figure
out what's going on.

If your compiler can't do this efficently (some might make copies of B, C, and D
on the stack), then a good subsitute would be to just have several overloaded
"Sum" routines containting as many addends as you might need.


---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



  parent reply	other threads:[~2001-08-14 14:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-07  1:13 efficient vector/matrix operations in Ada Russ
2001-08-07  2:18 ` Dale Stanbrough
2001-08-07  2:21 ` tmoran
2001-08-07  3:04   ` Russ P.
2001-08-10 16:54     ` B.Gaffney
2001-08-13  7:50       ` Dmitry Kazakov
2001-08-13 19:45       ` Russ
2001-08-13 20:23         ` Larry Hazel
2001-08-13 21:26           ` Ted Dennison
2001-08-14  4:46           ` Russ
2001-08-14  5:28             ` David Starner
2001-08-14  8:17             ` Alexander Boucke
2001-08-14  8:56             ` Lutz Donnerhacke
2001-08-14 10:54             ` Jacob Sparre Andersen
2001-08-13 21:30         ` Ted Dennison
2001-08-14  4:56           ` Russ
2001-08-14  7:32             ` efficient vector/matrix operations in Fortran, was Re: ... " tmoran
2001-08-14 14:05             ` Ted Dennison [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-08-07 11:36 efficient vector/matrix operations " Gautier Write-only-address
2001-08-14 12:37 Gautier Write-only-address
replies disabled

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