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=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no 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-14 07:06:13 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <3B6F40C1.FD215D1D@sneakemail.com> <3B6F5ABC.3C40E189@sneakemail.com> <9f6e2b77.0108100854.66b084b4@posting.google.com> Subject: Re: efficient vector/matrix operations in Ada Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Tue, 14 Aug 2001 10:05:21 EDT Organization: http://www.newsranger.com Date: Tue, 14 Aug 2001 14:05:21 GMT Xref: archiver1.google.com comp.lang.ada:11915 Date: 2001-08-14T14:05:21+00:00 List-Id: In article , Russ says... > >Ted Dennison wrote in message news:... >> > A = B; >> > A += C; >> > A += D; >> Perhaps to a reader who is *already* familiar with the idiom above that is >> true. I'm not, and it took me a couple of takes to see what you were doing >> here (and a bit of thought to figure out why). For someone starting from >> ground zero, I think the point is quite arguable. > >If you know even a tiny bit of C++, the "+=" notation is very obvious. For one thing, the issue isn't that *one* of them is tough to decipher. The issue is that the cumulative effect of all *three* of them is tough to deciper. For another, you are again assuming someone comfortable with C++. If C++ is going to remain your touchstone for readability, then there's no point at all in having this discussion. Ada, or any other language with a different syntax, is set up to loose from the get-go. I hope you can see where I'm comming from here. If you want to know, "what's the most readable way to do this efficiently in Ada", we can work with that. If you want to know, "how can I make this look exactly like C++, because anything that doesn't look that way is inferior", there's really nothing constructive anyone here can do for you. As for trying to be constructive, I think what I'd want to see in this situation would be "Sum" routine with the following profile (uncompiled, and forgive me if my posting s/w kills the formatting): --------- type Matrices is array (Natural range <>) of Matrix; procedure Sum (Target : out Matrix; Source : in Matrices ); --------- That way the operation is carried out in one statement for clarity, and it can have as many addends as you need, and can be implemented as efficiently as you need. A call would loook something like: ---- Sum (Target => A, Source => (B, C, D)); ---- That certianly looks clearer to me than your n lines of code (where n=# of addends), all of which have to be read and mentally pieced together to figure out what's going on. If your compiler can't do this efficently (some might make copies of B, C, and D on the stack), then a good subsitute would be to just have several overloaded "Sum" routines containting as many addends as you might need. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com