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 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-13 12:45:44 PST Path: archiver1.google.com!newsfeed.google.com!postnews1.google.com!not-for-mail From: 18k11tm001@sneakemail.com (Russ) Newsgroups: comp.lang.ada Subject: Re: efficient vector/matrix operations in Ada Date: 13 Aug 2001 12:45:43 -0700 Organization: http://groups.google.com/ Message-ID: References: <3B6F40C1.FD215D1D@sneakemail.com> <3B6F5ABC.3C40E189@sneakemail.com> <9f6e2b77.0108100854.66b084b4@posting.google.com> NNTP-Posting-Host: 24.178.46.154 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 997731944 8590 127.0.0.1 (13 Aug 2001 19:45:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 13 Aug 2001 19:45:44 GMT Xref: archiver1.google.com comp.lang.ada:11866 Date: 2001-08-13T19:45:44+00:00 List-Id: B_Gaffney@My-Deja.com (B.Gaffney) wrote in message news:<9f6e2b77.0108100854.66b084b4@posting.google.com>... > "Russ P." <18k11tm001@sneakemail.com> wrote in message news:<3B6F5ABC.3C40E189@sneakemail.com>... > > No, you really need the dynamically instantiated temporary matrix, I > > believe. I've been through this little lesson years ago. Don't forget > > that you also need to be able to handle expressions such as "A = B + C + > > D;". You can play complicated games with static arrays of "work" > > matrices, but you are asking for trouble and the resulting code is > > likely to not be re-entrant. > > Um, OK, but how would you handle this case using your "+=" > implementation? That was your original point wasn't it? > > --Bg Here's how you write "A = B + C + D;" efficiently: A = B; A += C; A += D; This requires no temporary matrices or passing by value. The original form (A=B+C+D) is fine for rapid prototyping, but the efficient form is preferable for production code. As far as I am concerned, Ada really needs arithmetic assignment operators. Sure, you can use procedures, but they're intent and effect is not as obvious to the reader. Russ