[PYTHON MATRIX-SIG] casting and default types
James Hugunin
jjh@mama-bear.lcs.mit.edu
Wed, 8 Nov 95 10:06:28 -0500
> What exactly do you mean by "coercion of ranks"?
I'm responsible for this poor phrase. My initial matrix proposal had the
phrase "dimension coercion" for the J-style rank concept (of which I was
unaware at the time).
The issue in a nutshell is that everybody (I think) agrees that:
a = Matrix((1,2,3),(11,12,13))
b = Matrix(100,200,300)
a+1 = Matrix((2,3,4),(12,13,14))
One question is should a+b be an error, or should it be
a+b = Matrix((101,202,203),(111,212,313))
I believe that the second is correct, and this can be elegantly expressed
by the concept of ranks. I don't think there's much disagreement on this
either.
Now the question comes, what if I ask for inverse( Matrix(((1,2),(11,12)),
((3,4),(13,14))) ).
Using the rank notions in J, the argument should be considered a 1-frame of
2-cells. The result should be a 1-frame containing the inverse of each of
these 2-cells.
However, for a case like this one, the arguments in favor of treating this
as an error (you can't take the inverse of a 3d matrix) seem worth
considering.
My current solution to this is that my optimized ofuncs use the J-style
rank system, but only work on operations with unbounded rank like +, *, etc.
This is as much an implementation issue as anything else.
Other functions on matrices, like inverse (or my favorite, fft) are
completely free to implement a rank system, or not as they see fit. So for
the fft function, when given a matrix, it will return the fft of every
1-cell. The question is whether or not we should adopt such a system as a
standard for matrix functions. Under the current setup there would be no
way to enforce such a standard.
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================