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 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-06 19:21:00 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newshub2.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: efficient vector/matrix operations in Ada References: <3B6F40C1.FD215D1D@sneakemail.com> X-Newsreader: Tom's custom newsreader Message-ID: Date: Tue, 07 Aug 2001 02:21:00 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 997150860 24.7.82.199 (Mon, 06 Aug 2001 19:21:00 PDT) NNTP-Posting-Date: Mon, 06 Aug 2001 19:21:00 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:11436 Date: 2001-08-07T02:21:00+00:00 List-Id: >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. ;)