From rob at hooft.net Fri Dec 1 02:15:01 2000 From: rob at hooft.net (Rob W. W. Hooft) Date: Fri, 1 Dec 2000 08:15:01 +0100 Subject: [Numpy-discussion] (no subject) In-Reply-To: <200011301805.VAA04440@www.pob.ru> References: <200011301805.VAA04440@www.pob.ru> Message-ID: <14887.20469.811363.721988@temoleh.chem.uu.nl> >>>>> "s" == szport writes: s> Is the following definition faster or not? s> def ones(shape, typecode=\'l\', savespace=0): s> a = zeros( (product(shape),), typecode, savespace) s> a[:] = 1 s> a.shape = shape s> return a This is yet another way to write a[...]=1 manually via a small detour. For small arrays (size 10...1000) it is about twice slower than writing [...] (0.1ms slower per call on my workstation). Rob -- ===== rob at hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From pauldubois at home.com Fri Dec 1 17:26:41 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Fri, 1 Dec 2000 14:26:41 -0800 Subject: [Numpy-discussion] RE: [numpy - Help] Numeric-17.1.2.tar.gz missing In-Reply-To: <200011301722.JAA13740@sf-web3.vaspecialprojects.com> Message-ID: I succeeded in getting the file at 2 p.m. Friday Dec 1 Pacific Standard Time. I had received a similar report earlier in the day so I don't think you're crazy, just that something at SF was down. -----Original Message----- From: noreply at sourceforge.net [mailto:noreply at sourceforge.net] Sent: Thursday, November 30, 2000 9:23 AM To: noreply at sourceforge.net Subject: [numpy - Help] Numeric-17.1.2.tar.gz missing Read and respond to this message at: http://sourceforge.net/forum/message.php?msg_id=80631 By: vanandel There are no Numeric 17 tar files on http://download.sourceforge.net/numpy/ Could someone replace them? Thanks! ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge and visit: http://sourceforge.net/forum/monitor.php?forum_id=3848 From clee at gnwy100.wuh.wustl.edu Fri Dec 1 19:43:12 2000 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: Fri, 1 Dec 2000 18:43:12 -0600 (CST) Subject: [Numpy-discussion] matrixmultiply implementation Message-ID: <14888.17824.628721.21773@gnwy100.wuh.wustl.edu> I'm curious to see if anyone has looked at the implementation of dot/matrixmultiply recently. I was doing a benchmark lapack-based matrix inversion and was surprised to find that the accuracy check was taking longer than the inversion. The bottleneck was the matrix multiply. It appears that a blas dgemm implementation might give a large improvement. Here is a sample benchmark using PyLapack's dblas.dgemm for comparison. Results for a 1000 x 1000 matrix inversion: time elapsed for inverse (sec) 10.050768 time elapsed for matrixmultiply (sec) 24.142714 time elapsed for dgemm-matrixmultiply (sec) 5.997188 max error is: 3.30398486348e-10 Given the "dot" code doesn't look too bad, so I might be able to add dgemm support myself, at least for some cases. -chris p.s. I'll include the test code below ##################################### import time from Numeric import * from LinearAlgebra import * import dblas for N in [5,100, 1000]: a = reshape(arange(float(N*N)), (N,N)) + identity(N) # print "typecode of array is: ", a.typecode() start = time.time() inv_a = inverse(a) stop = time.time() # print inv_a startmult = time.time() b = matrixmultiply(a, inv_a) stopmult = time.time() residual = b - identity(N) #DGEMM(TRANSA, TRANSB, M, N, K, ALPHA,A, LDA, B, LDB, BETA,C,LDC) C = zeros(a.shape, a.typecode()) alpha = array([1.0]) beta = array([1.0]) startdgemm = time.time() dblas.dgemm('N','N', N,N,N, alpha, a,N, # A, LDA inv_a, N, # B, LDB beta, # BETA C, N) stopdgemm = time.time() # print C print "%d x %d matrix inversion" % (N,N) print "max error is:", print maximum.reduce(fabs(ravel(residual))) print "time elapsed for inverse (sec) %f" % (stop-start) print "time elapsed for matrixmultiply (sec) %f" % (stopmult-startmult) print "time elapsed for dgemm-matrixmultiply (sec) %f" % (stopdgemm-startdgemm) print From pauldubois at home.com Fri Dec 1 23:15:55 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Fri, 1 Dec 2000 20:15:55 -0800 Subject: [Numpy-discussion] matrixmultiply implementation In-Reply-To: <14888.17824.628721.21773@gnwy100.wuh.wustl.edu> Message-ID: Not to put a damper on anything, but it would be a big change to REQUIRE dgemm in the Numeric core. The issues we shunted aside to the subpackage would return. -----Original Message----- From: numpy-discussion-admin at lists.sourceforge.net [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Christopher Lee Sent: Friday, December 01, 2000 4:43 PM To: numpy-discussion at lists.sourceforge.net Subject: [Numpy-discussion] matrixmultiply implementation I'm curious to see if anyone has looked at the implementation of dot/matrixmultiply recently. I was doing a benchmark lapack-based matrix inversion and was surprised to find that the accuracy check was taking longer than the inversion. The bottleneck was the matrix multiply. It appears that a blas dgemm implementation might give a large improvement. Here is a sample benchmark using PyLapack's dblas.dgemm for comparison. Results for a 1000 x 1000 matrix inversion: time elapsed for inverse (sec) 10.050768 time elapsed for matrixmultiply (sec) 24.142714 time elapsed for dgemm-matrixmultiply (sec) 5.997188 max error is: 3.30398486348e-10 Given the "dot" code doesn't look too bad, so I might be able to add dgemm support myself, at least for some cases. -chris p.s. I'll include the test code below ##################################### import time from Numeric import * from LinearAlgebra import * import dblas for N in [5,100, 1000]: a = reshape(arange(float(N*N)), (N,N)) + identity(N) # print "typecode of array is: ", a.typecode() start = time.time() inv_a = inverse(a) stop = time.time() # print inv_a startmult = time.time() b = matrixmultiply(a, inv_a) stopmult = time.time() residual = b - identity(N) #DGEMM(TRANSA, TRANSB, M, N, K, ALPHA,A, LDA, B, LDB, BETA,C,LDC) C = zeros(a.shape, a.typecode()) alpha = array([1.0]) beta = array([1.0]) startdgemm = time.time() dblas.dgemm('N','N', N,N,N, alpha, a,N, # A, LDA inv_a, N, # B, LDB beta, # BETA C, N) stopdgemm = time.time() # print C print "%d x %d matrix inversion" % (N,N) print "max error is:", print maximum.reduce(fabs(ravel(residual))) print "time elapsed for inverse (sec) %f" % (stop-start) print "time elapsed for matrixmultiply (sec) %f" % (stopmult-startmult) print "time elapsed for dgemm-matrixmultiply (sec) %f" % (stopdgemm-startdgemm) print _______________________________________________ Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net http://lists.sourceforge.net/mailman/listinfo/numpy-discussion From dyoo at hkn.eecs.berkeley.edu Sun Dec 3 03:32:50 2000 From: dyoo at hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sun, 3 Dec 2000 00:32:50 -0800 (PST) Subject: [Numpy-discussion] Re: [Python-Help] Numeric bug, or my misunderstanding? In-Reply-To: Message-ID: On Fri, 1 Dec 2000, chad scherrer wrote: > >>> import Numeric > >>> def mod2(x): return x%2 > >>> apply(mod2, [-3]) > 1 > >>> apply(mod2, Numeric.array([-3])) > 1 > >>> apply(mod2, Numeric.array([[-3]])) > array([-1]) > > Should that not be array([1]) ? Hmmm. Good point; This looks weird to me too. You should probably talk to the Numeric Python people at the Numpy-discussion newsgroup: http://lists.sourceforge.net/mailman/listinfo/numpy-discussion I'll try to forward this message to that group, so perhaps they'll be able to figure out if it's a true bug. I hope that your answer will be answered quickly. Good luck! From doko at cs.tu-berlin.de Sun Dec 3 08:26:35 2000 From: doko at cs.tu-berlin.de (Matthias Klose) Date: Sun, 3 Dec 2000 14:26:35 +0100 (MET) Subject: [Numpy-discussion] numpy on alpha/64bit Message-ID: <14890.18955.508417.480268@gargle.gargle.HOWL> An embedded message was scrubbed... From: unknown sender Subject: no subject Date: no date Size: 38 URL: From chris at debian.org Fri Dec 1 19:58:50 2000 From: chris at debian.org (Christopher C. Chimelis) Date: Fri, 1 Dec 2000 19:58:50 -0500 (EST) Subject: Installed python-numeric 17.1.2-1 (all source i386) In-Reply-To: Message-ID: Doh, found a problem and am still trying to figure out what the best way to fix it is. In Src/arrayobject.c, starting at around line 70: int do_sliced_copy(char *dest, int *dest_strides, int *dest_dimensions, int dest_nd, char *src, int *src_strides, int *src_dimensions, int src_nd, int elsize, int copies) { int i, j; if (src_nd == 0 && dest_nd == 0) { switch(elsize) { case sizeof(char): memset(dest, *src, copies); break; case sizeof(short): for(j=copies; j; --j, dest += sizeof(short)) *(short*)dest = *(short*)src; break; case sizeof(long): for(j=copies; j; --j, dest += sizeof(int)) *(int*)dest = *(int*)src; break; case sizeof(double): for(j=copies; j; --j, dest += sizeof(double)) *(double*)dest = *(double*)src; break; default: for(j=copies; j; --j, dest += elsize) memcpy(dest, src, elsize); } return 0; } The problem is, that sizeof(long) = sizeof(double) on Alpha (and probably on the other 64-bit archs). So, what do you think the best method of handling this is? I don't know the package well anymore or else I'd fix it :-P C From dubois at users.sourceforge.net Tue Dec 5 19:03:01 2000 From: dubois at users.sourceforge.net (Paul F. Dubois) Date: Tue, 5 Dec 2000 16:03:01 -0800 Subject: [Numpy-discussion] RE: Numpy In-Reply-To: <200012052345.PAA25946@tc05.llnl.gov> Message-ID: This was a patch that I put in before making this release. If you get 17.1.1 it won't be in there. Developers -- I'm busy right now with the Python conference; can someone fix this for me and make a new distribution? -----Original Message----- From: Lila Chase [mailto:chase at tc05.llnl.gov] Sent: Tuesday, December 05, 2000 3:45 PM To: dubois1 at llnl.gov Subject: Numpy Paul, First attempt at installing Numeric Python on Teracluster; fails. Lila tc05:/usr/tmp/chase/Numeric-17.1.2[407] !393 python setup_all.py install running install running build running build_py not copying Lib/ArrayPrinter.py (output up-to-date) not copying Lib/Numeric.py (output up-to-date) not copying Lib/Precision.py (output up-to-date) not copying Lib/UserArray.py (output up-to-date) not copying Lib/numeric_version.py (output up-to-date) running build_ext building '_numpy' extension skipping Src/_numpymodule.c (build/temp.osf1-V4.0-alpha-2.0/Src/_numpymodule.o up-to-date) cc -O -Olimit 1500 -IInclude -I/g/g16/chase/include/python2.0 -c Src/arrayobject.c -o build/temp.osf1-V4.0-alpha-2.0/Src/arrayobject.o cc: Error: Src/arrayobject.c, line 79: The switch statement containing this case label already has a case label for "8". (dupcase) case sizeof(double): ------------^ error: command 'cc' failed with exit status 1 tc05:/usr/tmp/chase/Numeric-17.1.2[408] int do_sliced_copy(char *dest, int *dest_strides, int *dest_dimensions, int dest_nd, char *src, int *src_strides, int *src_dimensions, int src_nd, int elsize, int copies) { int i, j; if (src_nd == 0 && dest_nd == 0) { switch(elsize) { case sizeof(char): memset(dest, *src, copies); break; case sizeof(short): for(j=copies; j; --j, dest += sizeof(short)) *(short*)dest = *(short*)src; break; case sizeof(long): for(j=copies; j; --j, dest += sizeof(int)) *(int*)dest = *(int*)src; break; case sizeof(double): for(j=copies; j; --j, dest += sizeof(double)) *(double*)dest = *(double*)src; break; default: for(j=copies; j; --j, dest += elsize) memcpy(dest, src, elsize); } return 0; } From rlw at stsci.edu Wed Dec 6 07:51:21 2000 From: rlw at stsci.edu (rlw at stsci.edu) Date: Wed, 6 Dec 2000 07:51:21 -0500 (EST) Subject: [Numpy-discussion] RE: Numpy Message-ID: <200012061251.HAA27408@sundog.stsci.edu> A suggestion for an easy way to fix this problem: use float instead of long. Presumably floats are always 4 bytes. Rick Paul Dubois writes: >This was a patch that I put in before making this release. If you get 17.1.1 >it won't be in there. > > [...] > >cc: Error: Src/arrayobject.c, line 79: The switch statement containing this >case label already has a case label for "8". (dupcase) > case sizeof(double): >------------^ >error: command 'cc' failed with exit status 1 >tc05:/usr/tmp/chase/Numeric-17.1.2[408] > > >int do_sliced_copy(char *dest, int *dest_strides, int *dest_dimensions, > int dest_nd, char *src, int *src_strides, > int *src_dimensions, int src_nd, int elsize, > int copies) { > int i, j; > > if (src_nd == 0 && dest_nd == 0) { > switch(elsize) { > case sizeof(char): > memset(dest, *src, copies); > break; > case sizeof(short): > for(j=copies; j; --j, dest += sizeof(short)) > *(short*)dest = *(short*)src; > break; > case sizeof(long): > for(j=copies; j; --j, dest += sizeof(int)) > *(int*)dest = *(int*)src; > break; > case sizeof(double): > for(j=copies; j; --j, dest += sizeof(double)) > *(double*)dest = *(double*)src; > break; > default: > for(j=copies; j; --j, dest += elsize) > memcpy(dest, src, elsize); > } > return 0; > } From taylor at rhino.llnl.gov Wed Dec 6 13:22:17 2000 From: taylor at rhino.llnl.gov (Lee Taylor) Date: Wed, 6 Dec 2000 10:22:17 -0800 (PST) Subject: [Numpy-discussion] RE: Numpy In-Reply-To: <200012061251.HAA27408@sundog.stsci.edu> Message-ID: I think a more portable solution is to just make it all an if statement. I'm not comfortable with presuming that floats are always 4 bytes. if (src_nd == 0 && dest_nd == 0) { if (elsize == sizeof(char)) { memset(dest, *src, copies); } else if (elsize == sizeof(short)) { for(j=copies; j; --j, dest += sizeof(short)) *(short*)dest = *(short*)src; } else if (elsize == sizeof(int)) { for(j=copies; j; --j, dest += sizeof(int)) *(int*)dest = *(int*)src; } else if (elsize == sizeof(long)) { for(j=copies; j; --j, dest += sizeof(long)) *(long*)dest = *(long*)src; } else if (elsize == sizeof(float)) { for(j=copies; j; --j, dest += sizeof(float)) *(float*)dest = *(float*)src; } else if (elsize == sizeof(double)) { for(j=copies; j; --j, dest += sizeof(double)) *(double*)dest = *(double*)src; } else { for(j=copies; j; --j, dest += elsize) memcpy(dest, src, elsize); } I've thrown in the int and float cases to make sure we cover every machine that may be out there. Lee Taylor On Wed, 6 Dec 2000 rlw at stsci.edu wrote: > A suggestion for an easy way to fix this problem: use float instead of > long. Presumably floats are always 4 bytes. > Rick > > Paul Dubois writes: > > >This was a patch that I put in before making this release. If you get 17.1.1 > >it won't be in there. > > > > [...] > > > >cc: Error: Src/arrayobject.c, line 79: The switch statement containing this > >case label already has a case label for "8". (dupcase) > > case sizeof(double): > >------------^ > >error: command 'cc' failed with exit status 1 > >tc05:/usr/tmp/chase/Numeric-17.1.2[408] > > > > > >int do_sliced_copy(char *dest, int *dest_strides, int *dest_dimensions, > > int dest_nd, char *src, int *src_strides, > > int *src_dimensions, int src_nd, int elsize, > > int copies) { > > int i, j; > > > > if (src_nd == 0 && dest_nd == 0) { > > switch(elsize) { > > case sizeof(char): > > memset(dest, *src, copies); > > break; > > case sizeof(short): > > for(j=copies; j; --j, dest += sizeof(short)) > > *(short*)dest = *(short*)src; > > break; > > case sizeof(long): > > for(j=copies; j; --j, dest += sizeof(int)) > > *(int*)dest = *(int*)src; > > break; > > case sizeof(double): > > for(j=copies; j; --j, dest += sizeof(double)) > > *(double*)dest = *(double*)src; > > break; > > default: > > for(j=copies; j; --j, dest += elsize) > > memcpy(dest, src, elsize); > > } > > return 0; > > } > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/mailman/listinfo/numpy-discussion > From rlw at stsci.edu Wed Dec 6 14:26:55 2000 From: rlw at stsci.edu (rlw at stsci.edu) Date: Wed, 6 Dec 2000 14:26:55 -0500 (EST) Subject: [Numpy-discussion] RE: Numpy Message-ID: <200012061926.OAA01657@sundog.stsci.edu> >From taylor at rhino.llnl.gov Wed Dec 6 13:23 EST 2000 > >I think a more portable solution is to just make it all an if statement. >I'm not comfortable with presuming that floats are always 4 bytes. I agree -- I also had the thought of changing to an if statement after I sent my mail. Much better than the switch since it can't break. >I've thrown in the int and float cases to make sure we cover every >machine that may be out there. I suspect that if float is 8 bytes then int will be too. Just char, short, float, and double should suffice. If the 4-byte version is missing it will just fall back on the default (slower but otherwise OK), and if the C compiler doesn't support shorter data items then probably the user won't be using them anyway... Rick White From Oliphant.Travis at mayo.edu Wed Dec 6 14:55:27 2000 From: Oliphant.Travis at mayo.edu (Travis Oliphant) Date: Wed, 6 Dec 2000 13:55:27 -0600 (CST) Subject: [Numpy-developers] Re: [Numpy-discussion] RE: Numpy In-Reply-To: <200012061926.OAA01657@sundog.stsci.edu> Message-ID: > I agree -- I also had the thought of changing to an if statement after > I sent my mail. Much better than the switch since it can't break. I took the liberty to change this in the CVS tree. (I haven't been very active lately and wanted to help in some way.) I haven't released a new version with the change, though. -Travis From dubois1 at llnl.gov Wed Dec 6 17:58:40 2000 From: dubois1 at llnl.gov (Paul F. Dubois) Date: Wed, 6 Dec 2000 14:58:40 -0800 Subject: [Numpy-discussion] Bug in MA Message-ID: <00120615025300.09688@almanac> It has come to my attention that the Masked Array package, MA, has a rather severe bug. The bug occurs when doing a mixed scalar/array operation in which the array has its first element masked. The bug causes the value computed by this operation to be wrong. I should have a fix for this problem shortly but since this bug is so severe I thought I should put out a warning immediately. This bug was introduced a few versions ago. From pauldubois at home.com Mon Dec 11 13:33:03 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Mon, 11 Dec 2000 10:33:03 -0800 Subject: [Numpy-discussion] CVS updated but cannot release 17.2.0 Message-ID: I have CVS updated with fixes to MA, and the optimization for ones, etc. I can't release the files because they lost the upload server that does that and until they get the replacement online there are no new file releases. Developers, there are bug reports for FFT and savespace that need attention from the corresponding experts. The patch list is clear. We have completed the refereed papers program for IPC9 and it will be released shortly after notification of authors. The program is quite good, plus there are tutorials and two other tracks. I encourage all Nummies to attend (March, Long Beach CA; see python9.org). Registration has just opened. From pih at oek.dk Tue Dec 12 09:01:01 2000 From: pih at oek.dk (Peter I. Hansen) Date: Tue, 12 Dec 2000 15:01:01 +0100 Subject: [Numpy-discussion] matrix file format Message-ID: <3A362F9D.AF9CF722@oek.dk> Hi, I'm trying to find out what format a matrix input file should have in numpy. example : I have the matrix : [[1 2 3 4 5 6 7 8 9]] and want to read it to nympy from a text-filen that is easy for a user to generate in an editor. Can you tell me how to do that. I read the manual and it didn?t given much af on idea. I thank you in advance Peter I. Hansen From jhauser at ifm.uni-kiel.de Tue Dec 12 09:11:10 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: Tue, 12 Dec 2000 15:11:10 +0100 (CET) Subject: [Numpy-discussion] matrix file format In-Reply-To: <3A362F9D.AF9CF722@oek.dk> References: <3A362F9D.AF9CF722@oek.dk> Message-ID: <20001212141110.4559.qmail@lisboa.ifm.uni-kiel.de> In principle there is no such format in the sense of other numerical environments. But it is possible to simple put the data into a python module and import that, like # Datafile data.py import Numeric data=Numeric.array([[1,2,3],[4,5,6],[7,8,9]]) # in python (other module or interactive session) from data import data print data HTH __Janko Peter I. Hansen writes: > Hi, > > I'm trying to find out what format a matrix input file should have in > numpy. > example : > > I have the matrix : > [[1 2 3 > 4 5 6 > 7 8 9]] > > and want to read it to nympy from a text-filen that is easy for a user > to generate in an editor. > > Can you tell me how to do that. I read the manual and it didn?t given > much af on idea. > > I thank you in advance > > Peter I. Hansen > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/mailman/listinfo/numpy-discussion From clee at gnwy100.wuh.wustl.edu Tue Dec 12 12:03:26 2000 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: Tue, 12 Dec 2000 11:03:26 -0600 (CST) Subject: [Numpy-discussion] matrix file format In-Reply-To: <3A362F9D.AF9CF722@oek.dk> References: <3A362F9D.AF9CF722@oek.dk> Message-ID: <14902.23134.68820.562930@gnwy100.wuh.wustl.edu> You have many options: I frequently use Konrad Hinsen's "Scientific" package (http://dirac.cnrs-orleans.fr/programs/scientific.html). It make importing files from user input or other packages like matlab easy and supports several file formats. The simpliest is a basic white-space-delimitted text file if you have a text file "arrayfile.txt" that looks like this: # arrayfile.txt (lines beginning with '#' are ignored) 1 2 3 4 5 6 6 8 9 You can fire up python and read in your matrix like this: >>> from Scientific.IO.ArrayIO import readArray >>> A = readArray('arrayfile.txt') >>> print A [[1 2 3] [4 5 6] [6 8 9]] From hinsen at cnrs-orleans.fr Tue Dec 12 13:20:24 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: Tue, 12 Dec 2000 19:20:24 +0100 Subject: [Numpy-discussion] matrix file format In-Reply-To: <3A362F9D.AF9CF722@oek.dk> (pih@oek.dk) References: <3A362F9D.AF9CF722@oek.dk> Message-ID: <200012121820.TAA14096@chinon.cnrs-orleans.fr> > I'm trying to find out what format a matrix input file should have in > numpy. Any format you like, but you have to supply the I/O code yourself. Which however is really simple. For example, the following function from ScientificPython: from Scientific.IO.TextFile import TextFile import string, Numeric def readArray(filename): "Return an array containing the data from file |filename|." data = [] for line in TextFile(filename): if line[0] != '#': data.append(map(eval, string.split(line))) a = Numeric.array(data) if a.shape[0] == 1 or a.shape[1] == 1: a = Numeric.ravel(a) return a Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From su96-fst at nada.kth.se Wed Dec 13 07:24:14 2000 From: su96-fst at nada.kth.se (Fredrik Stenberg) Date: Wed, 13 Dec 2000 13:24:14 +0100 (MET) Subject: [Numpy-discussion] Tutorial in Numerical Python? (fwd) Message-ID: Hi, I took the liberty to forward your email to numpy-discussion at lists.sourceforge.net. The only document i know of is located at the Python homepage http://numpy.sourceforge.net. /fredrik ---------- Forwarded message ---------- Date: 13 Dec 2000 11:27:08 +0000 From: Jos? Luis G?mez Dans Newsgroups: comp.lang.python Subject: Tutorial in Numerical Python? Hi, I am wondering whether such a thing exists. Is there a nice tutorial for NumPy that guides you through the basic steps? Say, a little hands-on introduction to Linear Algebra, Transforms and possibly the inclusion of some of the graphic modules? There are some willing students to be converted around these parts, and a hands-on tutorial would be great. Unfortunately, I am a beginner in these waters myself, but can see the opportunity for this. Thanks in advance, Jos? -- Jos? L G?mez Dans PhD student Tel: +44 114 222 5582 Radar & Communications Group FAX; +44 870 132 2990 Department of Electronic Engineering University of Sheffield UK From Herbert.W.Schilling at grc.nasa.gov Wed Dec 13 09:06:08 2000 From: Herbert.W.Schilling at grc.nasa.gov (Herb Schilling) Date: Wed, 13 Dec 2000 10:06:08 -0400 Subject: [Numpy-discussion] Tutorial in Numerical Python? (fwd) In-Reply-To: References: Message-ID: >---------- Forwarded message ---------- >Date: 13 Dec 2000 11:27:08 +0000 >From: Jos? Luis G?mez Dans >Newsgroups: comp.lang.python >Subject: Tutorial in Numerical Python? > > >Hi, > I am wondering whether such a thing exists. Is there a nice >tutorial for NumPy that guides you through the basic steps? Say, a >little hands-on introduction to Linear Algebra, Transforms and >possibly the inclusion of some of the graphic modules? Hi, Take a look at: -- --------------------------------- Herb Schilling NASA Glenn Research Center Cleveland, OH 44135 Herbert.W.Schilling at grc.nasa.gov If all our misfortunes were laid in one common heap whence everyone must take an equal portion, most people would be contented to take their own and depart. -Socrates (469?-399 B.C.) From pauldubois at home.com Wed Dec 13 19:24:13 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Wed, 13 Dec 2000 16:24:13 -0800 Subject: [Numpy-discussion] 17.2.0 Message-ID: I uploaded Numeric 17.2.0 but then got errors from Sourceforge's web pages for actually releasing it. I'm going to wait a day or two and try again. I may be forced to renumber around the one that is already there. I don't think users can actually see this file yet. CVS is up to date with what will become 17.2.? when I finally succeed. From anthony.seward at ieee.org Sun Dec 17 11:06:44 2000 From: anthony.seward at ieee.org (Tony Seward) Date: Sun, 17 Dec 2000 09:06:44 -0700 (MST) Subject: [Numpy-discussion] Numpy doesn't build properly Message-ID: Because the Numpy sub-packages use '#include "Numeric/arratobject.h", the Numeric package will not build from scratch. This may not matter if one does a 'python setup_all.py install' as long as the base Numeric package is installed before the sub-packages are built. I don't think that this is what setup_all.py does because the core setup.py is called with no arguments. In any case, I'm trying to build RPMs and the build and install processes are seperated. In order to build the packages seprately I am now putting a symbolic link in each package's Include directory called Numeric that points to the Include directory for the core package. I would like to suggest that the core header files be put in a directory 'Include/Numeric' rather than directly in 'Include'. That way the header file locations more acurately mirror the way that they are installed. Tony From pfenn at mmm.com Thu Dec 21 15:52:03 2000 From: pfenn at mmm.com (pfenn at mmm.com) Date: Thu, 21 Dec 2000 14:52:03 -0600 Subject: [Numpy-discussion] CXX versions Message-ID: Hi, I'm playing around with CXX because I'm going to be writing an extension in the next few days. I'm on WinNT running Microsoft Visual C++ 6.0 with service pack 3 installed. Also, Python 2.0. I've gotten all of CXX-5.0b to compile, and I compiled the demo. This required a slight edit of cxx_extensions.cxx which was documented in the SourceForge buglist for CXX. I was pleasantly surprised that VC++ was able to compile this code. However, when I import CXX.example python crashes. Is this a known problem, is there a workaround, or should I try CXX-4.2 instead? For some reason, I am really adverse to writing another extension using C. Tom Fenn From pauldubois at home.com Thu Dec 28 23:39:19 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Thu, 28 Dec 2000 20:39:19 -0800 Subject: [Numpy-discussion] Happy New Year Nummies -- and some discussion about the future In-Reply-To: Message-ID: A millenium-end report from the Head Nummie (this name is a joke; see the DEVELOPERS file): There have been a steady set of messages on the subject of I should do this or that to make it easier to make RPMs. It is impossible for me to act on these: I don't know much about RPMs, and if I did, I don't know if making the change suggested is good or bad for someone doing something else, like making Windows installers. Therefore my policy is to rely on the Distutils people to work this out. Those who wish to make it easier to make a binary installer for platform xyz should figure out what would be required by the Distutils bdist family of commands. That is not to say that I don't appreciate people trying to help. I'm grateful for all the support I get from the community. I think that relying on division of labor in this case is the right thing to do, so that we take advantage of the Distutils effort. If I'm wrong, I'll listen. There are a number of bug reports on the sourceforge site. I would be grateful for patches. In particular there are two reports dealing with FFTs. I lack the expertise to deal with these. The masked array package MA has been getting more of a workout as I put it into production at my site. I believe that it fills not only the immediate need for dealing with missing values, but can serve as a model for how to make a "Numeric-workalike" with extra properties, since we can't inherit from Numeric's array. Since MA is improved fairly often, I recommend keeping up via cvs if you are a user. I have new manuals but have had difficulty with the transport up to SourceForge. Anybody else having such a problem? I used scp from a Linux box and it sat there and didn't do anything. The rest of this is for developers. Actually, once you get into it, it isn't all that clear that inheritance would help very much. For example, suppose you want an array class F that has masked values but also has a special behavior f() controlled by a parameter set at creation, beta. Suppose therefore you decide to inherit from class MA. Thus the constructor of your new class must take the same arguments as an MA array but add a beta=somedefault. OK, we do that. Now we can construct a couple of F's: f1 = F([1.,2.,3.], beta=1.) f2 = F([4.,2.,1.], beta=2.) Great. Now we can do f1.f(), f2.f(). Maybe we redefine __str__ so we can print beta when we print f1. Now try to do something. Anything. Say, f3 = f1 + f2 Oops. f3 is an MA, not an F. We might have written __add__ in MA so the it used self.__class__ to construct the answer. But since the constructor now needs a new parameter, there is no way MA.__add__ can make an F. It doesn't know how. Doesn't know how to call F(), doesn't know what value to use for beta anyway. So now we redefine all the methods in MA. Besides muttering that maybe inheriting didn't buy me a lot, I am still nowhere, for the next thing I realize is that every function f(a) that takes an MA as an argument and returns an MA, still returns an MA. If any of these make sense for an instance of F, I have to replace them, just as MA replaced sin, cos, sqrt, take, etc. from Numeric. I have therefore come to the conclusion that we have been barking up the wrong tree. There might be a few cases where inheritance would buy you something, but essentially Numeric and MA are useless as parents. Instead, what would be good to have is a python class Numeric built upon a suite of C routines that did all the real work, such as adding, transposing, iterating over elements, applying a function to each element, etc. Since it is now possible to build a Python class with C methods, which it was not when Numeric was created, we ought to think about it. Such an API could be used to make other classes with good performance. We could lose the artificial layer that is in there now that makes it so tedious to add a function. (I counted something like five or six places I had to modify when I added "put".) Best regards to all, Paul Dubois From pauldubois at home.com Fri Dec 29 14:23:43 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Fri, 29 Dec 2000 11:23:43 -0800 Subject: [Numpy-discussion] Documentation updated Message-ID: Sorry this is in HTML, but the documentation below requires it. The latest source release is 17.2.0. Revised documentation in HTML and PDF is available at http://numpy.sourceforge.net. Package MA contains a number of new constructors. The complete list is: Constructing masked arrays 1.. array (data, typecode = None, copy = 1, savespace = 0, mask = None, fill_value = None) creates a masked array with the given data and mask. The name array is simply an alias for the class name, MA. This constructor sets the data area of the resulting masked array to filled (data, value = fill_value, copy = copy, savespace = savespace), the mask to make_mask (mask, savespace), and the fill value is set to fill_value. The class name MA may also be used instead of the name array. 2.. masked_array (data, mask = None, fill_value = None) is an easier to use version of array, for the common case of typecode = None, copy = 0. When data is newly-created this function can be used to make it a masked array without copying the data if data is already a Numeric array. 3.. masked_values (data, value, rtol=1.e-5, atol=1.e-8, typecode = None, copy = 1, savespace = 0) constructs a masked array whose mask is set at those places where abs (data - value) < atol + rtol * abs (data). That is a careful way of saying that those elements of the data that have value = value (to within a tolerance) are to be treated as invalid. 4.. masked_object (data, value, copy=1, savespace=0) creates a masked array with those entries marked invalid that are equal to value. Again, copy and savespace are passed on to the Numeric array constructor. 5.. masked_where (condition, data) creates a masked array whose shape is that of condition, whose values are those of data, and which is masked where elements of condition are true. 6.. masked_greater (data, value) is equivalent to masked_where (greater(data, value), data)). Similarly, masked_greater_equal, masked_equal, masked_not_equal, masked_less, masked_less_equal are called in the same way with the obvious meanings. Note that for floating point data, masked_values is preferable to masked_equal in most cases. On entry to any of these constructors, data must be any object which the Numeric package can accept to create an array (with the desired typecode, if specified). The mask if given must be None or any object that can be turned into a Numeric array of integer type (it will be converted to typecode MaskType, if necessary), have the same shape as data, and contain only values of 0 or 1. If the mask is not None but its shape does not match that of data, an exception will be thrown, unless one of the two is of length 1, in which case the scalar will be resized (using Numeric.resize) to match the other. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rob at hooft.net Fri Dec 1 02:15:01 2000 From: rob at hooft.net (Rob W. W. Hooft) Date: Fri, 1 Dec 2000 08:15:01 +0100 Subject: [Numpy-discussion] (no subject) In-Reply-To: <200011301805.VAA04440@www.pob.ru> References: <200011301805.VAA04440@www.pob.ru> Message-ID: <14887.20469.811363.721988@temoleh.chem.uu.nl> >>>>> "s" == szport writes: s> Is the following definition faster or not? s> def ones(shape, typecode=\'l\', savespace=0): s> a = zeros( (product(shape),), typecode, savespace) s> a[:] = 1 s> a.shape = shape s> return a This is yet another way to write a[...]=1 manually via a small detour. For small arrays (size 10...1000) it is about twice slower than writing [...] (0.1ms slower per call on my workstation). Rob -- ===== rob at hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From pauldubois at home.com Fri Dec 1 17:26:41 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Fri, 1 Dec 2000 14:26:41 -0800 Subject: [Numpy-discussion] RE: [numpy - Help] Numeric-17.1.2.tar.gz missing In-Reply-To: <200011301722.JAA13740@sf-web3.vaspecialprojects.com> Message-ID: I succeeded in getting the file at 2 p.m. Friday Dec 1 Pacific Standard Time. I had received a similar report earlier in the day so I don't think you're crazy, just that something at SF was down. -----Original Message----- From: noreply at sourceforge.net [mailto:noreply at sourceforge.net] Sent: Thursday, November 30, 2000 9:23 AM To: noreply at sourceforge.net Subject: [numpy - Help] Numeric-17.1.2.tar.gz missing Read and respond to this message at: http://sourceforge.net/forum/message.php?msg_id=80631 By: vanandel There are no Numeric 17 tar files on http://download.sourceforge.net/numpy/ Could someone replace them? Thanks! ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge and visit: http://sourceforge.net/forum/monitor.php?forum_id=3848 From clee at gnwy100.wuh.wustl.edu Fri Dec 1 19:43:12 2000 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: Fri, 1 Dec 2000 18:43:12 -0600 (CST) Subject: [Numpy-discussion] matrixmultiply implementation Message-ID: <14888.17824.628721.21773@gnwy100.wuh.wustl.edu> I'm curious to see if anyone has looked at the implementation of dot/matrixmultiply recently. I was doing a benchmark lapack-based matrix inversion and was surprised to find that the accuracy check was taking longer than the inversion. The bottleneck was the matrix multiply. It appears that a blas dgemm implementation might give a large improvement. Here is a sample benchmark using PyLapack's dblas.dgemm for comparison. Results for a 1000 x 1000 matrix inversion: time elapsed for inverse (sec) 10.050768 time elapsed for matrixmultiply (sec) 24.142714 time elapsed for dgemm-matrixmultiply (sec) 5.997188 max error is: 3.30398486348e-10 Given the "dot" code doesn't look too bad, so I might be able to add dgemm support myself, at least for some cases. -chris p.s. I'll include the test code below ##################################### import time from Numeric import * from LinearAlgebra import * import dblas for N in [5,100, 1000]: a = reshape(arange(float(N*N)), (N,N)) + identity(N) # print "typecode of array is: ", a.typecode() start = time.time() inv_a = inverse(a) stop = time.time() # print inv_a startmult = time.time() b = matrixmultiply(a, inv_a) stopmult = time.time() residual = b - identity(N) #DGEMM(TRANSA, TRANSB, M, N, K, ALPHA,A, LDA, B, LDB, BETA,C,LDC) C = zeros(a.shape, a.typecode()) alpha = array([1.0]) beta = array([1.0]) startdgemm = time.time() dblas.dgemm('N','N', N,N,N, alpha, a,N, # A, LDA inv_a, N, # B, LDB beta, # BETA C, N) stopdgemm = time.time() # print C print "%d x %d matrix inversion" % (N,N) print "max error is:", print maximum.reduce(fabs(ravel(residual))) print "time elapsed for inverse (sec) %f" % (stop-start) print "time elapsed for matrixmultiply (sec) %f" % (stopmult-startmult) print "time elapsed for dgemm-matrixmultiply (sec) %f" % (stopdgemm-startdgemm) print From pauldubois at home.com Fri Dec 1 23:15:55 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Fri, 1 Dec 2000 20:15:55 -0800 Subject: [Numpy-discussion] matrixmultiply implementation In-Reply-To: <14888.17824.628721.21773@gnwy100.wuh.wustl.edu> Message-ID: Not to put a damper on anything, but it would be a big change to REQUIRE dgemm in the Numeric core. The issues we shunted aside to the subpackage would return. -----Original Message----- From: numpy-discussion-admin at lists.sourceforge.net [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Christopher Lee Sent: Friday, December 01, 2000 4:43 PM To: numpy-discussion at lists.sourceforge.net Subject: [Numpy-discussion] matrixmultiply implementation I'm curious to see if anyone has looked at the implementation of dot/matrixmultiply recently. I was doing a benchmark lapack-based matrix inversion and was surprised to find that the accuracy check was taking longer than the inversion. The bottleneck was the matrix multiply. It appears that a blas dgemm implementation might give a large improvement. Here is a sample benchmark using PyLapack's dblas.dgemm for comparison. Results for a 1000 x 1000 matrix inversion: time elapsed for inverse (sec) 10.050768 time elapsed for matrixmultiply (sec) 24.142714 time elapsed for dgemm-matrixmultiply (sec) 5.997188 max error is: 3.30398486348e-10 Given the "dot" code doesn't look too bad, so I might be able to add dgemm support myself, at least for some cases. -chris p.s. I'll include the test code below ##################################### import time from Numeric import * from LinearAlgebra import * import dblas for N in [5,100, 1000]: a = reshape(arange(float(N*N)), (N,N)) + identity(N) # print "typecode of array is: ", a.typecode() start = time.time() inv_a = inverse(a) stop = time.time() # print inv_a startmult = time.time() b = matrixmultiply(a, inv_a) stopmult = time.time() residual = b - identity(N) #DGEMM(TRANSA, TRANSB, M, N, K, ALPHA,A, LDA, B, LDB, BETA,C,LDC) C = zeros(a.shape, a.typecode()) alpha = array([1.0]) beta = array([1.0]) startdgemm = time.time() dblas.dgemm('N','N', N,N,N, alpha, a,N, # A, LDA inv_a, N, # B, LDB beta, # BETA C, N) stopdgemm = time.time() # print C print "%d x %d matrix inversion" % (N,N) print "max error is:", print maximum.reduce(fabs(ravel(residual))) print "time elapsed for inverse (sec) %f" % (stop-start) print "time elapsed for matrixmultiply (sec) %f" % (stopmult-startmult) print "time elapsed for dgemm-matrixmultiply (sec) %f" % (stopdgemm-startdgemm) print _______________________________________________ Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net http://lists.sourceforge.net/mailman/listinfo/numpy-discussion From dyoo at hkn.eecs.berkeley.edu Sun Dec 3 03:32:50 2000 From: dyoo at hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sun, 3 Dec 2000 00:32:50 -0800 (PST) Subject: [Numpy-discussion] Re: [Python-Help] Numeric bug, or my misunderstanding? In-Reply-To: Message-ID: On Fri, 1 Dec 2000, chad scherrer wrote: > >>> import Numeric > >>> def mod2(x): return x%2 > >>> apply(mod2, [-3]) > 1 > >>> apply(mod2, Numeric.array([-3])) > 1 > >>> apply(mod2, Numeric.array([[-3]])) > array([-1]) > > Should that not be array([1]) ? Hmmm. Good point; This looks weird to me too. You should probably talk to the Numeric Python people at the Numpy-discussion newsgroup: http://lists.sourceforge.net/mailman/listinfo/numpy-discussion I'll try to forward this message to that group, so perhaps they'll be able to figure out if it's a true bug. I hope that your answer will be answered quickly. Good luck! From doko at cs.tu-berlin.de Sun Dec 3 08:26:35 2000 From: doko at cs.tu-berlin.de (Matthias Klose) Date: Sun, 3 Dec 2000 14:26:35 +0100 (MET) Subject: [Numpy-discussion] numpy on alpha/64bit Message-ID: <14890.18955.508417.480268@gargle.gargle.HOWL> An embedded message was scrubbed... From: unknown sender Subject: no subject Date: no date Size: 38 URL: From chris at debian.org Fri Dec 1 19:58:50 2000 From: chris at debian.org (Christopher C. Chimelis) Date: Fri, 1 Dec 2000 19:58:50 -0500 (EST) Subject: Installed python-numeric 17.1.2-1 (all source i386) In-Reply-To: Message-ID: Doh, found a problem and am still trying to figure out what the best way to fix it is. In Src/arrayobject.c, starting at around line 70: int do_sliced_copy(char *dest, int *dest_strides, int *dest_dimensions, int dest_nd, char *src, int *src_strides, int *src_dimensions, int src_nd, int elsize, int copies) { int i, j; if (src_nd == 0 && dest_nd == 0) { switch(elsize) { case sizeof(char): memset(dest, *src, copies); break; case sizeof(short): for(j=copies; j; --j, dest += sizeof(short)) *(short*)dest = *(short*)src; break; case sizeof(long): for(j=copies; j; --j, dest += sizeof(int)) *(int*)dest = *(int*)src; break; case sizeof(double): for(j=copies; j; --j, dest += sizeof(double)) *(double*)dest = *(double*)src; break; default: for(j=copies; j; --j, dest += elsize) memcpy(dest, src, elsize); } return 0; } The problem is, that sizeof(long) = sizeof(double) on Alpha (and probably on the other 64-bit archs). So, what do you think the best method of handling this is? I don't know the package well anymore or else I'd fix it :-P C From dubois at users.sourceforge.net Tue Dec 5 19:03:01 2000 From: dubois at users.sourceforge.net (Paul F. Dubois) Date: Tue, 5 Dec 2000 16:03:01 -0800 Subject: [Numpy-discussion] RE: Numpy In-Reply-To: <200012052345.PAA25946@tc05.llnl.gov> Message-ID: This was a patch that I put in before making this release. If you get 17.1.1 it won't be in there. Developers -- I'm busy right now with the Python conference; can someone fix this for me and make a new distribution? -----Original Message----- From: Lila Chase [mailto:chase at tc05.llnl.gov] Sent: Tuesday, December 05, 2000 3:45 PM To: dubois1 at llnl.gov Subject: Numpy Paul, First attempt at installing Numeric Python on Teracluster; fails. Lila tc05:/usr/tmp/chase/Numeric-17.1.2[407] !393 python setup_all.py install running install running build running build_py not copying Lib/ArrayPrinter.py (output up-to-date) not copying Lib/Numeric.py (output up-to-date) not copying Lib/Precision.py (output up-to-date) not copying Lib/UserArray.py (output up-to-date) not copying Lib/numeric_version.py (output up-to-date) running build_ext building '_numpy' extension skipping Src/_numpymodule.c (build/temp.osf1-V4.0-alpha-2.0/Src/_numpymodule.o up-to-date) cc -O -Olimit 1500 -IInclude -I/g/g16/chase/include/python2.0 -c Src/arrayobject.c -o build/temp.osf1-V4.0-alpha-2.0/Src/arrayobject.o cc: Error: Src/arrayobject.c, line 79: The switch statement containing this case label already has a case label for "8". (dupcase) case sizeof(double): ------------^ error: command 'cc' failed with exit status 1 tc05:/usr/tmp/chase/Numeric-17.1.2[408] int do_sliced_copy(char *dest, int *dest_strides, int *dest_dimensions, int dest_nd, char *src, int *src_strides, int *src_dimensions, int src_nd, int elsize, int copies) { int i, j; if (src_nd == 0 && dest_nd == 0) { switch(elsize) { case sizeof(char): memset(dest, *src, copies); break; case sizeof(short): for(j=copies; j; --j, dest += sizeof(short)) *(short*)dest = *(short*)src; break; case sizeof(long): for(j=copies; j; --j, dest += sizeof(int)) *(int*)dest = *(int*)src; break; case sizeof(double): for(j=copies; j; --j, dest += sizeof(double)) *(double*)dest = *(double*)src; break; default: for(j=copies; j; --j, dest += elsize) memcpy(dest, src, elsize); } return 0; } From rlw at stsci.edu Wed Dec 6 07:51:21 2000 From: rlw at stsci.edu (rlw at stsci.edu) Date: Wed, 6 Dec 2000 07:51:21 -0500 (EST) Subject: [Numpy-discussion] RE: Numpy Message-ID: <200012061251.HAA27408@sundog.stsci.edu> A suggestion for an easy way to fix this problem: use float instead of long. Presumably floats are always 4 bytes. Rick Paul Dubois writes: >This was a patch that I put in before making this release. If you get 17.1.1 >it won't be in there. > > [...] > >cc: Error: Src/arrayobject.c, line 79: The switch statement containing this >case label already has a case label for "8". (dupcase) > case sizeof(double): >------------^ >error: command 'cc' failed with exit status 1 >tc05:/usr/tmp/chase/Numeric-17.1.2[408] > > >int do_sliced_copy(char *dest, int *dest_strides, int *dest_dimensions, > int dest_nd, char *src, int *src_strides, > int *src_dimensions, int src_nd, int elsize, > int copies) { > int i, j; > > if (src_nd == 0 && dest_nd == 0) { > switch(elsize) { > case sizeof(char): > memset(dest, *src, copies); > break; > case sizeof(short): > for(j=copies; j; --j, dest += sizeof(short)) > *(short*)dest = *(short*)src; > break; > case sizeof(long): > for(j=copies; j; --j, dest += sizeof(int)) > *(int*)dest = *(int*)src; > break; > case sizeof(double): > for(j=copies; j; --j, dest += sizeof(double)) > *(double*)dest = *(double*)src; > break; > default: > for(j=copies; j; --j, dest += elsize) > memcpy(dest, src, elsize); > } > return 0; > } From taylor at rhino.llnl.gov Wed Dec 6 13:22:17 2000 From: taylor at rhino.llnl.gov (Lee Taylor) Date: Wed, 6 Dec 2000 10:22:17 -0800 (PST) Subject: [Numpy-discussion] RE: Numpy In-Reply-To: <200012061251.HAA27408@sundog.stsci.edu> Message-ID: I think a more portable solution is to just make it all an if statement. I'm not comfortable with presuming that floats are always 4 bytes. if (src_nd == 0 && dest_nd == 0) { if (elsize == sizeof(char)) { memset(dest, *src, copies); } else if (elsize == sizeof(short)) { for(j=copies; j; --j, dest += sizeof(short)) *(short*)dest = *(short*)src; } else if (elsize == sizeof(int)) { for(j=copies; j; --j, dest += sizeof(int)) *(int*)dest = *(int*)src; } else if (elsize == sizeof(long)) { for(j=copies; j; --j, dest += sizeof(long)) *(long*)dest = *(long*)src; } else if (elsize == sizeof(float)) { for(j=copies; j; --j, dest += sizeof(float)) *(float*)dest = *(float*)src; } else if (elsize == sizeof(double)) { for(j=copies; j; --j, dest += sizeof(double)) *(double*)dest = *(double*)src; } else { for(j=copies; j; --j, dest += elsize) memcpy(dest, src, elsize); } I've thrown in the int and float cases to make sure we cover every machine that may be out there. Lee Taylor On Wed, 6 Dec 2000 rlw at stsci.edu wrote: > A suggestion for an easy way to fix this problem: use float instead of > long. Presumably floats are always 4 bytes. > Rick > > Paul Dubois writes: > > >This was a patch that I put in before making this release. If you get 17.1.1 > >it won't be in there. > > > > [...] > > > >cc: Error: Src/arrayobject.c, line 79: The switch statement containing this > >case label already has a case label for "8". (dupcase) > > case sizeof(double): > >------------^ > >error: command 'cc' failed with exit status 1 > >tc05:/usr/tmp/chase/Numeric-17.1.2[408] > > > > > >int do_sliced_copy(char *dest, int *dest_strides, int *dest_dimensions, > > int dest_nd, char *src, int *src_strides, > > int *src_dimensions, int src_nd, int elsize, > > int copies) { > > int i, j; > > > > if (src_nd == 0 && dest_nd == 0) { > > switch(elsize) { > > case sizeof(char): > > memset(dest, *src, copies); > > break; > > case sizeof(short): > > for(j=copies; j; --j, dest += sizeof(short)) > > *(short*)dest = *(short*)src; > > break; > > case sizeof(long): > > for(j=copies; j; --j, dest += sizeof(int)) > > *(int*)dest = *(int*)src; > > break; > > case sizeof(double): > > for(j=copies; j; --j, dest += sizeof(double)) > > *(double*)dest = *(double*)src; > > break; > > default: > > for(j=copies; j; --j, dest += elsize) > > memcpy(dest, src, elsize); > > } > > return 0; > > } > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/mailman/listinfo/numpy-discussion > From rlw at stsci.edu Wed Dec 6 14:26:55 2000 From: rlw at stsci.edu (rlw at stsci.edu) Date: Wed, 6 Dec 2000 14:26:55 -0500 (EST) Subject: [Numpy-discussion] RE: Numpy Message-ID: <200012061926.OAA01657@sundog.stsci.edu> >From taylor at rhino.llnl.gov Wed Dec 6 13:23 EST 2000 > >I think a more portable solution is to just make it all an if statement. >I'm not comfortable with presuming that floats are always 4 bytes. I agree -- I also had the thought of changing to an if statement after I sent my mail. Much better than the switch since it can't break. >I've thrown in the int and float cases to make sure we cover every >machine that may be out there. I suspect that if float is 8 bytes then int will be too. Just char, short, float, and double should suffice. If the 4-byte version is missing it will just fall back on the default (slower but otherwise OK), and if the C compiler doesn't support shorter data items then probably the user won't be using them anyway... Rick White From Oliphant.Travis at mayo.edu Wed Dec 6 14:55:27 2000 From: Oliphant.Travis at mayo.edu (Travis Oliphant) Date: Wed, 6 Dec 2000 13:55:27 -0600 (CST) Subject: [Numpy-developers] Re: [Numpy-discussion] RE: Numpy In-Reply-To: <200012061926.OAA01657@sundog.stsci.edu> Message-ID: > I agree -- I also had the thought of changing to an if statement after > I sent my mail. Much better than the switch since it can't break. I took the liberty to change this in the CVS tree. (I haven't been very active lately and wanted to help in some way.) I haven't released a new version with the change, though. -Travis From dubois1 at llnl.gov Wed Dec 6 17:58:40 2000 From: dubois1 at llnl.gov (Paul F. Dubois) Date: Wed, 6 Dec 2000 14:58:40 -0800 Subject: [Numpy-discussion] Bug in MA Message-ID: <00120615025300.09688@almanac> It has come to my attention that the Masked Array package, MA, has a rather severe bug. The bug occurs when doing a mixed scalar/array operation in which the array has its first element masked. The bug causes the value computed by this operation to be wrong. I should have a fix for this problem shortly but since this bug is so severe I thought I should put out a warning immediately. This bug was introduced a few versions ago. From pauldubois at home.com Mon Dec 11 13:33:03 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Mon, 11 Dec 2000 10:33:03 -0800 Subject: [Numpy-discussion] CVS updated but cannot release 17.2.0 Message-ID: I have CVS updated with fixes to MA, and the optimization for ones, etc. I can't release the files because they lost the upload server that does that and until they get the replacement online there are no new file releases. Developers, there are bug reports for FFT and savespace that need attention from the corresponding experts. The patch list is clear. We have completed the refereed papers program for IPC9 and it will be released shortly after notification of authors. The program is quite good, plus there are tutorials and two other tracks. I encourage all Nummies to attend (March, Long Beach CA; see python9.org). Registration has just opened. From pih at oek.dk Tue Dec 12 09:01:01 2000 From: pih at oek.dk (Peter I. Hansen) Date: Tue, 12 Dec 2000 15:01:01 +0100 Subject: [Numpy-discussion] matrix file format Message-ID: <3A362F9D.AF9CF722@oek.dk> Hi, I'm trying to find out what format a matrix input file should have in numpy. example : I have the matrix : [[1 2 3 4 5 6 7 8 9]] and want to read it to nympy from a text-filen that is easy for a user to generate in an editor. Can you tell me how to do that. I read the manual and it didn?t given much af on idea. I thank you in advance Peter I. Hansen From jhauser at ifm.uni-kiel.de Tue Dec 12 09:11:10 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: Tue, 12 Dec 2000 15:11:10 +0100 (CET) Subject: [Numpy-discussion] matrix file format In-Reply-To: <3A362F9D.AF9CF722@oek.dk> References: <3A362F9D.AF9CF722@oek.dk> Message-ID: <20001212141110.4559.qmail@lisboa.ifm.uni-kiel.de> In principle there is no such format in the sense of other numerical environments. But it is possible to simple put the data into a python module and import that, like # Datafile data.py import Numeric data=Numeric.array([[1,2,3],[4,5,6],[7,8,9]]) # in python (other module or interactive session) from data import data print data HTH __Janko Peter I. Hansen writes: > Hi, > > I'm trying to find out what format a matrix input file should have in > numpy. > example : > > I have the matrix : > [[1 2 3 > 4 5 6 > 7 8 9]] > > and want to read it to nympy from a text-filen that is easy for a user > to generate in an editor. > > Can you tell me how to do that. I read the manual and it didn?t given > much af on idea. > > I thank you in advance > > Peter I. Hansen > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/mailman/listinfo/numpy-discussion From clee at gnwy100.wuh.wustl.edu Tue Dec 12 12:03:26 2000 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: Tue, 12 Dec 2000 11:03:26 -0600 (CST) Subject: [Numpy-discussion] matrix file format In-Reply-To: <3A362F9D.AF9CF722@oek.dk> References: <3A362F9D.AF9CF722@oek.dk> Message-ID: <14902.23134.68820.562930@gnwy100.wuh.wustl.edu> You have many options: I frequently use Konrad Hinsen's "Scientific" package (http://dirac.cnrs-orleans.fr/programs/scientific.html). It make importing files from user input or other packages like matlab easy and supports several file formats. The simpliest is a basic white-space-delimitted text file if you have a text file "arrayfile.txt" that looks like this: # arrayfile.txt (lines beginning with '#' are ignored) 1 2 3 4 5 6 6 8 9 You can fire up python and read in your matrix like this: >>> from Scientific.IO.ArrayIO import readArray >>> A = readArray('arrayfile.txt') >>> print A [[1 2 3] [4 5 6] [6 8 9]] From hinsen at cnrs-orleans.fr Tue Dec 12 13:20:24 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: Tue, 12 Dec 2000 19:20:24 +0100 Subject: [Numpy-discussion] matrix file format In-Reply-To: <3A362F9D.AF9CF722@oek.dk> (pih@oek.dk) References: <3A362F9D.AF9CF722@oek.dk> Message-ID: <200012121820.TAA14096@chinon.cnrs-orleans.fr> > I'm trying to find out what format a matrix input file should have in > numpy. Any format you like, but you have to supply the I/O code yourself. Which however is really simple. For example, the following function from ScientificPython: from Scientific.IO.TextFile import TextFile import string, Numeric def readArray(filename): "Return an array containing the data from file |filename|." data = [] for line in TextFile(filename): if line[0] != '#': data.append(map(eval, string.split(line))) a = Numeric.array(data) if a.shape[0] == 1 or a.shape[1] == 1: a = Numeric.ravel(a) return a Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From su96-fst at nada.kth.se Wed Dec 13 07:24:14 2000 From: su96-fst at nada.kth.se (Fredrik Stenberg) Date: Wed, 13 Dec 2000 13:24:14 +0100 (MET) Subject: [Numpy-discussion] Tutorial in Numerical Python? (fwd) Message-ID: Hi, I took the liberty to forward your email to numpy-discussion at lists.sourceforge.net. The only document i know of is located at the Python homepage http://numpy.sourceforge.net. /fredrik ---------- Forwarded message ---------- Date: 13 Dec 2000 11:27:08 +0000 From: Jos? Luis G?mez Dans Newsgroups: comp.lang.python Subject: Tutorial in Numerical Python? Hi, I am wondering whether such a thing exists. Is there a nice tutorial for NumPy that guides you through the basic steps? Say, a little hands-on introduction to Linear Algebra, Transforms and possibly the inclusion of some of the graphic modules? There are some willing students to be converted around these parts, and a hands-on tutorial would be great. Unfortunately, I am a beginner in these waters myself, but can see the opportunity for this. Thanks in advance, Jos? -- Jos? L G?mez Dans PhD student Tel: +44 114 222 5582 Radar & Communications Group FAX; +44 870 132 2990 Department of Electronic Engineering University of Sheffield UK From Herbert.W.Schilling at grc.nasa.gov Wed Dec 13 09:06:08 2000 From: Herbert.W.Schilling at grc.nasa.gov (Herb Schilling) Date: Wed, 13 Dec 2000 10:06:08 -0400 Subject: [Numpy-discussion] Tutorial in Numerical Python? (fwd) In-Reply-To: References: Message-ID: >---------- Forwarded message ---------- >Date: 13 Dec 2000 11:27:08 +0000 >From: Jos? Luis G?mez Dans >Newsgroups: comp.lang.python >Subject: Tutorial in Numerical Python? > > >Hi, > I am wondering whether such a thing exists. Is there a nice >tutorial for NumPy that guides you through the basic steps? Say, a >little hands-on introduction to Linear Algebra, Transforms and >possibly the inclusion of some of the graphic modules? Hi, Take a look at: -- --------------------------------- Herb Schilling NASA Glenn Research Center Cleveland, OH 44135 Herbert.W.Schilling at grc.nasa.gov If all our misfortunes were laid in one common heap whence everyone must take an equal portion, most people would be contented to take their own and depart. -Socrates (469?-399 B.C.) From pauldubois at home.com Wed Dec 13 19:24:13 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Wed, 13 Dec 2000 16:24:13 -0800 Subject: [Numpy-discussion] 17.2.0 Message-ID: I uploaded Numeric 17.2.0 but then got errors from Sourceforge's web pages for actually releasing it. I'm going to wait a day or two and try again. I may be forced to renumber around the one that is already there. I don't think users can actually see this file yet. CVS is up to date with what will become 17.2.? when I finally succeed. From anthony.seward at ieee.org Sun Dec 17 11:06:44 2000 From: anthony.seward at ieee.org (Tony Seward) Date: Sun, 17 Dec 2000 09:06:44 -0700 (MST) Subject: [Numpy-discussion] Numpy doesn't build properly Message-ID: Because the Numpy sub-packages use '#include "Numeric/arratobject.h", the Numeric package will not build from scratch. This may not matter if one does a 'python setup_all.py install' as long as the base Numeric package is installed before the sub-packages are built. I don't think that this is what setup_all.py does because the core setup.py is called with no arguments. In any case, I'm trying to build RPMs and the build and install processes are seperated. In order to build the packages seprately I am now putting a symbolic link in each package's Include directory called Numeric that points to the Include directory for the core package. I would like to suggest that the core header files be put in a directory 'Include/Numeric' rather than directly in 'Include'. That way the header file locations more acurately mirror the way that they are installed. Tony From pfenn at mmm.com Thu Dec 21 15:52:03 2000 From: pfenn at mmm.com (pfenn at mmm.com) Date: Thu, 21 Dec 2000 14:52:03 -0600 Subject: [Numpy-discussion] CXX versions Message-ID: Hi, I'm playing around with CXX because I'm going to be writing an extension in the next few days. I'm on WinNT running Microsoft Visual C++ 6.0 with service pack 3 installed. Also, Python 2.0. I've gotten all of CXX-5.0b to compile, and I compiled the demo. This required a slight edit of cxx_extensions.cxx which was documented in the SourceForge buglist for CXX. I was pleasantly surprised that VC++ was able to compile this code. However, when I import CXX.example python crashes. Is this a known problem, is there a workaround, or should I try CXX-4.2 instead? For some reason, I am really adverse to writing another extension using C. Tom Fenn From pauldubois at home.com Thu Dec 28 23:39:19 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Thu, 28 Dec 2000 20:39:19 -0800 Subject: [Numpy-discussion] Happy New Year Nummies -- and some discussion about the future In-Reply-To: Message-ID: A millenium-end report from the Head Nummie (this name is a joke; see the DEVELOPERS file): There have been a steady set of messages on the subject of I should do this or that to make it easier to make RPMs. It is impossible for me to act on these: I don't know much about RPMs, and if I did, I don't know if making the change suggested is good or bad for someone doing something else, like making Windows installers. Therefore my policy is to rely on the Distutils people to work this out. Those who wish to make it easier to make a binary installer for platform xyz should figure out what would be required by the Distutils bdist family of commands. That is not to say that I don't appreciate people trying to help. I'm grateful for all the support I get from the community. I think that relying on division of labor in this case is the right thing to do, so that we take advantage of the Distutils effort. If I'm wrong, I'll listen. There are a number of bug reports on the sourceforge site. I would be grateful for patches. In particular there are two reports dealing with FFTs. I lack the expertise to deal with these. The masked array package MA has been getting more of a workout as I put it into production at my site. I believe that it fills not only the immediate need for dealing with missing values, but can serve as a model for how to make a "Numeric-workalike" with extra properties, since we can't inherit from Numeric's array. Since MA is improved fairly often, I recommend keeping up via cvs if you are a user. I have new manuals but have had difficulty with the transport up to SourceForge. Anybody else having such a problem? I used scp from a Linux box and it sat there and didn't do anything. The rest of this is for developers. Actually, once you get into it, it isn't all that clear that inheritance would help very much. For example, suppose you want an array class F that has masked values but also has a special behavior f() controlled by a parameter set at creation, beta. Suppose therefore you decide to inherit from class MA. Thus the constructor of your new class must take the same arguments as an MA array but add a beta=somedefault. OK, we do that. Now we can construct a couple of F's: f1 = F([1.,2.,3.], beta=1.) f2 = F([4.,2.,1.], beta=2.) Great. Now we can do f1.f(), f2.f(). Maybe we redefine __str__ so we can print beta when we print f1. Now try to do something. Anything. Say, f3 = f1 + f2 Oops. f3 is an MA, not an F. We might have written __add__ in MA so the it used self.__class__ to construct the answer. But since the constructor now needs a new parameter, there is no way MA.__add__ can make an F. It doesn't know how. Doesn't know how to call F(), doesn't know what value to use for beta anyway. So now we redefine all the methods in MA. Besides muttering that maybe inheriting didn't buy me a lot, I am still nowhere, for the next thing I realize is that every function f(a) that takes an MA as an argument and returns an MA, still returns an MA. If any of these make sense for an instance of F, I have to replace them, just as MA replaced sin, cos, sqrt, take, etc. from Numeric. I have therefore come to the conclusion that we have been barking up the wrong tree. There might be a few cases where inheritance would buy you something, but essentially Numeric and MA are useless as parents. Instead, what would be good to have is a python class Numeric built upon a suite of C routines that did all the real work, such as adding, transposing, iterating over elements, applying a function to each element, etc. Since it is now possible to build a Python class with C methods, which it was not when Numeric was created, we ought to think about it. Such an API could be used to make other classes with good performance. We could lose the artificial layer that is in there now that makes it so tedious to add a function. (I counted something like five or six places I had to modify when I added "put".) Best regards to all, Paul Dubois From pauldubois at home.com Fri Dec 29 14:23:43 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Fri, 29 Dec 2000 11:23:43 -0800 Subject: [Numpy-discussion] Documentation updated Message-ID: Sorry this is in HTML, but the documentation below requires it. The latest source release is 17.2.0. Revised documentation in HTML and PDF is available at http://numpy.sourceforge.net. Package MA contains a number of new constructors. The complete list is: Constructing masked arrays 1.. array (data, typecode = None, copy = 1, savespace = 0, mask = None, fill_value = None) creates a masked array with the given data and mask. The name array is simply an alias for the class name, MA. This constructor sets the data area of the resulting masked array to filled (data, value = fill_value, copy = copy, savespace = savespace), the mask to make_mask (mask, savespace), and the fill value is set to fill_value. The class name MA may also be used instead of the name array. 2.. masked_array (data, mask = None, fill_value = None) is an easier to use version of array, for the common case of typecode = None, copy = 0. When data is newly-created this function can be used to make it a masked array without copying the data if data is already a Numeric array. 3.. masked_values (data, value, rtol=1.e-5, atol=1.e-8, typecode = None, copy = 1, savespace = 0) constructs a masked array whose mask is set at those places where abs (data - value) < atol + rtol * abs (data). That is a careful way of saying that those elements of the data that have value = value (to within a tolerance) are to be treated as invalid. 4.. masked_object (data, value, copy=1, savespace=0) creates a masked array with those entries marked invalid that are equal to value. Again, copy and savespace are passed on to the Numeric array constructor. 5.. masked_where (condition, data) creates a masked array whose shape is that of condition, whose values are those of data, and which is masked where elements of condition are true. 6.. masked_greater (data, value) is equivalent to masked_where (greater(data, value), data)). Similarly, masked_greater_equal, masked_equal, masked_not_equal, masked_less, masked_less_equal are called in the same way with the obvious meanings. Note that for floating point data, masked_values is preferable to masked_equal in most cases. On entry to any of these constructors, data must be any object which the Numeric package can accept to create an array (with the desired typecode, if specified). The mask if given must be None or any object that can be turned into a Numeric array of integer type (it will be converted to typecode MaskType, if necessary), have the same shape as data, and contain only values of 0 or 1. If the mask is not None but its shape does not match that of data, an exception will be thrown, unless one of the two is of length 1, in which case the scalar will be resized (using Numeric.resize) to match the other. -------------- next part -------------- An HTML attachment was scrubbed... URL: