comp.lang.ada
 help / color / mirror / Atom feed
* efficient vector/matrix operations in Ada
@ 2001-08-07  1:13 Russ
  2001-08-07  2:18 ` Dale Stanbrough
  2001-08-07  2:21 ` tmoran
  0 siblings, 2 replies; 20+ messages in thread
From: Russ @ 2001-08-07  1:13 UTC (permalink / raw)


Several years ago I developed a C++ class for vector/matrix operations.
I decided to do the same in Ada as an excercize. A key lesson I learned
about C++ is that vector/matrix operations can be done much more
efficiently using the arithmetic "assignment" operators such as "+="
instead of "+". I am interested in how this is handled in Ada.

Suppose A and B are matrices. The expression

    A = A + B; // inefficient

is much less efficient than

    A += B; // efficient

The former requires the dynamic construction of a temporary matrix to
hold the sum (A + B), which must then be passed by value and copied into
A. This can take three or four times as long as the addition "in place"
using "+=". That is simply unacceptable for numerically intensive
applications such as Monte Carlo simulations.

Since Ada has no arithmetic assignment operators, are vector/matrix
operations in Ada simply inefficient, or do Ada programmers resort to
tacky, ambiguous expressions like

    PlusEquals(A,B);

-- 
Russ P.
http://RussP.org



^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: efficient vector/matrix operations in Ada
@ 2001-08-07 11:36 Gautier Write-only-address
  0 siblings, 0 replies; 20+ messages in thread
From: Gautier Write-only-address @ 2001-08-07 11:36 UTC (permalink / raw)
  To: comp.lang.ada

>I'm not looking for high-level optimization, I'm just looking for
>something that is reasonably efficient.

With the "Add(x,y)" approach you can get a high-level
efficiency - provided you compile it with Suppress_all,
"O2"-style options as well as an loop-unrolling option.

________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: Do not answer to sender address, visit the Web site!
    Ne r�pondez pas � l'exp�diteur, visitez le site ouaibe!


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp




^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: efficient vector/matrix operations in Ada
@ 2001-08-14 12:37 Gautier Write-only-address
  0 siblings, 0 replies; 20+ messages in thread
From: Gautier Write-only-address @ 2001-08-14 12:37 UTC (permalink / raw)
  To: comp.lang.ada

>What's the difference between:
>
>    A += B;
>
>and
>
>    Add (Target => A,
>         Addend => B);
>
>(except for a few extra characters)?

well... "Add (Target =>,Addend =>)"'length / "+="'length
is not very small, and the 2nd formula seems to me less
readable. I find this idea of Russ a seriously good improvement:
besides ":=", one would have "+=" and "-=", with a programmable

  procedure "+=" (target: in out the_type; addend: in the_type);

________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: Do not answer to sender address, visit the Web site!
    Ne r�pondez pas � l'exp�diteur, visitez le site ouaibe!


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2001-08-14 14:05 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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             ` efficient vector/matrix operations " Ted Dennison
  -- strict thread matches above, loose matches on Subject: below --
2001-08-07 11:36 Gautier Write-only-address
2001-08-14 12:37 Gautier Write-only-address

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