[PYTHON MATRIX-SIG] New Tutorial / Some Questions

Konrad HINSEN hinsenk@ere.umontreal.ca
Mon, 5 Feb 1996 16:23:57 -0500


      1. I can't seem to find the counterpart to the toFile() method.

   There used to be such a function in Numeric.py.  The reason it's not
   there any more is to strongly encourage people to use pickling of
   matrices and better yet of objects containing matrices instead of the
   raw toFile and fromFile methods.  This is the method I use to store

That makes sense, but then toFile() should also disappear.

   Take is the equivalent of "full product form indexing" that for a
   number of reasons is not available in normal indexing.  The most
   common use I have for take is to implement decoding from mu-law to
   16-bit linear sound files.  mu-law files map the bytes from 0-255 to a
   given 16-bit number using a non-linear scale as a form of compression.

   Assuming you have an array mu_law_array (of length 256) where
    mu_law_array[value_mu_law] = value_linear

   linear_encoded_array = mu_law_array.take(mu_law_encoded_array)

Translation tables are one of the important applications of this
operation. Another is sorting, ...ehhh... *would* be sorting if it
were implemented in a more flexible way. Right now we have the
built-in function sort() which works also on arrays. What is missing
(and should be added) is a function that returns the indices of the
elements in sorted order. As an example, suppose you have an array of
measurements of some function f(x) as a rank-2 array a; a[0] being the
evaluation points and a[1] the values. You want to sort the array by
evaluation points. The answer is
   a.take(a[0].sortIndex(), 1)

BTW, it would be extremely helpful to have a list of all existing
functions/methods with a short definition. It is difficult to comment
on whether the current set is sufficient and/or appropriately defined
and names without knowing what is out there! Do you happen to have
something suitable?

      3. Shouldn't typecodes look more like real types than strings, sort of
	 like exceptions?  

	      >>> b.typecode()
	      'l'
	 vs.
	      >>> b.typecode()
	      LongInteger  or whatever.

   The only hassle is that doing this would lead to yet another new
   object type added to python (after already adding array's, ufunc's,
   and slices (hopefully soon).  I'm willing to be convinced that this is
   the right choice, but for now I opted for the minimal approach.

There is no need for a new object type, since the typecode could be of
type "type". All that has to be added is type objects for the new
types.

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