comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: efficient vector/matrix operations in Ada
Date: Tue, 07 Aug 2001 02:21:00 GMT
Date: 2001-08-07T02:21:00+00:00	[thread overview]
Message-ID: <ggIb7.36969$Kd7.22848996@news1.rdc1.sfba.home.com> (raw)
In-Reply-To: 3B6F40C1.FD215D1D@sneakemail.com

>tacky, ambiguous expressions like
>   PlusEquals(A,B);
but is
    Inc(A, B);
so bad or non-obvious?  Fortran programmers, no slouch at fast matrix
operations, seem to have figured out a satisfactory approach.  If you
are really pressed for speed, you are going to be calling an optimized
library anyway.

>    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.
  Is A = A+B, an O(n**2) operation, going to be limiting the speed of
your matrix arithmetic, which probably involves some O(n**3) operations
if it does anything substantial?
  Just because one way of doing it is slow doesn't mean there isn't a
fast way.  For instance why does a temporary need to be dynamic?
Register oriented CPUs don't dynamically create a new register
every time they need one.  One could easily imagine a machine with
vector instructions that can do A+B->C very fast, but has no special
instruction for A+B->A.  In the case of a temporary matrix, of
course, "dynamic construction" could mean something as simple as
"move the stack pointer".  Or your aithmetic operations could create
expressions, moving just pointers and op-codes, and the assignment
operator could analyze the expression and decide the fastest way
to actually calculate the result.  Think outside of the box. ;)



  parent reply	other threads:[~2001-08-07  2:21 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 [this message]
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
replies disabled

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