help-octave
[Top][All Lists]

## Re: Scalars and Matrices:

 From: Francesco Potorti` Subject: Re: Scalars and Matrices: Date: Fri, 15 Oct 1999 13:56:35 +0200 (CEST)

```(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)

What  Ted means (I  suppose) is  that, in  a programming  language, when
dealing  with non-associative  binary  operators (like  the product  for
matrices), there is a commonly used default assumption, unless otherwise
stated in the language definition.

This assumption  is that the language's  operator is "left-associative",
that is, grouping is done from left to right.

This  is quite common  and, in  my opinion,  intuitive.  I  think Octave
should not change anything in the way it deals with these ambiguities.

When operators of equal precedence are used together, the leftmost
operator groups first, except for the assignment and exponentiation
operators, which group in the opposite order.  Thus, the expression `a
- b + c' groups as `(a - b) + c', but the expression `a = b = c' groups
as `a = (b = c)'.

Possibly, if someone  thinks so, some text could be  added to the Octave
manual which clarifies this issue  further.  If John Eaton does not feel
like  adding that text  himself, I  am sure  he will  be glad  to accept
reasonable contributions.

--
Francesco PotortÃ¬ (researcher)         Voice:    +39-050-593 203 (op. 211)
Computer Networks Group                Fax:      +39-050-904052
CNUCE-CNR, Via Santa Maria 36          Email:    address@hidden
56126 Pisa - Italy                     Web:      http://fly.cnuce.cnr.it/

---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure