[Gretl-devel] matrix transposition/multiplication operator precedence
svetosch at gmx.net
Fri Jul 1 19:51:34 EDT 2016
Am 01.07.2016 um 20:37 schrieb Allin Cottrell:
> On Fri, 1 Jul 2016, Sven Schreiber wrote:
>> matrix a = zeros(3,1)
>> matrix b = ones(2,3)
>> matrix hu = a' * b'
>> hu = a'(b')
>> hu = a'b' # fails
>> Apparently gretl interprets the last line as "(a'b)'" which kind of
>> implies that the implicit multiplication with the transpose sign has
>> higher precedence than the actual transposition of b.
> "Kind of". But couldn't this be interpreted as a case of simple
> left-to-right evaluation in the absence of another deciding criterion?
Well, I admit that according to table 3.1 in the command reference the
unary transpose and the binary transpose-multiply have the same
priority, and so it would boil down to left-to-right.
But I'm not sure that's right. Semantically it's clear that
transpose-multiply just exists to mimick mathematical handwriting (on
the blackboard or on paper). So wherever it's meaningful, "'" must be
replaced by "'*". And then in the expression "a'*b'" the right
precedence kicks in.
Or to put it differently: Nobody would ever write "(a'b)'" on the
blackboard as "a'b'", because I think it's a broad consensus that the
two expressions are different.
More information about the Gretl-devel