On Sat, 8 Dec 2012, Sven Schreiber wrote:
On 12/08/2012 06:26 PM, Allin Cottrell wrote:
> On Sat, 8 Dec 2012, Riccardo (Jack) Lucchetti wrote:
>> This said, I think both expressions should be legal: in the expressions
"a'b"
>> and "a' * b" the 'prime' character actually performs a
different role (as
>> Allin already said): in the first case, it's shorthand for "transpose
and
>> then multiply"; in the second case, it means "transpose and see what
happens
>> next".
>>
>> In the interest of common sense, I imagine that everybody agrees that
>> transposition on a 1x1 matrix should be a no-op which takes precedence on
>> anything else, so "a' * b" is exactly equivalent to
"a*b". For similar
>> reasons, "a'b" should be interpreted as "since this is
shorthand for "(a')*b,
>> just do the same".
>
> I think you're right. That's now the situation in CVS.
sorry, I disagree. I can write more about this later, but IIUC now "a'b"
with for example "a" 1x1 and "b" 3x3 would not give an error and
multiply b with the scalar version of a. If that's so, I think this
would hide bugs in the hansl code which will be difficult to spot and
correct.
It's a difficult issue: for sure, there's a trade-off whereby
greater convenience (and efficiency) are associated with a greater
chance of scripting errors going undetected. Where to strike the
balance?
For the record, let me state some of the possibly contentious points
(while noting that these have been around for quite a long time,
other than having been broken for a day or two due to recent
changes, since mostly reverted).
1) In concatenating matrices, we treat specially both "true" null
matrices (0 x 0) and 1 x 1 matrices, thus:
* A null matrix can be concatenated with a matrix of any dimensions.
* A 1 x 1 matrix can also be concatenated with any matrix: the
scalar value is expanded to fill the row or column as required.
Other than that, we insist that the row or column dimension matches,
for column or row concatenation respectively. So you can't now do,
for example,
ones(1,1) | zeros(0,9)
2) In multiplying matrices, including the case of
transpose-multiply, it's always acceptable for one of the operands
to be 1 x 1 and the other to be of arbitrary dimension: we treat
this as multiplication of a matrix by a scalar.
2) Likewise for addition and subtraction, as in
matrix a = {5}
eval I(3) + a
eval I(3) - a
eval a + I(3)
eval a - I(3)
All these operations are valid and produce what you'd expect, given
that they're considered valid.
Allin