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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b375f07e05d12c7a,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-06 18:08:36 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!news-hog.berkeley.edu!ucberkeley!feeder.via.net!cyclone-sf.pbi.net!206.13.28.33!news.pacbell.net.POSTED!not-for-mail Message-ID: <3B6F40C1.FD215D1D@sneakemail.com> From: Russ <18k11tm001@sneakemail.com> X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.3-20mdk i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: efficient vector/matrix operations in Ada Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 06 Aug 2001 18:13:37 -0700 NNTP-Posting-Host: 63.194.87.148 X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 997146515 63.194.87.148 (Mon, 06 Aug 2001 18:08:35 PDT) NNTP-Posting-Date: Mon, 06 Aug 2001 18:08:35 PDT Organization: SBC Internet Services Xref: archiver1.google.com comp.lang.ada:11433 Date: 2001-08-06T18:13:37-07:00 List-Id: 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