[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FW: Scalars and Matrices:

From: A. Scottedward Hodel
Subject: FW: Scalars and Matrices:
Date: Tue, 12 Oct 1999 08:33:02 -0500

>From time to time, JWE explains some odd features of Octave as being caused
by "MATLAB(tm) compatibility."  This morning I received the following thread
as a part of the N. A. Digest newsletter, which indicates that some features
may be bugs...

I'm not suggesting that we change Octave!  I send this on because I've had
students write vector outer products in reverse order and get completely
wrong answers with no warning message.  That is, we must be careful when
using these software tools, and, for those of us who teach, we must inform
our students of the "gotcha's" that are out there.

From: Garry Tee <address@hidden>
      Ken Turkowski <address@hidden>
Date: Tue, 5 Oct 1999 16:56:34 +1300
Subject: Re: Difference Between 1x1 Matrices and Scalars

In last week's NA Digest, Ilse Ipsen wrote:

> There can be a difference between 1x1 matrices and scalars.
> Consider the matrix product A*B*C where
> A = [1 1]     B = [1]     C=[1]
> [1]       [2]
> [3]
> The product A*B*C is not defined because B*C is not defined.
> Nevertheless MATLAB 5.3 computes the answer [2]
> [4]
> [6]
> presumably because it associates (A*B)*C. In this case A*B
> happens to be a scalar but should be treated as a 1x1 matrix.
> Is this something to worry about?


Garry Tee replies:

        Yes, it is something to worry about.
        A 1x1 matrix D is not just its single scalar element d_{11}, but it
has associated operations which are not identical with those for a scalar.
The scalar has the property that it can form a scalar product with any
vector or matrix, but the 1x1 matrix does not have that property. The
matrix product DE exists iff E has 1 row, and the matrix product FD exists
iff F has 1 column.
        When any array is declared in a PASCAL program (& similarly for
other languages), then some relevant information about the structure must
be stored, as well as just the elements of the array. If a parameter in a
PASCAL procedure is specified as being  array[1..1,1..1] of real, then the
compiler will properly reject an actual parameter which is a real scalar; &
it will reject every actual parameter with n subscripts, where n = 1 or
        Many operations in linear algebra become simpler and clearer if
scalar multiplication is replaced by matrix multiplication. For example,
consider the eigenvalue equation
                           Av  =  ve.
If e is regarded not as a scalar, but as a 1x1 matrix, then this eigenvalue
equation generalizes to the case where m eigenvectors are packed together
to form the m columns of matrix v. In that case, e becomes an mxm matrix of
diagonal form, with the m eigenvalues as the diagonal elements.
        The reported behaviour of MATLAB 5.3 must be regarded as a bug, to
be corrected.

     Garry J. Tee,
     Department of Mathematics, University of Auckland, Auckland, New


Ken Turkowski replies:

This is a common occurance. A*B is a dot product, resulting in a scalar.

It could be that A and B are vectors (or covectors) on a surface and C is
a vector (or covector) in three space.

However, the expression *should* be formally expressed as (A*B)*C, since
A*B*C can ambiguously be interpreted as A*(B*C), which is undefined.

A S Hodel Assoc. Prof. Dept Elect Eng, Auburn Univ,AL  36849-5201
On leave at NASA Marshall Space Flight Center (256) 544-1426
Address until 15 Mar 2000:Mail Code TD-55, MSFC, Alabama, 35812

Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see
Instructions for unsubscribing:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]