[Top][All Lists]

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

FW: Scalars and Matrices:

From: John W. Eaton
Subject: FW: Scalars and Matrices:
Date: Tue, 12 Oct 1999 14:09:21 -0500 (CDT)

On 12-Oct-1999, A. Scottedward Hodel <address@hidden> wrote:

| >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.

Although Octave is a matrix language, matrices are not the only
supported data type.  Also, since there are no explicit type
declarations as in languages like C, Fortran, or Pascal, the type of
an expression must be determined from the expression itself.

So, for an expression like

  A * B

in which A is a matrix with one row (or is that a row vector?) and B
is a mstrix with one column (or is that a column vector?), the result
will be a matrix with one row and one column (or is that a scalar?).

Octave makes the choice that it is usually desirable to do automatic
type conversions when possible.  So the result of the above expression
is a scalar.  This choice, coupled with the choice of evaluating
expressions from left to right means that an expression like

  A * B * C

in which A is a row vector, B is a column vector, and C is a matrix
with more than one row, is equivalent to

  (A * B) * C

which is OK because the result of (A * B) may be converted to a scalar.

Would anyone really like to have the option of not performing the type
conversions and having an expression like the above result in an error?

Would anyone really prefer to have dot products result in matrix
objects instead of scalar objects?


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]