[PYTHON MATRIX-SIG] default axes

Konrad Hinsen hinsen@physik.rwth-aachen.de
Thu, 15 Aug 1996 10:37:44 +0200


   For ufunc.add.reduce(), sort() & Co., and fft(), -1 seems the most
   natural choice for me.

I agree about sort and fft, but not about reduce etc.
(Besides, another argument is compatibility with the Python built-in
reduce(), which when applied to a nested list reduces along the
outermost nesting level, i.e. the first axis.

   > take, choose, repeat, compress

   About take(), I don't really know. Maybe 0. choose()... does it have a
   default axis? repeat() is like concatenate(), the default axis should
   be 0. compress()... no idea.

I'd say 0 for all of them.

   trace() and diagonal()... should they operate on the diagonal between
   -1 and -2, especially if reduce and the others will use the default

Definitely.

   matrices. Likewise, dot() should reduce -1.

Actually, dot() is the only function about which I am not sure.
There are several options that make sense:
1) Axis -1 for both arguments. Good for vectors and lists of vectors.
2) Axis -1 for the first and -2 for the second. Good for matrices
   and lists of matrices.
3) Axis -1 for the first and 0 for the second. Good for higher-rank
   tensors.
My personal favourite is 3), but I can't give any relly good argument.
But evidently dot() needs two optional axis arguments to cover all cases.

Konrad.

-- 
-------------------------------------------------------------------------------
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. A                | 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
=================