[PYTHON MATRIX-SIG] casting and default types
Hinsen Konrad
hinsenk@ere.umontreal.ca
Wed, 8 Nov 1995 10:47:35 -0500
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.
In my opinion, the experience of the APL/J community shows that using
rank extension everywhere is the better solution. Although in
principle that can hide errors, such errors don't seem to occur in
practice. It happens that by some mistake you create an array with
the wrong length (typically off by 1), but you never create an array
of the wrong rank. Besides, you could always locate such a mistake
after a rank-3 inversion, as the result is still rank-3 and could
not be confused with the inverse of a rank-2 matrix.
On the other hand, there are applications where rank extension on
inverses etc. is useful. Of course you could always get the same
effect with explicit loops, but the speed difference is enormous
(e.g. for inverting 1000 4x4 matrices).
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.
That includes all binary operations, which are the most complicated.
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
There should be some provision in the matrix module for applying
a unary function with a given rank to an array of higher rank,
which could also be applied to user-written Python functions.
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
FFT is a good example for an operation where the rank system is useful.
There are of course many applications for rank-1 FFT with extension to
higher ranks, i.e. what you implemented. But it also makes sense
to have multidimensional FFTs. In the J system, FFT would be unbounded
and therefore n-dimensional for a rank-n array. You could then
specify a lower rank to get lower-dimensional FFTs.
standard for matrix functions. Under the current setup there would be no
way to enforce such a standard.
I think it should be standard (i.e. provided for all built-in functions).
It shouldn't be enforced for user-defined function, but it should be
made easy.
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsenk@ere.umontreal.ca
Departement de chimie | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal | Fax: +1-514-343-7586
C.P. 6128, succ. Centre-Ville | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7 | Francais (phase experimentale)
-------------------------------------------------------------------------------
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================