From chris.chase@jhuapl.edu Mon Mar 4 06:01:34 1996
From: chris.chase@jhuapl.edu (Chris Chase S1A)
Date: Mon, 4 Mar 1996 11:01:34 +0500
Subject: [PYTHON MATRIX-SIG] RubberIndex
In-Reply-To: <199602262127.QAA24193@cyclone.ERE.UMontreal.CA>
References: <199602261735.MAA06305@python.org>
<199602262127.QAA24193@cyclone.ERE.UMontreal.CA>
Message-ID: <9603041601.AA21958@hurlbut.>
>>>>> "Konrad" == Konrad HINSEN writes:
Chase> both selection and assignment. This specific solution for
Chase> flattened indexing is supported in all the array languages
Chase> that I have had exposure to (e.g. Matlab, IDL, Tela,
Chase> Yorick). To me this is more important than the hierarchical
Chase> indexing scheme so that an array looks like a list (but does
Chase> not act like a list for other purposes).
Konrad> The array languages I am familiar with (APL and J) do not
Konrad> permit this.
I forgot about my brief experience with APL-PLUS.
Chase> As an alternative, a 'flat' (or 'flattened') array attribute
Chase> could be supported.
Konrad> Why? What's wrong with ravel(a)? You can index its result if
Konrad> you want.
The reason for a 'flat' attribute is that ravel(a) does not support
_assignment_ to 'a' in flattened form. An attribute or method is a
more natural interface for changing an objects data members. However,
ravel(a) could provide this functionality if ravel(a) returned a
reference instead of a copy.
The attribute would not fit your functions for everything so that
scalars can be substituted for arrays. But if the flattened array is
to be indexed (for assignment or selection) then scalars could not be
supported anyway.
Chris
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Mon Mar 4 16:37:23 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Mon, 4 Mar 1996 11:37:23 -0500
Subject: [PYTHON MATRIX-SIG] RubberIndex
In-Reply-To: <9603041601.AA21958@hurlbut.> (message from Chris Chase S1A on Mon, 4 Mar 1996 11:01:34 +0500)
Message-ID: <199603041637.LAA25988@cyclone.ERE.UMontreal.CA>
> The reason for a 'flat' attribute is that ravel(a) does not support
> _assignment_ to 'a' in flattened form. An attribute or method is a
> more natural interface for changing an objects data members. However,
> ravel(a) could provide this functionality if ravel(a) returned a
> reference instead of a copy.
I think that right now it does, but in my opinion it shouldn't, at
least not by default. For assignment in flattened form, my proposal
contains:
2.1.3) Combining a group of axes into one axis (see comment 2):
+ a[i1, i2, ......, i3, i4] (see comment 3)
The double ellipsis works similar to the single one, but
contracts all the axes covered into a single axis.
This is more flexible, since it allows partially flattened forms,
and follows the principle "assignment only via indexing", which
I might add to the list of principles...
> The attribute would not fit your functions for everything so that
> scalars can be substituted for arrays. But if the flattened array is
> to be indexed (for assignment or selection) then scalars could not be
> supported anyway.
Which is another reason to do all assignments in the form of indexing,
such that indexing is the only operation not supported on scalars.
-------------------------------------------------------------------------------
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
=================
From hinsenk@ere.umontreal.ca Mon Mar 4 18:49:13 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Mon, 4 Mar 1996 13:49:13 -0500
Subject: [PYTHON MATRIX-SIG] Proposal: upward cast operation
Message-ID: <199603041849.NAA03129@cyclone.ERE.UMontreal.CA>
Problem: How do you write a mathematical function that works for
integers, floats, complex numbers, and number classes implemented in
Python? If you think that's easy, look at this example:
def f(a, b):
return a/(a+b)
If you call this with integer arguments, it won't do what you think,
because the division operation for integers is different. You might of
course simply say "don't call this with integer arguments", but you
might have to call it with numbers coming from, say, a library
function whose types are not so easy to predict. You could also modify
the code to
def f(a, b):
return float(a)/(a+b)
but then it doesn't work for complex arguments, because a gets
replaced by its real part. And for other number types, you don't
even know what float() does. What is needed is a type cast that
acts only "if necessary".
I propose to add two such functions to umath, one to cast to float and
the other to cast to complex. The cast to float should work like
this:
1) If the argument is an integer, cast it to float.
2) If the argument has a suitably named method, call this
method to do the cast.
3) If neither 1) or 2) apply, return the argument unchanged.
The cast to complex would work similarly, with only the
first step different.
Any comments? Is there a problem I have overlooked? Or is there
a simpler solution to the problem?
-------------------------------------------------------------------------------
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
=================
From da@maigret.cog.brown.edu Tue Mar 5 19:44:03 1996
From: da@maigret.cog.brown.edu (David Ascher)
Date: Tue, 5 Mar 1996 14:44:03 -0500 (EST)
Subject: [PYTHON MATRIX-SIG] which fft library should I do?
Message-ID: <199603051944.OAA28722@maigret>
While I have started work on a module to the fft routines in the SGI
complib.sgimath library, I'm thinking that maybe I should do something
which is 1) better tested (there are things like "array of size
2*((n+2)/2)" in the man pages), and 2) more portable (e.g. would work on
my PC).
I've looked around on the web, and there are more FFT packages out there
than there should be. =) Netlib's FFTPACK is fine, but it's only in
Fortran (the fft.c file doesn't seem to be a straight port -- it seems
to change the function names, for example).
I think that the library used should come in C at least, and in Fortran
if possible, mostly due to the portability problem. While "serious" fft
users would probably do it on a fast machine w/ a fortran library, I
think that I want to be able to do FFT on MacPython or PythonWin without
a fortran compiler.
I think the first goal of an fft module for Python would be to be
relatively generic and relatively simple. It should do at least 1, 2
and 3 dims. It should deal with floats, doubles, and float and double
complex.
I don't think that I want to worry about routines which are optimized
for, say, multiple even sequences with only odd wave numbers.
Any suggestions?
--david
PS: How bad of a performance hit does one take w/ f2c-output code as
opposed to handcoded C on code like this?
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Tue Mar 5 21:25:36 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Tue, 5 Mar 1996 16:25:36 -0500
Subject: [PYTHON MATRIX-SIG] which fft library should I do?
In-Reply-To: <199603051944.OAA28722@maigret> (da@maigret.cog.brown.edu)
Message-ID: <199603052125.QAA12725@cyclone.ERE.UMontreal.CA>
> I think that the library used should come in C at least, and in Fortran
> if possible, mostly due to the portability problem. While "serious" fft
> users would probably do it on a fast machine w/ a fortran library, I
> think that I want to be able to do FFT on MacPython or PythonWin without
> a fortran compiler.
I agree. I remember having seen a list of mathematical libraries
in C somewhere, which is where you should start looking for
C libraries. I suppose it was in news.answers, but I am not sure.
> PS: How bad of a performance hit does one take w/ f2c-output code as
> opposed to handcoded C on code like this?
That depends a lot on your C compiler and on your application. Many C
compilers are not very good at standard optimizations for numerical
code. The difficulties caused by the language itself are few: pointer
aliasing (a Fortran compiler may assume that two array arguments
passed to a subroutine do not refer to overlapping memory blocks; a C
compiler may not), the power operator (few C compilers can optimize
e.g. small integer powers) and intrinsic functions (although some C
compilers already come with a good substitute in the form of #pragmas
in math.h and corresponding optimizations).
Another question is whether the code produced by f2c is sufficiently
portable. After all, f2c has to be configured for some features of the
C compiler, and there are C compilers for which this is impossible.
For example, the C compiler must provide two floating-point precisions
of which the larger one uses exactly twice as many bytes as the
smaller one. I remember one compiler (Pure-C for the Atari ST) for
which I could not configure f2c, because "float" takes 4 bytes and
"double" 10.
Another problem is the f2c library. The generic source code is
very Unix-specific. I don't know whether there are any ports
to other operating systems.
All that means that a real C library is best. One can still
have an alternate Fortran library binding for people with
a Fortran compiler and a need for speed. As long as the
high-level interface is the same, few users should see the
difference.
-------------------------------------------------------------------------------
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
=================
From spillar@uwyo.edu Wed Mar 6 04:59:45 1996
From: spillar@uwyo.edu (Earl Spillar)
Date: Tue, 5 Mar 96 21:59:45 -0700
Subject: [PYTHON MATRIX-SIG] Efficient data reading
Message-ID: <9603060459.AA00271@galaxies.plk.af.mil>
Gentlepeople:
I'm going to implement some astronomical image processing stuff
using the Matrix extensions. I think it's a perfect application for
Python- I need to perform arithmatic on 2MB numerical arrays quickly and
efficiently, while dealing with some simple variables associated with
each array. I could post more details if there is interest-
Anyway, the question is how to most efficiently read in data already
written to disk in a standard format (FITS). I know how to parse
the headers, its the 2 MB data arrays I'm worried about. I'm thinking about
reading the data using the array module, and feeding the result of that to the
Numerical module. Is that reasonably efficient? It seems like I'll have 2
copies floating around for a moment. Is there another mechanism
in the Numerical module that I'm missing?
Thanks for any help- this stuff looks great, and answers needs I've had
for some time!
Earl Spillar
spillar@uwyo.edu
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From weinhand@unileoben.ac.at Wed Mar 6 07:54:56 1996
From: weinhand@unileoben.ac.at (Herbert Weinhandl)
Date: Wed, 6 Mar 96 08:54:56 +0100
Subject: [PYTHON MATRIX-SIG] which fft library should I do?
Message-ID: <45891.weinhand@unileoben.ac.at>
[snip]
>All that means that a real C library is best. One can still
>have an alternate Fortran library binding for people with
>a Fortran compiler and a need for speed. As long as the
>high-level interface is the same, few users should see the
>difference.
You should look at th URL
http://www.tu-chemnitz.de/~arndt/joerg.html
there is e.g. fxt.tgz (C source for FFT and Fast Hartley Transform).
You can find a lot of links to other sites related to this matter.
I hope this helps
Herbert Weinhandl
Institute for Solid State Physics, Austrian Academy of Sciences,
Institute for Metal Physics, University for Mining & Metallurgy,
Jahnstr. 12, ! It is
A-8700 Leoben, Austria ! NOT
Tel: (+43) 3842-45511-37 ! my bailiwick !
Fax: (+43) 3842-45512-16 ! from Cliff Stoll's "The Cuckoo's Egg"
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From chris.chase@jhuapl.edu Wed Mar 6 14:12:28 1996
From: chris.chase@jhuapl.edu (Chris Chase S1A)
Date: Wed, 6 Mar 1996 09:12:28 -0500
Subject: [PYTHON MATRIX-SIG] index of C and C++ numerical software
Message-ID: <199603061515.KAA00253@python.org>
Below is the header of a file containing info on numerical C/C++
software on the net. It contains pointers to lots of FFT software
among other things.
Chris
Welcome to of the index of resources for numerical computation
in C or C++. It is a collection of pointers to:
- free source code available on the net,
- articles and documents, especially those available over the net.
This file is
ftp://usc.edu/pub/C-numanal/numcomp-free-c.gz
ftp://ftp.math.psu.edu/pub/FAQ/numcomp-free-c
or c/numcomp-free-c on netlib (slightly outdated).
Also see the last item on http://www.math.psu.edu/OtherMath.html
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From jjh@Goldilocks.LCS.MIT.EDU Wed Mar 6 13:29:41 1996
From: jjh@Goldilocks.LCS.MIT.EDU (James Hugunin)
Date: Wed, 6 Mar 96 08:29:41 EST
Subject: [PYTHON MATRIX-SIG] Efficient data reading
In-Reply-To: <9603060459.AA00271@galaxies.plk.af.mil> (message from Earl Spillar on Tue, 5 Mar 96 21:59:45 -0700)
Message-ID: <9603061329.AA06526@baribal.LCS.MIT.EDU.LCS.MIT.EDU>
From: Earl Spillar
I'm going to implement some astronomical image processing stuff
using the Matrix extensions. I think it's a perfect application for
Python- I need to perform arithmatic on 2MB numerical arrays quickly and
efficiently, while dealing with some simple variables associated with
each array. I could post more details if there is interest-
BTW - has anybody heard anything more about the image module discussed
a while back on this list? It sounds like it might be very helpful
here.
Anyway, the question is how to most efficiently read in data already
written to disk in a standard format (FITS). I know how to parse
the headers, its the 2 MB data arrays I'm worried about. I'm thinking about
reading the data using the array module, and feeding the result of that to the
Numerical module. Is that reasonably efficient? It seems like I'll have 2
copies floating around for a moment. Is there another mechanism
in the Numerical module that I'm missing?
I explicitly designed the numeric module to not access file objects
(well, there are a couple of hidden methods lying around, but those
wil be going away very soon). This makes safe code (things like
grail) much easier to think about. It also should strongly encourage
people to use pickling as their "native" format for storing arrays
which I think is almost always the best choice. Also, for every case
I've had to deal with, reading data into a string, and then converting
the string to an array works just fine. ie.
data = Numeric.fromString(fp.read(n_bytes), type_of_data)
It is true, this does temporarily require twice as much memory as data
"should" require, and it memcpy's all of that data once. However, in
comparision to the time required for reading 2MB of data off even a
fast local disk, the memory copies/allocations are negligible.
Almost anything that you do with arrays (like a = a + 2) will
temporarily require this double memory.
(Note to experts, this can actually be written as add(a, 2, a) in
which case you don't need that extra memory, but if you want to write
a lot of code like this, then you should probably be working in C
anyway).
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Wed Mar 6 14:14:41 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Wed, 6 Mar 1996 09:14:41 -0500
Subject: [PYTHON MATRIX-SIG] Efficient data reading
In-Reply-To: <9603060459.AA00271@galaxies.plk.af.mil> (message from Earl Spillar on Tue, 5 Mar 96 21:59:45 -0700)
Message-ID: <199603061414.JAA24129@cyclone.ERE.UMontreal.CA>
> the headers, its the 2 MB data arrays I'm worried about. I'm thinking about
> reading the data using the array module, and feeding the result of that to the
> Numerical module. Is that reasonably efficient? It seems like I'll have 2
> copies floating around for a moment. Is there another mechanism
> in the Numerical module that I'm missing?
There is no difference between the "array module" and the "numerical module".
The module "Numerical" simply imports objects from the array module. Or are
you referring to the old array module?
I see no problem in writing a C function that allocates the array and
loads the data without any copying. However, you will have to take
care that this array is not copied during later processing. Python
is not exactly designed to avoid copying objects.
-------------------------------------------------------------------------------
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
=================
From fredrik_lundh@ivab.se Wed Mar 6 21:41:43 1996
From: fredrik_lundh@ivab.se (Fredrik Lundh)
Date: Wed, 6 Mar 1996 22:41:43 +0100
Subject: [PYTHON MATRIX-SIG] Efficient data reading
In-Reply-To: <9603061329.AA06526@baribal.LCS.MIT.EDU.LCS.MIT.EDU>
(jjh@Goldilocks.LCS.MIT.EDU)
Message-ID: <9603062141.AA20782@arnold.image.ivab.se>
> BTW - has anybody heard anything more about the image module discussed
> a while back on this list? It sounds like it might be very helpful
> here.
An image-sig have been formed, but not yet activated. I've been a bit
too busy writing articles and holding seminars on Python...
Anyway, feel free to sign up (image-sig-request@python.org), but don't
expect any activity (not this week, at least :-). A formal
announcement will be posted to the news group real soon now.
The Python Imaging Library, release 0.1, is nearly completed, and I
hope to release it within a few weeks. I've even written a handbook
for it...
Regards /F
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From spillar@uwyo.edu Wed Mar 6 23:56:14 1996
From: spillar@uwyo.edu (Earl J Spillar)
Date: Wed, 06 Mar 1996 16:56:14 -0700 (MST)
Subject: [PYTHON MATRIX-SIG] Efficient data reading
Message-ID:
Gentlemen- thanks for your answers.
James Hugunin said:
BTW - has anybody heard anything more about the image module discussed
a while back on this list? It sounds like it might be very helpful
here.
Probably will be helpful. A lot of what astronomers call "image processi=
ng"
is actually numerical analysis though, so the other Matrix stuff is very
important.
I explicitly designed the numeric module to not access file objects...
strongly encourage people to use pickling as their "native" format for =
storing arrays which I think is almost always the best choice..."
I agree completely with this philosophy. I will certainly keep my data =
in
pickled format. I do have a need to get the data in and out to use "lega=
cy" apps
though, hence the question.
(Note to experts, this can actually be written as add(a, 2, a) in
which case you don't need that extra memory, but if you want to
write a lot of code like this, then you should probably be working
in C anyway).
Thanks for the trick. I WILL be doing a lot of code like this, but it =
needs to
be "reconfigured" frequently. I want to prototype in the fluid Python =
environment
and then freeze bottlenecks into C.
Konrad said:
There is no difference between the "array module" and the
"numerical module". The module "Numerical" simply imports
objects from the array module. Or are you referring to the old array mod=
ule?
Actually, was thinking about the old array module. I guess when I saw =
the
Numeric.fromString method, I thought C string, and CR/LF etc, NULLs, and =
thought
it wouldn't work... primitive thinking on my part.
Thanks for the help!
Earl Spillar
spillar@uwyo.edu
http://plains.uwyo.edu/~spillar/
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From fredrik_lundh@ivab.se Thu Mar 7 06:54:56 1996
From: fredrik_lundh@ivab.se (Fredrik Lundh)
Date: Thu, 7 Mar 1996 07:54:56 +0100
Subject: [PYTHON MATRIX-SIG] Efficient data reading
In-Reply-To:
(message from Earl J Spillar on Wed, 06 Mar 1996 16:56:14 -0700 (MST))
Message-ID: <9603070654.AA22905@arnold.image.ivab.se>
> Probably will be helpful. A lot of what astronomers call "image
> processing" is actually numerical analysis though, so the other
> Matrix stuff is very important.
Indeed. One important future task is to provide tight interfaces
between PIL and the matrix extensions. I'd rather not duplicate stuff
like frequency domain filters, for example.
On the other hand, a FITS reader should probably be part of PIL
rather than some other module. I've already hacked a simple version,
but haven't tested it much. Maybe your module could be plugged in
instead?
/F
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From spillar@uwyo.edu Thu Mar 7 16:22:21 1996
From: spillar@uwyo.edu (Earl J Spillar)
Date: Thu, 07 Mar 1996 09:22:21 -0700 (MST)
Subject: [PYTHON MATRIX-SIG] FITS images place in Module Space
Message-ID:
Fredrik Lundh said-
On the other hand, a FITS reader should probably
be part of PIL rather than some other module. I've
already hacked a simple version, but haven't tested it
much. Maybe your module could be plugged in
instead?
This makes sense. I wasn't aware of PIL until these posts.
I'm not sure my module is all that useful yet- it mostly
deals with the header parts so far, and calls some legacy
free standing executables for data operations.
The Python Imaging Library, release 0.1, is nearly
completed, and I hope to release it within a few
weeks. I've even written a handbook for it...
I'ld be very interested in seeing how the handbook!
Earl Spillar
spillar@uwyo.edu
http://plains.uwyo.edu/~spillar/
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From dubois1@llnl.gov Thu Mar 7 21:39:28 1996
From: dubois1@llnl.gov (Paul. Dubois)
Date: Thu, 07 Mar 1996 13:39:28 -0800
Subject: [PYTHON MATRIX-SIG] Functions and names
References: <199602202012.PAA17939@cyclone.ERE.UMontreal.CA>
Message-ID: <313F5790.68C0@llnl.gov>
I finally got time to take a look at Konrad's memo about functions
and names for the matrix class. I have no objection to it.
Except, I still want to be able to distinguish those actions which
modify self and those which return a new array, so that
x.reshape(s) modifies x, (or else the only way to do it is assignment
to x.shape)
x.shaped(s) returns some new value.
Likewise with transpose. In short, if the name is or is most likely to
be interpreted as an imperative verb, it means that self is modified,
and no value is returned.
--
Paul F. Dubois, L-472 (510)-422-5426
Lawrence Livermore National Laboratory FAX (510)-423-9969
Livermore, CA 94550 dubois1@llnl.gov
Consulting: PaulDubois@aol.com
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Fri Mar 8 00:08:08 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Thu, 7 Mar 1996 19:08:08 -0500
Subject: [PYTHON MATRIX-SIG] Functions and names
In-Reply-To: <313F5790.68C0@llnl.gov> (dubois1@llnl.gov)
Message-ID: <199603080008.TAA21569@cyclone.ERE.UMontreal.CA>
>
> I finally got time to take a look at Konrad's memo about functions
> and names for the matrix class. I have no objection to it.
> Except, I still want to be able to distinguish those actions which
> modify self and those which return a new array, so that
In my proposal there are no operations that modify an array. I am not
sure they are needed at all. You can change elements by assignment
with indexing, and you can assign to shape. In-place transposition is
not essential, because transposition returns a reference anyway (which
I discovered only today; I'll update my proposal to make this behaviour
optional, as for reshape()). I'd like to establish the principle that
with exception of indexing, no operation returns a reference by default.
Making a copy leads to fewer surprises and is therefore the better
default option.
In-place operations are more important for add-on packages like
linear algebra, and I agree that the naming scheme should make
the distinction clear. For example, one could have invert(m)
and inverse(m). But for other operations the choice is less
clear, e.g. for singular value decomposition.
-------------------------------------------------------------------------------
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
=================
From da@maigret.cog.brown.edu Sat Mar 9 21:05:19 1996
From: da@maigret.cog.brown.edu (David Ascher)
Date: Sat, 9 Mar 1996 16:05:19 -0500 (EST)
Subject: [PYTHON MATRIX-SIG] missing (?) feature
Message-ID: <199603092105.QAA09084@maigret>
I came accross a feature I'd like to see in the "choose"
command/function (or whatever else it gets called =):
Basically, my problem is that I want to do something like:
ranf = Ranf.ranf
age = age + 1
x = age.greater(MAX_AGE).choose(x, ranf)
y = age.greater(MAX_AGE).choose(y, ranf)
age = age.greater(MAX_AGE).choose(age, 0)
so that the x and y values of 'old' coordinates get replaced w/ new
coordinates. The new coordinates are typically based on random numbers.
With the current implementation I have to do:
x = age.greater(MAX_AGE).choose(x, random_sample(NUM_DOTS))
which is wasteful since on a given iteration, only a few of the dots are
likely to be "too old". But a new random_sample() array is generated
each time anyway.
--david
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Mon Mar 11 14:08:55 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Mon, 11 Mar 1996 09:08:55 -0500
Subject: [PYTHON MATRIX-SIG] missing (?) feature
In-Reply-To: <199603092105.QAA09084@maigret> (da@maigret.cog.brown.edu)
Message-ID: <199603111408.JAA11002@cyclone.ERE.UMontreal.CA>
> Basically, my problem is that I want to do something like:
>
> ranf = Ranf.ranf
> age = age + 1
> x = age.greater(MAX_AGE).choose(x, ranf)
> y = age.greater(MAX_AGE).choose(y, ranf)
> age = age.greater(MAX_AGE).choose(age, 0)
If you are really worried about efficiency, you should certainly
not recalculate age.greater(MAX_AGE) three times ;-)
> With the current implementation I have to do:
>
> x = age.greater(MAX_AGE).choose(x, random_sample(NUM_DOTS))
>
> which is wasteful since on a given iteration, only a few of the dots are
> likely to be "too old". But a new random_sample() array is generated
> each time anyway.
Which "waste" are you worried about? The waste in CPU time caused by
the random generator? Unless your array is really big, this is
probably not worth mentioning.
On the other hand, a rather concise solution could be obtained if
the idea of allowing general list indices is taken up again.
Then you could write:
update = repeat(greater(age, MAX_AGE), arrayRange(len(age)))
x[update] = random_sample(len(update))
y[update] = random_sample(len(update))
-------------------------------------------------------------------------------
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
=================
From g.k@trulli.imc.akh-wien.ac.at Tue Mar 12 11:25:04 1996
From: g.k@trulli.imc.akh-wien.ac.at (Guenter Kolousek)
Date: Tue, 12 Mar 1996 11:25:04 GMT
Subject: [PYTHON MATRIX-SIG] Extending NumericalPython by fuzzy numbers?
Message-ID: <9603121125.AA12133@trulli.imc.akh-wien.ac.at>
Hi everybody!
I recently looked at the new NumericalPython. It looks great. For my
purposes I need fuzzy numbers. Is it easy to extend the library by
new functions and especially by new data types, like fuzzy numbers?
There is just a little problem: No experience in extending Python
with C functions! Is there a way for me to implement it with a
reasonable effort and contribute it to the matrix lib? Is it
possible to implement the extensions in C++?
I appreciate any helpful answers.
Guenter Kolousek
--
----------------------------------------------------
DI Guenter Kolousek
Department for Medical Computer Sciences
Medical School, University of Vienna
mail: Spitalgasse 23, 1090 Vienna, Austria
email: g.k@trulli.imc.akh-wien.ac.at
phone: +43-1-40400/6664 fax: +43-1-40400/6667
----------------------------------------------------
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From jjh@Goldilocks.LCS.MIT.EDU Tue Mar 12 16:38:41 1996
From: jjh@Goldilocks.LCS.MIT.EDU (James Hugunin)
Date: Tue, 12 Mar 96 11:38:41 EST
Subject: [PYTHON MATRIX-SIG] Extending NumericalPython by fuzzy numbers?
In-Reply-To: <9603121125.AA12133@trulli.imc.akh-wien.ac.at> (g.k@trulli.imc.akh-wien.ac.at)
Message-ID: <9603121638.AA16842@baribal.LCS.MIT.EDU.LCS.MIT.EDU>
At the moment, I am probably the only person in the world who can
extend the array module with new data types. This is obviously not
the way I'd like things to be. If there is an important data type,
with a nice implementation in C, it shouldn't take me much time to add
the appropriate hooks. I happen to strongly dislike C++, so adding a
C++ object is unlikely.
On the other hand...
How exactly would you define a fuzzy number? My guess is that a fuzzy
array could probably be implemented fairly easily as a subclass of
UserArray in python, and that you wouldn't take too much of a
performance hit. Of course, this is just a guess.
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Tue Mar 12 17:05:05 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Tue, 12 Mar 1996 12:05:05 -0500
Subject: [PYTHON MATRIX-SIG] Extending NumericalPython by fuzzy numbers?
In-Reply-To: <9603121638.AA16842@baribal.LCS.MIT.EDU.LCS.MIT.EDU> (jjh@Goldilocks.LCS.MIT.EDU)
Message-ID: <199603121705.MAA10705@cyclone.ERE.UMontreal.CA>
> At the moment, I am probably the only person in the world who can
> extend the array module with new data types. This is obviously not
Sorry to disappoint you, but what do you think about this:
Python 1.3 (Mar 4 1996) [C]
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from Numeric import *
>>> from Derivatives import *
>>> a = array([DerivVar(-2.9,0), DerivVar(3.2,1)])
>>> multiply.reduce(a)
(-9.28, [3.2, -2.9])
As long as speed is not of prime importance, using general arrays with
arbitrary numeric types seems a very acceptable solution to me.
-------------------------------------------------------------------------------
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
=================
From dredish@CS.cmu.edu Wed Mar 13 15:07:15 1996
From: dredish@CS.cmu.edu (David Redish)
Date: Wed, 13 Mar 1996 10:07:15 -0500
Subject: [PYTHON MATRIX-SIG] atanh
Message-ID: <25549.826729635@GS151.SP.CS.CMU.EDU>
I have been unable to find atanh in the python Numeric libraries.
Is it there?
adr
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Wed Mar 13 16:33:14 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Wed, 13 Mar 1996 11:33:14 -0500
Subject: [PYTHON MATRIX-SIG] atanh
In-Reply-To: <25549.826729635@GS151.SP.CS.CMU.EDU> (message from David Redish on Wed, 13 Mar 1996 10:07:15 -0500)
Message-ID: <199603131633.LAA18578@cyclone.ERE.UMontreal.CA>
>
> I have been unable to find atanh in the python Numeric libraries.
> Is it there?
I can't find it either. There is one in cmath, which also works
for floats, but of course not for arrays.
-------------------------------------------------------------------------------
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
=================
From hinsenk@ere.umontreal.ca Wed Mar 13 17:24:18 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Wed, 13 Mar 1996 12:24:18 -0500
Subject: [PYTHON MATRIX-SIG] ArrayPrinter.py
Message-ID: <199603131724.MAA23017@cyclone.ERE.UMontreal.CA>
# Array printing function
#
# Written by Konrad Hinsen
# last revision: 1996-3-13
#
import sys
from fast_umath import *
import Numeric
def arrayToString(a, max_line_width = None, precision = None,
suppress_small = None):
if len(a.shape) == 0:
return str(a[0])
if max_line_width is None:
try:
max_line_width = sys.output_line_width
except AttributeError:
max_line_width = 77
if precision is None:
try:
precision = sys.float_output_precision
except AttributeError:
precision = 8
if suppress_small is None:
try:
suppress_small = sys.float_output_suppress_small
except AttributeError:
suppress_small = 0
if a.contiguous():
data = a.reshape(None)
else:
data = a.copy().reshape(None)
type = a.typecode()
items_per_line = a.shape[-1]
if type == 'b' or type == '1' or type == 's' or type == 'i' \
or type == 'l':
max_str_len = max(len(str(maximum.reduce(data))),
len(str(minimum.reduce(data))))
format = '%' + str(max_str_len) + 'd'
item_length = max_str_len+1
format_function = lambda x, f = format: _formatInteger(x, f)
elif type == 'f' or type == 'd':
format, item_length = _floatFormat(data, precision, suppress_small)
format_function = lambda x, f = format: _formatFloat(x, f)
elif type == 'F' or type == 'D':
real_format, real_item_length = _floatFormat(data.real, precision,
suppress_small, sign=0)
imag_format, imag_item_length = _floatFormat(data.imaginary, precision,
suppress_small, sign=1)
item_length = real_item_length + imag_item_length + 2
format_function = lambda x, f1 = real_format, f2 = imag_format: \
_formatComplex(x, f1, f2)
elif type == 'c':
item_length = 1
format_function = lambda x: x
elif type == 'O':
item_length = max(map(lambda x: len(str(x)), data)) + 1
format_function = _formatGeneral
else:
return str(a)
final_spaces = (type != 'c')
line_width = item_length*items_per_line - final_spaces
if line_width > max_line_width:
indent = 6
if indent == item_length:
indent = 8
items_first = (max_line_width+final_spaces)/item_length
if items_first < 1: items_first = 1
items_continuation = (max_line_width+final_spaces-indent)/item_length
if items_continuation < 1: items_continuation = 1
line_width = max(item_length*items_first,
item_length*items_continuation+indent) - final_spaces
number_of_lines = 1 + (items_per_line-items_first +
items_continuation-1)/items_continuation
line_format = (number_of_lines, items_first, items_continuation,
indent, line_width)
else:
line_format = (1, items_per_line, 0, 0, line_width)
return _arrayToString(a, format_function, len(a.shape), line_format)[:-1]
def _floatFormat(data, precision, suppress_small, sign = 0):
exp_format = 0
non_zero = abs(Numeric.compress(data.notEqual(0), data))
if len(non_zero) == 0:
max_val = 0.
min_val = 0.
else:
max_val = maximum.reduce(non_zero)
min_val = minimum.reduce(non_zero)
if max_val >= 1.e12:
exp_format = 1
if not suppress_small and (min_val < 0.0001 or max_val/min_val > 1000.):
exp_format = 1
if exp_format:
large_exponent = 0 < min_val < 1e-99 or max_val >= 1e100
max_str_len = 8 + precision + large_exponent
if sign: format = '%+'
else: format = '%'
format = format + str(max_str_len) + '.' + str(precision) + 'e'
if large_exponent: format = format + '3'
item_length = max_str_len + 1
else:
format = '%.' + str(precision) + 'f'
precision = min(precision, max(tuple(map(lambda x, p=precision,
f=format: _digits(x,p,f),
data))))
max_str_len = len(str(int(max_val))) + precision + 2
if sign: format = '%#+'
else: format = '%#'
format = format + str(max_str_len) + '.' + str(precision) + 'f'
item_length = max_str_len + 1
return (format, item_length)
def _digits(x, precision, format):
s = format % x
zeros = len(s)
while s[zeros-1] == '0': zeros = zeros-1
return precision-len(s)+zeros
def _arrayToString(a, format_function, rank, line_format):
if rank == 0:
return str(a[0])
elif rank == 1:
s = ''
items = line_format[1]
indent = 0
index = 0
for j in range(line_format[0]):
s = s + indent * ' '
for i in range(items):
s = s + format_function(a[index])
index = index + 1
if index == a.shape[0]: break
if s[-1] == ' ': s = s[:-1]
s = s + '\n'
items = line_format[2]
indent = line_format[3]
else:
s = ''
for i in range(a.shape[0]-1):
s = s + _arrayToString(a[i], format_function, rank-1, line_format)
if rank == 3:
s = s + '\n'
elif rank > 3:
s = s + (rank-3)*(line_format[4]*'-'+'\n')
s = s + _arrayToString(a[a.shape[0]-1], format_function,
rank-1, line_format)
return s
def _formatInteger(x, format):
return format % x + ' '
def _formatFloat(x, format, strip_zeros = 1):
if format[-1] == '3':
format = format[:-1]
s = format % x
third = s[-3]
if third == '+' or third == '-':
s = s[1:-2] + '0' + s[-2:]
elif format[-1] == 'f':
s = format % x
if strip_zeros:
zeros = len(s)
while s[zeros-1] == '0': zeros = zeros-1
s = s[:zeros] + (len(s)-zeros)*' '
else:
s = format % x
return s + ' '
def _formatComplex(x, real_format, imag_format):
r = _formatFloat(x.real, real_format)[:-1]
i = _formatFloat(x.imag, imag_format, 0)[:-1]
spaces = 0
while r[spaces] == ' ': spaces = spaces + 1
r = spaces*' ' + '(' + r[spaces:]
if imag_format[-1] == 'f':
zeros = len(i)
while i[zeros-1] == '0': zeros = zeros-1
i = i[:zeros] + 'j)' + (len(i)-zeros)*' '
else:
i = i + 'j)'
return r + i + ' '
def _formatGeneral(x):
return str(x) + ' '
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Wed Mar 13 17:23:51 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Wed, 13 Mar 1996 12:23:51 -0500
Subject: [PYTHON MATRIX-SIG] New array pretty printer
Message-ID: <199603131723.MAA23007@cyclone.ERE.UMontreal.CA>
I have added two new features to the array printer, and I will send
the new version to everyone in a separate message. Since the last
NumericPython distribution did not contain the most recent version
(there were still a few minor bugs), I recommend the current update
to everyone, even those who are not interested in the new features.
The first new feature is support for general object arrays. This is
rather elementary (str() is called on each element, and the resulting
strings are printed in a neat arrangement), but it is very useful and
also sufficient for any general array with reasonable elements. Of
course in extreme cases (e.g. when str() for one element returns a
multi-line string) the array output will be a complete mess.
The second new feature is an additional optional parameter
suppress_small that defaults to "false". If set to true (1), then
elements with a very small absolute value in float arrays will not
cause a switch to exponential format (they will be printed as
zeros). This results in a much neater output if these elements are in
fact "numerical zeros", but of course some information is lost.
I'd also like to propose to change the name of the module
"PrettyPrinter" to "ArrayPrinter". After someone sent me
another module called "PrettyPrinter" (which prints
lists etc. in a nice way), I had some problems for a while
until I found out what went wrong. To avoid such problems it
makes sense to choose a very specific name for this module,
and "ArrayPrinter" is certainly much more specific than
"PrettyPrinter".
-------------------------------------------------------------------------------
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
=================
From jjh@Goldilocks.LCS.MIT.EDU Wed Mar 13 20:58:14 1996
From: jjh@Goldilocks.LCS.MIT.EDU (James Hugunin)
Date: Wed, 13 Mar 96 15:58:14 EST
Subject: [PYTHON MATRIX-SIG] atanh
In-Reply-To: <199603131633.LAA18578@cyclone.ERE.UMontreal.CA> (hinsenk@ere.umontreal.ca)
Message-ID: <9603132058.AA09651@baribal.LCS.MIT.EDU.LCS.MIT.EDU>
This is an obvious oversight. As far as I can tell, the inverse
hyperbolic trig functions are part of the standard math library for
doubles, and Konrad's provided them for complex numbers, so I'll just
add a couple lines to my ufunc generator code and they'll be in the
next version.
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From davem@magnet.com Thu Mar 14 22:43:48 1996
From: davem@magnet.com (Dave Mitchell)
Date: Thu, 14 Mar 1996 17:43:48 -0500 (EST)
Subject: [PYTHON MATRIX-SIG] matrix module
Message-ID: <199603142243.RAA19827@lemur.magnet.com>
>
>
> Could someone please give me an url for the current matrix stuff?
>
> thanks-Dave
> davem@magnet.com
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From demars@netcom.com Fri Mar 15 01:03:53 1996
From: demars@netcom.com (Dennis C. De Mars)
Date: Thu, 14 Mar 1996 17:03:53 -0800
Subject: [PYTHON MATRIX-SIG] matrix module
Message-ID:
>>
>>
>> Could someone please give me an url for the current matrix stuff?
>>
>> thanks-Dave
>> davem@magnet.com
>
>
>=================
>MATRIX-SIG - SIG on Matrix Math for Python
>
>send messages to: matrix-sig@python.org
>administrivia to: matrix-sig-request@python.org
>=================
Same here; perhaps the location could be posted to the mailing list for
those of us who have signed up recently?
- Dennis D.
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From da@maigret.cog.brown.edu Sat Mar 16 19:49:16 1996
From: da@maigret.cog.brown.edu (David Ascher)
Date: Sat, 16 Mar 1996 14:49:16 -0500 (EST)
Subject: [PYTHON MATRIX-SIG] Any interest in PC binaries?
Message-ID: <199603161949.OAA27675@maigret>
I've recently gotten a PC, so the first thing I've done (naturally!)
is to get the Numeric extension to work with Python under Windows95,
along w/ the alpha OpenGL, GLU and Glut extensions. I will also be
looking into integrating the Numeric extension w/ Jim Ahlstrom's DOS
version (though clearly not the OpenGL stuff), as I hate having a ">>>"
prompt but being unable to do "from Numeric import *".
Would there be any interest in my making binaries of these ports
available, or is everyone on the list a pure unixhead?
--david
PS: Thanks to Python, the boundary between unix workstations and pc's is
blurring -- a fast pentium w/ Python and OpenGL is looking more and
more like my (r3000) SGI at school. Well, actually, it's faster.
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From phil@geog.ubc.ca Sat Mar 16 20:10:55 1996
From: phil@geog.ubc.ca (Phil Austin)
Date: Sat, 16 Mar 1996 12:10:55 -0800
Subject: [PYTHON MATRIX-SIG] Any interest in PC binaries?
In-Reply-To: <199603161949.OAA27675@maigret>
References: <199603161949.OAA27675@maigret>
Message-ID: <199603162010.MAA07296@whimbrel.geog.ubc.ca>
David Ascher writes:
> I've recently gotten a PC, so the first thing I've done (naturally!)
> is to get the Numeric extension to work with Python under Windows95,
> along w/ the alpha OpenGL, GLU and Glut extensions. I will also be
> looking into integrating the Numeric extension w/ Jim Ahlstrom's DOS
> version (though clearly not the OpenGL stuff), as I hate having a ">>>"
> prompt but being unable to do "from Numeric import *".
>
> Would there be any interest in my making binaries of these ports
> available, or is everyone on the list a pure unixhead?
>
> --david
One of the main attractions of Python (to us) is the cross-platform
development, and we'd appreciate access to the binaries. Our hope
is that it can be used as an Octave/Matlab-like teaching tool in our
undergraduate PC lab.
Regards,
Phil Austin INTERNET: phil@geog.ubc.ca
(604) 822-2175 FAX: (604) 822-6150
http://www.geog.ubc.ca/~phil
Associate Professor
Atmospheric Sciences Programme
Geography #217
University of British Columbia
1984 W Mall
Vancouver, BC V6T 1Z2
CANADA
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From demars@netcom.com Sun Mar 17 05:05:47 1996
From: demars@netcom.com (Dennis C. De Mars)
Date: Sat, 16 Mar 1996 21:05:47 -0800
Subject: [PYTHON MATRIX-SIG] matrix module
Message-ID:
>>>
>>>
>>> Could someone please give me an url for the current matrix stuff?
>>>
>>> thanks-Dave
>>> davem@magnet.com
>>
>>
>
>Same here; perhaps the location could be posted to the mailing list for
>those of us who have signed up recently?
>
>- Dennis D.
>
As Rosanne Rosanadana used to say, "Never mind." I discovered that an
archive of the entire content of the mailing list (as well as the other
Python lists) is available from Majordomo, which contains the desired URL
plus all of the discussion of Numerical Python which provides very useful
background -- now I won't feel as if I've come in on the middle of a
conversation while reading the traffic on this SIG. I would have realized
this was available if I'd read the info on the Python web site more
carefully.
Anyhow, I suggest to any new subscribers that haven't already done it that
they download the archive for matrix-sig -- over a megabyte and well worth
the effort (...and my apologies to other members of the SIG who will find
this message superfluous, but I think there may be a few other subscribers
out there who are as confused as I was and will find this helpful).
- Dennis D.
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From spillar@uwyo.edu Mon Mar 18 04:03:48 1996
From: spillar@uwyo.edu (Earl Spillar)
Date: Sun, 17 Mar 96 21:03:48 -0700
Subject: [PYTHON MATRIX-SIG] PC binaries
Message-ID: <9603180403.AA00503@galaxies.plk.af.mil>
David Ascher asked:
"Would there be any interest in my making binaries of these ports
available, or is everyone on the list a pure unixhead?"
Well, I'ld like to be a pure unix head, but the reality is I need
to work with people who aren't- so I would like to have the ports
available!
Earl Spillar
spillar@uwyo.edu
http://plains.uwyo.edu/~spillar/
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From GROMA@everx.szbk.u-szeged.hu Tue Mar 19 12:23:34 1996
From: GROMA@everx.szbk.u-szeged.hu (Groma Geza)
Date: Tue, 19 Mar 1996 12:23:34 MET
Subject: [PYTHON MATRIX-SIG] pickle error on Win95
Message-ID: <9A3698A0A36@everx.szbk.u-szeged.hu>
I built v0.35 on Win95 by Symantec C++ 7.3. No compilation error
occured. I realized that TestSuite was not updated to this version.
The following error, however, probably is not related to that.
Running TestPickle resulted in:
pickle.load(fp) ->
Bad result: EOFError: None
Traceback (innermost last):
File "", line 1, in ?
File "c:\Python\Lib\ArrayTest\TestPickle.py", line 31, in ?
do_eval(test, initialize = init)
File "c:\Python\Lib\ArrayTest\TestUtils.py", line 51, in do_eval
raise ValueError, "Bad result"
ValueError: Bad result
Is that a bug in the pickling routines, or can be fixed by a proper compiler flag?
This is the hex dump of file 'matrix.save' created by TestPickle:
4D 69 4C 34 20 32 20 33 20 34 20 0D 0A 00 00 00
00 01 00 00 00 02 00 00 00 03 00 00 00 0D 0A 00
00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 14 00
00 00 15 00 00 00 16 00 00 00 17 00 00 00 64 00
00 00 65 00 00 00 66 00 00 00 67 00 00 00 6E 00
00 00 6F 00 00 00 70 00 00 00 71 00 00 00 78 00
00 00 79 00 00 00 7A 00 00 00 7B 00 00 00 2E
Geza I. Groma
Institute of Biophysics
Biological Research Centre of Hungarian Academy of Sciences
Szeged, Hungary
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From jjh@Goldilocks.LCS.MIT.EDU Tue Mar 19 13:16:08 1996
From: jjh@Goldilocks.LCS.MIT.EDU (James Hugunin)
Date: Tue, 19 Mar 96 08:16:08 EST
Subject: [PYTHON MATRIX-SIG] pickle error on Win95
In-Reply-To: <9A3698A0A36@everx.szbk.u-szeged.hu> (GROMA@everx.szbk.u-szeged.hu)
Message-ID: <9603191316.AA19874@baribal.LCS.MIT.EDU.LCS.MIT.EDU>
Your hex dump looks right to me, so I'd guess that the error is
something else.
I'm surprised that v0.35 compiled on Win95 without any compilation
errors. I haven't yet implemented any of the patches that others have
told me are needed to get things to compile under windows. Did you
have to make any changes to the code?
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From steve@estel.uindy.edu Tue Mar 19 13:49:12 1996
From: steve@estel.uindy.edu (Steve Spicklemire)
Date: Tue, 19 Mar 96 08:49:12 -0500
Subject: [PYTHON MATRIX-SIG] pickle error on Win95
In-Reply-To: <9603191316.AA19874@baribal.LCS.MIT.EDU.LCS.MIT.EDU> (jjh@Goldilocks.LCS.MIT.EDU)
Message-ID: <9603191349.AA03021@estel.uindy.edu>
Jim,
>>>>> "James" == James Hugunin writes:
James> Your hex dump looks right to me, so I'd guess that the
James> error is something else.
James> I'm surprised that v0.35 compiled on Win95 without any
James> compilation errors. I haven't yet implemented any of the
James> patches that others have told me are needed to get things
James> to compile under windows. Did you have to make any changes
James> to the code?
Note that he's using the Symantec compiler, rather than MSoft. I don't
have that compiler, so I can't be sure, but all of the patches I made could've
easily been OK on another compiler (e.g., MSoft seems to define 'complex', and
M_PI was not defined.. etc.)
-steve
James> -Jim
James> ================= MATRIX-SIG - SIG on Matrix Math for
James> Python
James> send messages to: matrix-sig@python.org administrivia to:
James> matrix-sig-request@python.org =================
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Tue Mar 19 22:13:42 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Tue, 19 Mar 1996 17:13:42 -0500
Subject: [PYTHON MATRIX-SIG] Wanted: testers for a module
Message-ID: <199603192213.RAA23768@cyclone.ERE.UMontreal.CA>
This has no direct relation to the Matrix SIG, but since the code I am
talking about works only with the numerics package, I might just as
well restrict the distribution to those who have it.
I have written a module that handles physical quantities with
units. It allows all reasonable mathematical operations on them (while
checking unit compatibility and doing automatic unit conversions) and
can convert between compatible units.
I am looking for people willing to test this. The code itself is not
so much of a problem, but the biggest part of the file is the unit
table, and I am not 100% sure that all entries are correct and that
my collection is sufficiently complete. Anyone interested please
mail me.
Oh yes, there is a relation to arrays: you can use arrays for
the values if you want to :-)
-------------------------------------------------------------------------------
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
=================
From GROMA@everx.szbk.u-szeged.hu Wed Mar 20 11:49:19 1996
From: GROMA@everx.szbk.u-szeged.hu (Groma Geza)
Date: Wed, 20 Mar 1996 11:49:19 MET
Subject: [PYTHON MATRIX-SIG] pickle error on Win95
Message-ID: <9BAD7A75EB3@everx.szbk.u-szeged.hu>
> Your hex dump looks right to me, so I'd guess that the error is
> something else.
Meanwhile I fround that pickle.load() fails if the value of any
element of an integer array is 13 (CR!?). This is demonstrated in the
following example:
---------------------------------------------------
>>> import pickle
>>> from Numeric import *
>>> def CreateBug(m):
... fp=open("test","w")
... pickle.dump(m,fp)
... fp.close()
... fp=open("test","r")
... y=pickle.load(fp)
... print y
...
>>> CreateBug(array([12,14,15]))
12 14 15
>>> CreateBug(array([12,13,14]))
Traceback (innermost last):
File "", line 1, in ?
File "", line 6, in CreateBug
File "c:\Python\Lib\pickle.py", line 533, in load
return Unpickler(file).load()
File "c:\Python\Lib\pickle.py", line 375, in load
self.dispatch[key](self)
File "c:\Python\Lib\pickle.py", line 387, in load_eof
raise EOFError
EOFError
>>>
----------------------------------------------------------------------
If you have any idea how to fix this error, I am eager to check it on
my system.
> I'm surprised that v0.35 compiled on Win95 without any compilation
> errors. I haven't yet implemented any of the patches that others have
> told me are needed to get things to compile under windows. Did you
> have to make any changes to the code?
Absolutely no change was necessery for Symantec C.
Geza I. Groma
Institute of Biophysics
Biological Research Centre of Hungarian Academy of Sciences
Szeged, Hungary
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From GROMA@everx.szbk.u-szeged.hu Wed Mar 20 12:03:51 1996
From: GROMA@everx.szbk.u-szeged.hu (Groma Geza)
Date: Wed, 20 Mar 1996 12:03:51 MET
Subject: [PYTHON MATRIX-SIG] pickle error on Win95
Message-ID: <9BB158C6B31@everx.szbk.u-szeged.hu>
> Note that he's using the Symantec compiler, rather than MSoft. I don't
> have that compiler, so I can't be sure, but all of the patches I made could've
> easily been OK on another compiler (e.g., MSoft seems to define 'complex', and
> M_PI was not defined.. etc.)
I offer my help in checking your patches on Symantec C. Could you send
me the code and the list of compiler errors you have got with MSoft?
Geza I. Groma
Institute of Biophysics
Biological Research Centre of Hungarian Academy of Sciences
Szeged, Hungary
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From fredrik_lundh@ivab.se Wed Mar 20 11:08:34 1996
From: fredrik_lundh@ivab.se (Fredrik Lundh)
Date: Wed, 20 Mar 1996 12:08:34 +0100
Subject: [PYTHON MATRIX-SIG] pickle error on Win95
In-Reply-To: <9BAD7A75EB3@everx.szbk.u-szeged.hu>
(GROMA@everx.szbk.u-szeged.hu)
Message-ID: <9603201108.AA12490@arnold.image.ivab.se>
... fp=open("test","w")
... pickle.dump(m,fp)
... fp.close()
... fp=open("test","r")
... y=pickle.load(fp)
... print y
Hey, you've forgot the "b" flag! The following should work:
... fp=open("test","wb")
... pickle.dump(m,fp)
... fp.close()
... fp=open("test","rb")
... y=pickle.load(fp)
Since text and binary files are not the same thing under DOS (and
some other systems as well), you should always make sure to add "b"
when dealing with binary data. See open() in the python manual for
details.
/F
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From guido@CNRI.Reston.VA.US Wed Mar 20 15:04:59 1996
From: guido@CNRI.Reston.VA.US (Guido van Rossum)
Date: Wed, 20 Mar 1996 10:04:59 -0500
Subject: [PYTHON MATRIX-SIG] pickle error on Win95
In-Reply-To: Your message of "Wed, 20 Mar 1996 12:08:34 +0100."
<9603201108.AA12490@arnold.image.ivab.se>
References: <9603201108.AA12490@arnold.image.ivab.se>
Message-ID: <199603201505.KAA07841@monty>
> Hey, you've forgot the "b" flag! The following should work:
[...]
> Since text and binary files are not the same thing under DOS (and
> some other systems as well), you should always make sure to add "b"
> when dealing with binary data. See open() in the python manual for
> details.
On the other hand, pickle *used* to be a text-only format, which is
fine with 'r' and 'b'. But I presume that numerical arrays may be
written in a more efficient binary form?
--Guido van Rossum
URL:
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From jjh@Goldilocks.LCS.MIT.EDU Wed Mar 20 15:22:55 1996
From: jjh@Goldilocks.LCS.MIT.EDU (James Hugunin)
Date: Wed, 20 Mar 96 10:22:55 EST
Subject: [PYTHON MATRIX-SIG] pickle error on Win95
Message-ID: <9603201522.AA06306@baribal.LCS.MIT.EDU.LCS.MIT.EDU>
> Hey, you've forgot the "b" flag! The following should work:
[...]
> Since text and binary files are not the same thing under DOS (and
> some other systems as well), you should always make sure to add "b"
> when dealing with binary data. See open() in the python manual for
> details.
On the other hand, pickle *used* to be a text-only format, which is
fine with 'r' and 'b'. But I presume that numerical arrays may be
written in a more efficient binary form?
--Guido van Rossum
URL:
I've been waiting for somebody to notice this and properly castigate
me for violating the beauty of pickle's text-only format.
There are some major size and speed savings to be realized by dumping
large arrays in a binary format. Since dumping 1 MB arrays to disk is
not all that uncommon, these things are unfortunately an issue.
This is the first time that anybody's noticed problems with the binary
format, and it seems a simple enough matter to add warnings that
matrices should only be pickled to binary format files. Other than
this, I've found the binary format to work quite well for archiving
arbitrary objects that contain matrices across many platforms
(big/little endian) and even for passing these objects across sockets.
Anybody know a way I can add a check to the matrix pickling routines
to determine if they're writing to/reading from a binary format file
and raise an exception otherwise?
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From guido@CNRI.Reston.VA.US Wed Mar 20 15:27:15 1996
From: guido@CNRI.Reston.VA.US (Guido van Rossum)
Date: Wed, 20 Mar 1996 10:27:15 -0500
Subject: [PYTHON MATRIX-SIG] pickle error on Win95
In-Reply-To: Your message of "Wed, 20 Mar 1996 10:22:55 EST."
<9603201522.AA06306@baribal.LCS.MIT.EDU.LCS.MIT.EDU>
References: <9603201522.AA06306@baribal.LCS.MIT.EDU.LCS.MIT.EDU>
Message-ID: <199603201527.KAA08036@monty>
> I've been waiting for somebody to notice this and properly castigate
> me for violating the beauty of pickle's text-only format.
>
> There are some major size and speed savings to be realized by dumping
> large arrays in a binary format. Since dumping 1 MB arrays to disk is
> not all that uncommon, these things are unfortunately an issue.
Agreed. For large strings, I was going to add this (eventually) as a
speed up extension as well.
> This is the first time that anybody's noticed problems with the binary
> format, and it seems a simple enough matter to add warnings that
> matrices should only be pickled to binary format files. Other than
> this, I've found the binary format to work quite well for archiving
> arbitrary objects that contain matrices across many platforms
> (big/little endian) and even for passing these objects across sockets.
You must've patched the pickle module, right?
> Anybody know a way I can add a check to the matrix pickling routines
> to determine if they're writing to/reading from a binary format file
> and raise an exception otherwise?
That's easy. A file object has an attribute 'mode' which is the
read/write open mode. Of course, pickle can also be used on pseudo
file objects (like StringIO) which don't have this attribute.
--Guido van Rossum
URL:
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From drh@oasis.unl.edu Wed Mar 20 17:07:35 1996
From: drh@oasis.unl.edu (Doug Heisterkamp)
Date: Wed, 20 Mar 1996 11:07:35 -0600 (CST)
Subject: [PYTHON MATRIX-SIG] LAPACK access module v.0.02 is available
Message-ID: <199603201707.LAA23052@oasis.unl.edu>
Hi,
The second version of the python modules for the low-level access to the
LAPACK libraries is now available at
ftp.cs.unl.edu
in
/pub/drh/python/pylapack.0.02.tar.gz
Some of the changes from version 0.01
* Removed reference to f2c.h -- easier to link to fortran libraries
* Fixed a mistake in reference counting.
* Doc strings have been removed.
* Modules have been split up based on first three letters of function names.
* Functions return an exception if the arrays are not contiguous or of the
wrong type
* LinAlg.py from Konrad Hinsen has been added to the distribution.
Doug Heisterkamp
drh@oasis.unl.edu
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From GROMA@everx.szbk.u-szeged.hu Thu Mar 21 16:15:30 1996
From: GROMA@everx.szbk.u-szeged.hu (Groma Geza)
Date: Thu, 21 Mar 1996 16:15:30 MET
Subject: [PYTHON MATRIX-SIG] compiling v0.35 by Symantec C
Message-ID: <9D7483D064B@everx.szbk.u-szeged.hu>
Steve Spicklemire wrote:
> Here is my original note to Jim. I also have diffs around
> somewhere.
>
> -steve
>
> --------
>
> OK... well it took a lot longer than I would've figured
> to get python compiling and running under windows.. but
> once I got that.. the matrix module worked without much
> change. The one that stumped me for a bit was endless
> complaints about the 'complex' type. After much gnashing
> of teeth it turns out that MSoft defines it's own complex
> type in so..... if you include "mymath.h" before
> "allobjects.h" in any module/object that deals with the complex
> type, then all is well.
Math.h of Symantec C includes complex in the form:
struct complex
{
double x,y;
};
This did not conflict with Konrad Hinsen's allobjects.h and
complexobject.h distributed in v0.35.
> Also, the Windows port needs
>
> HAVE_HYPOT
>
> defined in config.h for the math modules to build without
> complaint.
I used config.h distributed in the latest version of PythonWin. That defines HAVE_HYPOT.
> Finally, M_PI needs to be defined as well.
Symantec math.h includes
#define PI 3.14159265358979323846
#define M_PI PI
In addition M_PI is defined in umathmodule.c, fast_umathmodule.c and
cmathmodule.c of v0.35.
Geza I. Groma
Institute of Biophysics
Biological Research Centre of Hungarian Academy of Sciences
Szeged, Hungary
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From GROMA@everx.szbk.u-szeged.hu Thu Mar 21 14:50:36 1996
From: GROMA@everx.szbk.u-szeged.hu (Groma Geza)
Date: Thu, 21 Mar 1996 14:50:36 MET
Subject: [PYTHON MATRIX-SIG] pickle error on Win95
Message-ID: <9D5DDCA3BB6@everx.szbk.u-szeged.hu>
> I've been waiting for somebody to notice this and properly castigate
> me for violating the beauty of pickle's text-only format.
>
> There are some major size and speed savings to be realized by dumping
> large arrays in a binary format. Since dumping 1 MB arrays to disk is
> not all that uncommon, these things are unfortunately an issue.
>
> This is the first time that anybody's noticed problems with the binary
> format, and it seems a simple enough matter to add warnings that
> matrices should only be pickled to binary format files. Other than
> this, I've found the binary format to work quite well for archiving
> arbitrary objects that contain matrices across many platforms
> (big/little endian) and even for passing these objects across sockets.
>
> Anybody know a way I can add a check to the matrix pickling routines
> to determine if they're writing to/reading from a binary format file
> and raise an exception otherwise?
>
> -Jim
I completely agree with the binary format for arrays. Is there any
system where the "b" flag in open() causes problem? If not, I suggest to include
this flag in TestPickle.py.
BTW could you upgrade TestSuite to be compatible
with v0.35? I realized that in this version nonzero() does not return
None. This makes sense, but in this case I really miss a special object
representing an empty array, like [] or () for an empty list or tuple.
Matlab introduces [] for that, and it is very extensively used there.
Geza I. Groma
Institute of Biophysics
Biological Research Centre of Hungarian Academy of Sciences
Szeged, Hungary
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Thu Mar 21 16:24:09 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Thu, 21 Mar 1996 11:24:09 -0500
Subject: [PYTHON MATRIX-SIG] pickle error on Win95
In-Reply-To: <9D5DDCA3BB6@everx.szbk.u-szeged.hu> (GROMA@everx.szbk.u-szeged.hu)
Message-ID: <199603211624.LAA29075@cyclone.ERE.UMontreal.CA>
> None. This makes sense, but in this case I really miss a special object
> representing an empty array, like [] or () for an empty list or tuple.
> Matlab introduces [] for that, and it is very extensively used there.
array() should accept empty lists in its arguments. Then array([])
would be a rank-1 array of length zero, array([[],[]]) a rank-2 array
of shape (2,0) and so on. A single "empty array" does not make sense,
since there can be many empty arrays that differ in shape. Matlab can
get away with that because its matrix concept is much more limited.
-------------------------------------------------------------------------------
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
=================
From hinsenk@ere.umontreal.ca Mon Mar 25 13:29:36 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Mon, 25 Mar 1996 08:29:36 -0500
Subject: [PYTHON MATRIX-SIG] Re: empty array
In-Reply-To: <9EF360E2F63@everx.szbk.u-szeged.hu> (GROMA@everx.szbk.u-szeged.hu)
Message-ID: <199603251329.IAA16483@cyclone.ERE.UMontreal.CA>
>
> > array() should accept empty lists in its arguments. Then array([])
> > would be a rank-1 array of length zero, array([[],[]]) a rank-2 array
> > of shape (2,0) and so on.
>
> That is what I expected, too, but it does not work, at least on my
> system (built from v0.35). What is wrong in this code?
I know it doesn't work. When I wrote "it should work" I didn't mean
"I think it works", but "I think it ought to work". Keep in mind
that the array module is neither finished nor bug-free.
> Even if array([]) were correct, that would be useful only to create
> an empty array, and not to test it. In TestUtils.py I found a simple
> and natural way to check the equality of array a and b:
>
> a.notEqual(b).nonzero() == None
I must confess that I never understood what nonzero() is good
for. Now I am beginning to realize its use. The name is
rather misleading...
Anyway, to test the equality of two arrays, of course
a == b
ought to work. Currently it seems to be equivalent to
a is b
which is against standard Python conventions. Unfortunately
there is no way to give a reasonable meaning to a > b
and a < b, but they are much less important in practice.
Supposing that a == b does what everybody expects it to
do, you can then use it to test for a specific form
of an empty array by writing
a == array([])
a == array([[]])
and so on. To test for general emptyness, i.e. to test if
an array has zero elements, you can write
ravel(a) == array([])
> Another problem is that an empty array is not a printable object:
I know, but there is no point in trying to fix this as long
as many operations don't work properly on empty arrays. The
expression
maximum.reduce(data)
for example should not raise an error if "data" is empty,
but return the smallest representable number of the type
of "data".
-------------------------------------------------------------------------------
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
=================
From GROMA@everx.szbk.u-szeged.hu Fri Mar 22 16:11:05 1996
From: GROMA@everx.szbk.u-szeged.hu (Groma Geza)
Date: Fri, 22 Mar 1996 16:11:05 MET
Subject: [PYTHON MATRIX-SIG] empty array
Message-ID: <9EF360E2F63@everx.szbk.u-szeged.hu>
Konrad Hinsen writes:
> array() should accept empty lists in its arguments. Then array([])
> would be a rank-1 array of length zero, array([[],[]]) a rank-2 array
> of shape (2,0) and so on.
That is what I expected, too, but it does not work, at least on my
system (built from v0.35). What is wrong in this code?
-------------------------------------------------------------------
>>> from Numeric import *
>>> array([])
Traceback (innermost last):
File "", line 1, in ?
TypeError: illegal argument type for built-in operation
>>>
-------------------------------------------------------------------
> A single "empty array" does not make sense,
> since there can be many empty arrays that differ in shape. Matlab can
> get away with that because its matrix concept is much more limited.
Even if array([]) were correct, that would be useful only to create
an empty array, and not to test it. In TestUtils.py I found a simple
and natural way to check the equality of array a and b:
a.notEqual(b).nonzero() == None
In v0.35 this returns false. The equality can be tested by
len(a.notEqual(b).nonzero()) == 0
but I personally prefer the previous style. None is a 'general empty
object', something similar could be introduced for arrays, too.
Another problem is that an empty array is not a printable object:
--------------------------------------------------------------
>>> array([0]).nonzero()
Traceback (innermost last):
File "", line 1, in ?
File "./PrettyPrinter.py", line 28, in arrayToString
max_str_len = max(len(str(maximum.reduce(data))),
ArrayError: can't take anything from an empty array
>>>
-----------------------------------------------------------------
Geza I. Groma
Institute of Biophysics
Biological Research Centre of Hungarian Academy of Sciences
Szeged, Hungary
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From tbyang@icf.llnl.gov Mon Mar 25 18:45:05 1996
From: tbyang@icf.llnl.gov (Tser-Yuan BrianYang)
Date: Mon, 25 Mar 96 10:45:05 PST
Subject: [PYTHON MATRIX-SIG] PrettyPrinter problem
Message-ID: <9603251845.AA05868@icf.llnl.gov>
The following may have been posted or even corrected. If so, I apologize
for sending junk mail.
The PrettyPrinter in the numeric package seems to have trouble printing
a float or double array with only one element, i.e.,
>>> a=zeros(1,'d')
>>> a
Traceback (innermost last):
File "", line 1, in ?
File "/dist/basis/Python/Python-1.3b/lib/python/numeric/PrettyPrinter.py", lin
e 34, in arrayToString
format, item_length = _floatFormat(data, precision)
File "/dist/basis/Python/Python-1.3b/lib/python/numeric/PrettyPrinter.py", lin
e 91, in _floatFormat
precision = min(precision, apply(max, tuple(map(lambda x, p=precision,
TypeError: min() or max() of non-sequence
Brian Yang
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From jjh@Goldilocks.LCS.MIT.EDU Mon Mar 25 19:35:52 1996
From: jjh@Goldilocks.LCS.MIT.EDU (James Hugunin)
Date: Mon, 25 Mar 96 14:35:52 EST
Subject: [PYTHON MATRIX-SIG] Re: empty array
In-Reply-To: <199603251329.IAA16483@cyclone.ERE.UMontreal.CA> (hinsenk@ere.umontreal.ca)
Message-ID: <9603251935.AA23372@baribal.LCS.MIT.EDU.LCS.MIT.EDU>
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
>
> > array() should accept empty lists in its arguments. Then array([])
> > would be a rank-1 array of length zero, array([[],[]]) a rank-2 array
> > of shape (2,0) and so on.
>
> That is what I expected, too, but it does not work, at least on my
> system (built from v0.35). What is wrong in this code?
I know it doesn't work. When I wrote "it should work" I didn't mean
"I think it works", but "I think it ought to work". Keep in mind
that the array module is neither finished nor bug-free.
I made the obvious patches to get this to work and noticed that
array([]) creates an empty array of characters (This is the lowest
type in the type hierarchy). This is probably not what people want in
the general case. Any suggestions on how to deal with the type of an
empty array?
-Jim
BTW - I'm making these patches in preparation for one a final 0.36
release containing a fairly large number of bug fixes. After that I
plan to start work on v0.40 which will involve switching over to much
of Konrad's proposed naming conventions.
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Mon Mar 25 20:13:33 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Mon, 25 Mar 1996 15:13:33 -0500
Subject: [PYTHON MATRIX-SIG] PrettyPrinter problem
In-Reply-To: <9603251845.AA05868@icf.llnl.gov> (tbyang@icf.llnl.gov)
Message-ID: <199603252013.PAA26408@cyclone.ERE.UMontreal.CA>
> The PrettyPrinter in the numeric package seems to have trouble printing
> a float or double array with only one element, i.e.,
>
> >>> a=zeros(1,'d')
> >>> a
That has been fixed a long time ago, but somehow the fixed
version did not propagate far from me :-(
Anyway, the updated version I sent to the list some time
ago should not have that bug. If anyone didn't get it
or lost it, please contact me. (For identification: I am
talking about the version that can print general arrays.)
-------------------------------------------------------------------------------
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
=================
From hinsenk@ere.umontreal.ca Mon Mar 25 20:25:29 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Mon, 25 Mar 1996 15:25:29 -0500
Subject: [PYTHON MATRIX-SIG] Re: empty array
In-Reply-To: <9603251935.AA23372@baribal.LCS.MIT.EDU.LCS.MIT.EDU> (jjh@Goldilocks.LCS.MIT.EDU)
Message-ID: <199603252025.PAA28420@cyclone.ERE.UMontreal.CA>
> I made the obvious patches to get this to work and noticed that
> array([]) creates an empty array of characters (This is the lowest
> type in the type hierarchy). This is probably not what people want in
> the general case. Any suggestions on how to deal with the type of an
> empty array?
Of course explicit type specifications should work as expected.
For the default type, I am surprised that "character" is
in the hierarchy at all. Character arrays behave differently
and are not coerced to number arrays. They should therefore
be a separate category. The default type for empty arrays
would then be "integer", which is fine.
-------------------------------------------------------------------------------
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
=================
From tommy@archive.cs.virginia.edu Wed Mar 27 17:58:27 1996
From: tommy@archive.cs.virginia.edu (tommy@archive.cs.virginia.edu)
Date: Wed, 27 Mar 1996 12:58:27 -0500
Subject: [PYTHON MATRIX-SIG] FAQ?
Message-ID: <9603271758.AA25053@viper.cs.Virginia.EDU>
Hi,
I just hitched up on this list looking for info on the Matrix
extension(s) to Python and was wondering if there's a FAQ before I
start asking questions. Thanks,
-------> Tommy.
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Thu Mar 28 14:11:34 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Thu, 28 Mar 1996 09:11:34 -0500
Subject: [PYTHON MATRIX-SIG] Slices
Message-ID: <199603281411.JAA26035@cyclone.ERE.UMontreal.CA>
The recently introduced slice notation (a:b etc.) has greatly improved
readability of slice indexing, but is has also lead to the disappearance
of the old Slice() objects (they are still there, but are not accepted
as indices any more) and thereby important functionality: it is no
longer possible to construct index expressions containing slices
dynamically.
For those who wonder why anyone might want to do this, I'll describe
my application: I have written a class that represents a function
defined on a grid, with linear interpolation for arguments between the
grid points. Of course it should work for functions of any number of
arguments. A crucial step in the interpolation is the extraction of
the subarray of neighbouring grid points, i.e. a subarray of length 2
along any axis. It is no problem to calculate the first/last indices
for each axis, but there is currently no way to construct an indexing
expression with slices, because the : notation is legal only inside
square brackets.
There are basically three possible solutions:
1) Make the : notation legal everywhere. That would make slice objects
first-class objects like anything else in Python. You could create
them, assign them to variables, make them elements of lists, tuples,
or arrays, etc. It would then make sense to make them real sequence
objects that can be subscripted, used in for-loops, converted to
lists or tuples etc.
2) Reintroduce the old Slice() notation for the new slice objects.
The consequences would be the same as above, but with a less
uniform syntax. I don't really see the point of doing this.
3) Keep slice objects restricted to index expressions, but create
some way to make them act on a dynamically specified axis. Then
the example given above could be handled by iteratively indexing
along the axes. Less elegant, but better than nothing.
My personal favourite is 1), and I can't see any disadvantage in
this. But that makes me think about why slice objects were restricted
to subscripts in the first place. Was there a good reason for that, or
was it just the desire to make the smallest possible change to Python
syntax?
-------------------------------------------------------------------------------
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
=================
From hinsenk@ere.umontreal.ca Thu Mar 28 14:11:34 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Thu, 28 Mar 1996 09:11:34 -0500
Subject: [PYTHON MATRIX-SIG] Slices
Message-ID: <199603281411.JAA26035@cyclone.ERE.UMontreal.CA>
The recently introduced slice notation (a:b etc.) has greatly improved
readability of slice indexing, but is has also lead to the disappearance
of the old Slice() objects (they are still there, but are not accepted
as indices any more) and thereby important functionality: it is no
longer possible to construct index expressions containing slices
dynamically.
For those who wonder why anyone might want to do this, I'll describe
my application: I have written a class that represents a function
defined on a grid, with linear interpolation for arguments between the
grid points. Of course it should work for functions of any number of
arguments. A crucial step in the interpolation is the extraction of
the subarray of neighbouring grid points, i.e. a subarray of length 2
along any axis. It is no problem to calculate the first/last indices
for each axis, but there is currently no way to construct an indexing
expression with slices, because the : notation is legal only inside
square brackets.
There are basically three possible solutions:
1) Make the : notation legal everywhere. That would make slice objects
first-class objects like anything else in Python. You could create
them, assign them to variables, make them elements of lists, tuples,
or arrays, etc. It would then make sense to make them real sequence
objects that can be subscripted, used in for-loops, converted to
lists or tuples etc.
2) Reintroduce the old Slice() notation for the new slice objects.
The consequences would be the same as above, but with a less
uniform syntax. I don't really see the point of doing this.
3) Keep slice objects restricted to index expressions, but create
some way to make them act on a dynamically specified axis. Then
the example given above could be handled by iteratively indexing
along the axes. Less elegant, but better than nothing.
My personal favourite is 1), and I can't see any disadvantage in
this. But that makes me think about why slice objects were restricted
to subscripts in the first place. Was there a good reason for that, or
was it just the desire to make the smallest possible change to Python
syntax?
-------------------------------------------------------------------------------
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
=================
From huntd@pocc.gpsmet.ucar.edu Thu Mar 28 16:40:25 1996
From: huntd@pocc.gpsmet.ucar.edu (Doug Hunt)
Date: Thu, 28 Mar 1996 09:40:25 -0700 (MST)
Subject: [PYTHON MATRIX-SIG] Where is the Numerical Python extension?
Message-ID:
Hi all: I looked at the short postscript paper on Numerical Python on
www.python.org and it looked like just the thing I need for numerical
programming project I've got coming up (plus I wanted to learn python).
The trouble is that after having looked all over www.python.org, I can't
find the bloody thing. In the paper there is reference to a beta version
having been released. Can anyone point me in the right direction?
Many thanks,
Doug Hunt
dhunt@ucar.edu
GPS/MET project
Tel. (303) 497-2611
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hugunin@mit.edu Fri Mar 29 16:18:17 1996
From: hugunin@mit.edu (Jim Hugunin)
Date: Fri, 29 Mar 1996 11:18:17 -0500
Subject: [PYTHON MATRIX-SIG] Re: building problems on DEC Alphas
References: <4jfiab$f18@csnews.cs.colorado.edu>
Message-ID: <315C0D49.41C67EA6@mit.edu>
Both of these issues are related entirely to the Numerical extension and
should really be discussed in the matrix-sig. I hate to sound like a net
cop, but the main reason for this is that I pay a great deal of
attention to bugs reported to the sig, while I skip many of the postings
to the main newsgroup.
Your problem lies in ofuncobject.c, and if you add the following line to
the top of this file, this problem should go away.
#define HAVE_FINITE
(Interestingly enough, I just ran into this problem myself this morning
as I was trying to get some code to run on our alcors).
As to your qeustion about cluster analysis, I'd be interested to hear
what answers you get.
-Jim
Carlos Maltzahn wrote:
Does anybody know about cluster analysis software that could be easily
integrated into Numerical Python? Or even better, is there already
such a module out there?
>
> I tried to build Python on a DEC Alpha (DEC OSF/1 V3.2A (Rev. 17)).
> During linking I get the following error message:
>
> ld:
> Unresolved:
> CHECK
> *** Exit 1
> Stop.
> *** Exit 1
> Stop.
>
> After doing a grep CHECK Modules/*.c I get many modules that define
> CHECK as a macro. Does anybody has an idea what's wrong?
>
> Any comments are very appreciated!
> Carlos
>
> --
> # Carlos Maltzahn University of Colorado at Boulder
> # carlosm@cs.colorado.edu Department of Computer Science
> # FAX: ++1-303-492-2844 Campus Box 430, Boulder, CO 80309-0430
> # phone: 8709 http://www.cs.colorado.edu/~carlosm/
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From huntd@pocc.gpsmet.ucar.edu Fri Mar 29 16:55:38 1996
From: huntd@pocc.gpsmet.ucar.edu (Doug Hunt)
Date: Fri, 29 Mar 1996 09:55:38 -0700 (MST)
Subject: [PYTHON MATRIX-SIG] Thanks
Message-ID:
Hi all: Thanks for the quick replies regarding the location of Numeric
Python. I downloaded it and was able to get it up and running (flawless
build!) on my Linux machine at home.
A few quick experiments lead me to believe that Numeric Python will do
everything that I need.
Keep up the good work!
Doug Hunt
dhunt@ucar.edu
GPS/MET project
Tel. (303) 497-2611
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From jjh@Goldilocks.LCS.MIT.EDU Fri Mar 29 18:48:36 1996
From: jjh@Goldilocks.LCS.MIT.EDU (James Hugunin)
Date: Fri, 29 Mar 96 13:48:36 EST
Subject: [PYTHON MATRIX-SIG] Floating point exceptions on DEC alpha
Message-ID: <9603291848.AA00977@baribal.LCS.MIT.EDU.LCS.MIT.EDU>
I've recently started running some fairly demanding code on our DEC
alphas (using Numeric python of course) and I've run into a very
annoying piece of behavior. If I do a division by zero, instead of
returning an IEEE Infinity value, an exception is raised and I'm
thrown out of python entirely. You'll have to take my word for the
fact that these particular divide by zeros are not in fact a bug in my
code, but something that is worth catching later.
Here's a simple example:
On a Sparc 10 (and most other machines I've worked with)
>>> from Numeric import *
>>> array(1.)/0
Infinity
>>>
On a DEC alpha
>>> from Numeric import *
>>> array(1.)/0
Floating exception
(Dumped back to the shell)
What I'd like to do is find a compiler flag, environment variable, or
whatever that would make the alpha behave like the Sparc 10 in this
and similar cases. Does anybody have any hints?
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From carlosm@anchor.cs.colorado.edu Fri Mar 29 21:59:03 1996
From: carlosm@anchor.cs.colorado.edu (Carlos Maltzahn)
Date: Fri, 29 Mar 1996 14:59:03 -0700 (MST)
Subject: [PYTHON MATRIX-SIG] Are the matrix-sig articles archived?
Message-ID: <199603292159.OAA12556@anchor.cs.colorado.edu>
If so, could somebody tell me where the archive is?
Thanks,
Carlos
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From carlosm@anchor.cs.colorado.edu Sun Mar 31 02:30:11 1996
From: carlosm@anchor.cs.colorado.edu (Carlos Maltzahn)
Date: Sat, 30 Mar 1996 19:30:11 -0700 (MST)
Subject: [PYTHON MATRIX-SIG] max_element array method
Message-ID: <199603310230.TAA25619@anchor.cs.colorado.edu>
I don't know whether this has been discussed before because I have yet
to find the matrix-sig archive. I'm currently implementing some clustering
algorithms and came across two features that would be very helpful to
me:
1. A space-efficient implementation of a symmetric matrix object, and
2. a max_elem() and min_elem() method that would return the tuple
(max_elem, index). For example:
> from Numeric import *
> m == zeros(3, 3, 2)
> m[2, 0, 1] = 12.04
> m.max_elem()
> (12.04, (2, 0, 1))
> m.min_elem()
> (0.0, (2, 2, 1))
> m[2, 0].max_elem()
> (12.04, (1,))
Currently, I'm using a Python class that does just that. But a C-level
implementation would be probably faster and more space-efficient.
Comments?
Carlos
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From hinsenk@ere.umontreal.ca Sun Mar 31 14:50:40 1996
From: hinsenk@ere.umontreal.ca (Konrad HINSEN)
Date: Sun, 31 Mar 1996 09:50:40 -0500
Subject: [PYTHON MATRIX-SIG] max_element array method
In-Reply-To: <199603310230.TAA25619@anchor.cs.colorado.edu> (message from Carlos Maltzahn on Sat, 30 Mar 1996 19:30:11 -0700 (MST))
Message-ID: <199603311450.JAA27508@cyclone.ERE.UMontreal.CA>
> I don't know whether this has been discussed before because I have yet
> to find the matrix-sig archive. I'm currently implementing some clustering
> algorithms and came across two features that would be very helpful to
> me:
>
> 1. A space-efficient implementation of a symmetric matrix object, and
That is not so difficult. The most straightforward way is to define
symmetric matrices as a Python class and use a one-dimensional array
object as the data representation. The most reasonable arrangement is
the packed format used by LAPACK, and of course by using it you have
immediate access to all the linear algebra functions from that
library. All the elementwise operations can be mapped directly on the
internal representation. Indexing is straightforward. Matrix
multiplication has to be rewritten, and is a bit tricky, since the
product of two symmetric matrices is in general not a symmetric
matrix.
But if you want full compatibility with ordinary arrays, the
implementation gets complicated. Slices, for example, are messy. So
are reduction operations, for example. But these operations don't make
much sense for symmetric matrices anyway. So the best solution is not
to pretend that symmetric matrices are a special case of general
arrays and implement only a meaningful subset of operations.
> 2. a max_elem() and min_elem() method that would return the tuple
> (max_elem, index). For example:
Right, there is very little support now for efficient determination
of specific indices. I had a similar problem recently with my
class for function interpolation: finding the index of the largest
element smaller than a given number in a sorted array.
> Currently, I'm using a Python class that does just that. But a C-level
> implementation would be probably faster and more space-efficient.
I don't know how you do it in Python, but if you are doing the whole
search in Python, consider the following alternative:
def max_index(a):
max = maximum.reduce(a)
index = compress(equal(a, max), arange(a.shape[0]))
return max, index
This version is only for rank-1 arrays; a general version is possible,
but messy. It is still inefficient compared to C, but there is no
loop in Python, which probably makes it faster for long arrays.
And if the maximum occurs more than once, you even get all the
indices.
-------------------------------------------------------------------------------
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
=================
From hugunin@clark.lcs.mit.edu Sun Mar 31 17:28:16 1996
From: hugunin@clark.lcs.mit.edu (James Hugunin)
Date: Sun, 31 Mar 96 12:28:16 -0500
Subject: [PYTHON MATRIX-SIG] max_element array method
Message-ID: <9603311728.AA13359@clark.lcs.mit.edu>
Try argmax and argmin. (And since I had similar problems as
Konrad, the next release will add argsort).
ie.
>>> argmax([1,2,3,4,3,2,1])
(4, 3)
This will only return the index of the first maxima in the list
(which is usually what I want anyway). This will work on
arbitrarily high dimensional arrays, always acting along the last
axis.
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From fredrik_lundh@ivab.se Sun Mar 31 19:33:19 1996
From: fredrik_lundh@ivab.se (Fredrik Lundh)
Date: Sun, 31 Mar 1996 21:33:19 +0200
Subject: [PYTHON MATRIX-SIG] Sorry to have to ask this question again...
In-Reply-To: <9603311728.AA13359@clark.lcs.mit.edu> (message from James
Hugunin on Sun, 31 Mar 96 12:28:16 -0500)
Message-ID: <9603311933.AA06008@arnold.image.ivab.se>
but how do I get my hands at the most recent distribution?
cannot seem to get through to sls-ftp.lcs.mit.edu...
/F
--------------------------------------------------------------------
PS! The first version of the Python Imaging Library is now released!
Join the image-sig for more info!
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================
From jjh@Goldilocks.LCS.MIT.EDU Sun Mar 31 19:45:59 1996
From: jjh@Goldilocks.LCS.MIT.EDU (James Hugunin)
Date: Sun, 31 Mar 96 14:45:59 EST
Subject: [PYTHON MATRIX-SIG] Sorry to have to ask this question again...
Message-ID: <9603311945.AA05474@baribal.LCS.MIT.EDU.LCS.MIT.EDU>
Our group file server is down for some serious maintenence this weekend. It should be
back up by Monday morning.
(Good news about the imaging lib, I'll have to give it a try.)
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================