[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Operator precedence tests show 3 failures
From: |
Ben Abbott |
Subject: |
Re: Operator precedence tests show 3 failures |
Date: |
Sun, 20 Mar 2011 19:41:51 -0400 |
On Mar 20, 2011, at 1:35 PM, John W. Eaton wrote:
> On 20-Mar-2011, Rik wrote:
>
> | On 03/20/2011 01:42 AM, marco atzeri wrote:
> | > On Fri, Mar 18, 2011 at 5:40 PM, Rik wrote:
> | >> 3/18/11
> | >>
> | >> I just checked in some tests for the Octave parser (test_parser.m in
> | >> tests/). The current parser shows 3 failures. These are known, but
> until
> | >> jwe gets a chance to modify his proposed patch be aware that your 'make
> | >> check' will not run cleanly.
> | >>
> | >> --Rik
> | >>
> | >
> | > at least 1 seems obvious
> | > -------------------------------------------
> | > assert ([2, 3] .^ 2',[4; 9]) expected
> | > 4
> | > 9
> | > but got
> | > 4 9
> | > Dimensions don't match
> | > -------------------------------------------
> | >
> | > the test should be:
> | >
> | > assert ([2; 3] .^ 2',[4; 9]) expected
> | >
> | > to match dimensions of argument and result
> | > Marco
> | >
> | Actually, the point is that exponentiation has higher precedence in Octave
> | than the transpose operator. This should be parsed as
> | ([2, 3] .^ 2)'. Instead it is parsed as [2, 3] .^ (2'). Transposing a
> | scalar does nothing nothing so Octave returns a row vector where it should
> | return a column vector. The original bug report is here
> | (https://savannah.gnu.org/bugs/?32533).
> |
> | For Ben's point, we are not trying to match Matlab's equal precedence for
> | transpose and exponentiation.
>
> Are the precedence rules for Matlab documented somewhere?
1) Parentheses ()
2) Transpose (.'), power (.^), complex conjugate transpose ('), matrix power (^)
3) Unary plus (+), unary minus (-), logical negation (~)
4) Multiplication (.*), right division (./), left division(.\), matrix
multiplication (*), matrix right division (/), matrix left division (\)
5) Addition (+), subtraction (-)
6) Colon operator (:)
7) Less than (<), less than or equal to (<=), greater than (>), greater than or
equal to (>=), equal to (==), not equal to (~=)
8) Element-wise AND (&)
9) Element-wise OR (|)
10) Short-circuit AND (&&)
11) Short-circuit OR (||)
The link will probably get garbled, but it is below.
http://www.mathworks.com/help/techdoc/matlab_prog/f0-40063.html;jsessionid=m8spNGQT0ylkH0ftD4FZzP2z1GcGncm76m7QStBzth46DdydJ8Nd!-2028253755#f0-38155
Ben