[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scalars and Matrices:
From: |
Ted Harding |
Subject: |
Re: Scalars and Matrices: |
Date: |
Fri, 15 Oct 1999 13:20:39 +0100 (BST) |
On 15-Oct-99 Johan Kullstam wrote:
> (Ted Harding) <address@hidden> writes:
>>
>> Sorry, I don't think I can sympathise with this. As a general
>> convention for associativity,
>>
>> A*B*C = (A*B)*C
>
> no. associativity says, by definition, that
>
> (A*B)*C = A*(B*C) (A)
>
> and one draws the conclusion that since (A) holds, we can write
>
> A*B*C
>
> with no risk of confusion. *order doesn't matter* if star (*)
> is associative.
>
> what you are promoting is implicit grouping. this is *not*
> associativity. it is, in fact, nearly the *opposite* of
> associativity, since order clearly *does* matter. you even go out of
> your way to define a default order convention.
>
> one could also take the point of view that the octave interpreter
> should *require* parenthesis in cases of ambiguity.
Confusion of terminology here. I was using "associativity" in the
sense usual in programming languages, e.g. as in C there is
implicit "left associativity" (using the terminology of the manuals)
for (most) operators of the same precedence so that x*y/z = (x*y)/z,
and x*y*z is evaluated in the order (x*y)*z, for instance.
(You are of course right about the meaning of "associative"
in the mathematical (algebraic) sense.)
How this works depends on the expression parser. I think octave's is
close to the general C convention, allowing for complications due to
the fact that the operands in an expression may be scalars, vectors
and matrices. This means that A*B*C*... will be parsed to evaluate
as (...((A*B)*C)*...), with the possibility that this may create
non-conformal terms for a product, in which case it will fail.
The usual proof that "(A*B)*C = A*(B*C) provided either side is defined"
in matrix algebra presumes that (A*B) evaluates to a matrix with as many
columns as C has rows in the case that the LHS is given as defined, or
that (B*C) has as many rows as A has columns in the case that the RHS
is given as defined. It does not cover the case where (e.g.) in the
LHS (A*B) evaluates to a scalar (i.e. is of the form (x'*y) for
equal-length column vectors x,y); nor, similarly, where in the RHS
(B*C) is a scalar. In either of these cases, however, the other side may
be undefined. So the (algebraic) associativity (A*B)*C = A*(B*C) = A*B*C
for matrices is not necessarily true unless you restrict "is defined" to
exclude cases where A*B (or A*C) evaluates to a scalar.
Quite where that leaves the discussion about the distinction between
a scalar and a 1x1 matrix is not clear to me. I think the main issue
is: what would you want to mean by a 1x1 matrix, if this is not the
same as the meaning of a scalar?
In any case, I'd like to re-iterate the wise motto:
When in doubt use brackets
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Date: 15-Oct-99 Time: 13:20:39
------------------------------ XFMail ------------------------------
---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL. To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------
- Re: FW: Scalars and Matrices:, (continued)