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,8c8550b9f2cf7d40 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-08 11:51:32 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: 18k11tm001@sneakemail.com (Russ) Newsgroups: comp.lang.ada Subject: Re: Is ther any sense in *= and matrices? Date: 8 Jun 2003 11:51:31 -0700 Organization: http://groups.google.com/ Message-ID: References: NNTP-Posting-Host: 63.194.87.148 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1055098292 25914 127.0.0.1 (8 Jun 2003 18:51:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 8 Jun 2003 18:51:32 GMT Xref: archiver1.google.com comp.lang.ada:38836 Date: 2003-06-08T18:51:32+00:00 List-Id: "John R. Strohm" wrote in message news:... > "Russ" <18k11tm001@sneakemail.com> wrote in message > news:bebbba07.0306071138.6bf9784f@posting.google.com... > > "*=" is not so useful for multipying non-square matrices. However, it > > is very useful for multiplying a matrix (or a vector) by a scalar. For > > example, > > > > A *= 2.0 > > > > can be used to multiply matrix A by two in place. This is potentially > > more efficient than A := A * 2 for all the same reasons discussed with > > respect to "+=". > > With all due respect, ladies and gentlemen, it has been known for a very > long time that the difference in "efficiency" between A := A + B and A += B > is lost in the noise floor compared to the improvements that can be gotten > by improving the algorithms involved. Oh, really? I just did a test in C++ with 3x3 matrices. I added them together 10,000,000 times using "+", then "+=". The "+=" version took about 19 seconds, and the "+" version took about 55 seconds. That's just shy of a factor of 3, folks. If that's your "noise floor," I can't help wonder what kind of "algorithms" you are dealing with! > And I'd be REALLY interested to know what you are doing with matrix > multiplication such that the product of a matrix and a scalar is the > slightest bit interesting. (Usually, when I'm multiplying matrices, I'm > playing with direction cosine matrices, and I don't recall ever hearing > about any use for multiplying a DCM by a scalar.) Sorry, but I'm having some trouble with your "logic". DCM matrices don't get multiplied by scalars, so you doubt that any vector or matrix ever gets multiplied by a scalar? Actually, it is more common to scale a vector than a matrix, but the same principles regarding the efficiency of "+"and "+=" still apply. Vectors often need to be scaled for conversion of units, for example. Another very common example would be determining a change in position by multiplying a velocity vector by a scalar time increment. Ditto for determining a change in a velocity vector by multiplying an acceleration vector by a time increment. Since you know about DCMs, you must also be familiar with quaternions, otherwise known as Euler parameters. Like DCMs, Euler parameter "vectors" represents the attitude of a rigid body. Well, an Euler parameter vector consists of 4 scalar components or "Euler parameters", and the norm (roor sum square) of the 4 parameters is unity by definition. However, due to numerical roundoff error, the norm can drift away from one. However, you can renormalize by dividing the vector by its own norm. This can be written very concisely and efficiently in C++ as eulpar /= eulpar.norm() Incidentally, this procedure is much simpler than the corresponding procedure for orthogonalizing a DCM. I could come up with other examples, but this should suffice. Actually, I'm a bit dissappointed in myself for wasting as much time as I did in replying to your meritless post. So is my wife.