You can subscribe to this list here.
2000 |
Jan
(8) |
Feb
(49) |
Mar
(48) |
Apr
(28) |
May
(37) |
Jun
(28) |
Jul
(16) |
Aug
(16) |
Sep
(44) |
Oct
(61) |
Nov
(31) |
Dec
(24) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(56) |
Feb
(54) |
Mar
(41) |
Apr
(71) |
May
(48) |
Jun
(32) |
Jul
(53) |
Aug
(91) |
Sep
(56) |
Oct
(33) |
Nov
(81) |
Dec
(54) |
2002 |
Jan
(72) |
Feb
(37) |
Mar
(126) |
Apr
(62) |
May
(34) |
Jun
(124) |
Jul
(36) |
Aug
(34) |
Sep
(60) |
Oct
(37) |
Nov
(23) |
Dec
(104) |
2003 |
Jan
(110) |
Feb
(73) |
Mar
(42) |
Apr
(8) |
May
(76) |
Jun
(14) |
Jul
(52) |
Aug
(26) |
Sep
(108) |
Oct
(82) |
Nov
(89) |
Dec
(94) |
2004 |
Jan
(117) |
Feb
(86) |
Mar
(75) |
Apr
(55) |
May
(75) |
Jun
(160) |
Jul
(152) |
Aug
(86) |
Sep
(75) |
Oct
(134) |
Nov
(62) |
Dec
(60) |
2005 |
Jan
(187) |
Feb
(318) |
Mar
(296) |
Apr
(205) |
May
(84) |
Jun
(63) |
Jul
(122) |
Aug
(59) |
Sep
(66) |
Oct
(148) |
Nov
(120) |
Dec
(70) |
2006 |
Jan
(460) |
Feb
(683) |
Mar
(589) |
Apr
(559) |
May
(445) |
Jun
(712) |
Jul
(815) |
Aug
(663) |
Sep
(559) |
Oct
(930) |
Nov
(373) |
Dec
|
From: Tim C. <tc...@op...> - 2002-03-29 22:50:27
|
Johan Fredrik =D8hman wrote: >=20 > The first numbers in each of your three runs are 7.98493051529 , > 7.98525762558 and 7.98623776436. > They look like different numbers to me. >=20 > First, thanks for your answer Time. > I do agree, they are different. But I wouldn't call it random. I didn= 't expect > that the small difference in the initial seed would affect the first nu= mber with so little. > Usually the seed numbers I have experienced other places have much more > dramatic effect on the numbers, if you see what I mean... OK, you need to use Konrad Hinsen's excellent RNG module which comes with Numeric Python: ################################# # Python Virtual clock import RNG dist =3D RNG.NormalDistribution(10, 2) rng =3D RNG.CreateGenerator(0, dist) for i in range(1000000,10000000,1000000): print "Clock at time:" , i/1000000, ":", rng.ranf() ################################## The above code gives 8.46183655136, 7.29889782477 and 5.58243682462 as the first values in three successive runs on my system. Hope this helps, Tim C >=20 > If you want the difference > between initial values to be greater, you need to make the > difference in your seeds greater. For example, if I run your code now, = I > get 8.29225027561, 8.29484963417 and 8.29744851589, but setting the see= d > to (1,2) gives an initial value of 5.69397783279. Remember, these are > only pseudorandom numbers. >=20 > Yes, they are pseudorandom and that is OK. What I just want is some mo= re > initial difference between the runs without setting the seed number man= ually. > But know I know this is not a flaw in the RNG, but "its the way it is s= upposed to be" >=20 > Thanks >=20 > -- > Johan Fredrik Ohman >=20 > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion |
From: <jo...@oh...> - 2002-03-29 21:27:42
|
The first numbers in each of your three runs are 7.98493051529 , 7.98525762558 and 7.98623776436. They look like different numbers to me.=20 First, thanks for your answer Time.=20 I do agree, they are different. But I wouldn't call it random. I = didn't expect that the small difference in the initial seed would affect the first = number with so little. Usually the seed numbers I have experienced other places have much more dramatic effect on the numbers, if you see what I mean... If you want the difference between initial values to be greater, you need to make the=20 difference in your seeds greater. For example, if I run your code now, I get 8.29225027561, 8.29484963417 and 8.29744851589, but setting the seed to (1,2) gives an initial value of 5.69397783279. Remember, these are only pseudorandom numbers.=20 Yes, they are pseudorandom and that is OK. What I just want is some = more initial difference between the runs without setting the seed number = manually. But know I know this is not a flaw in the RNG, but "its the way it is = supposed to be" Thanks -- Johan Fredrik Ohman |
From: Tim C. <tc...@op...> - 2002-03-29 21:00:29
|
> Johan Fredrik =D8hman wrote: >=20 > This code generates very non-random numbers, even when the seed value > is reinitialized. > Take a look at the first number in each run ! >=20 The first numbers in each of your three runs are 7.98493051529 , 7.98525762558 and 7.98623776436. They look like different numbers to me. If you want the difference between initial values to be greater, you need to make the=20 difference in your seeds greater. For example, if I run your code now, I get 8.29225027561, 8.29484963417 and 8.29744851589, but setting the seed to (1,2) gives an initial value of 5.69397783279. Remember, these are only pseudorandom numbers.=20 Tim C =20 > Is this right ? >=20 > -- > JF=D8 >=20 >=20 > #!/usr/local/bin/python2.1 >=20 > # Python Virtual clock > import RandomArray >=20 > print "Seed", RandomArray.get_seed() > for i in range(1000000,10000000,1000000): > print "Clock at time:" , i/1000000, ":", > RandomArray.normal(10,2) >=20 >=20 > [root@blekkulf /root]# ./t2.py > Seed (101743, 1951) > Clock at time: 1 : 7.98493051529 > Clock at time: 2 : 10.8439420462 > Clock at time: 3 : 7.59234881401 > Clock at time: 4 : 7.32021093369 > Clock at time: 5 : 10.9444898367 > Clock at time: 6 : 10.1128772199 > Clock at time: 7 : 13.1178274155 > Clock at time: 8 : 11.779414773 > Clock at time: 9 : 10.7529922128 > [root@blekkulf /root]# ./t2.py > Seed (101743, 1953) > Clock at time: 1 : 7.98525762558 > Clock at time: 2 : 9.38142818213 > Clock at time: 3 : 7.11979293823 > Clock at time: 4 : 10.867649436 > Clock at time: 5 : 9.62882992625 > Clock at time: 6 : 12.1940765381 > Clock at time: 7 : 6.84895467758 > Clock at time: 8 : 8.13472533226 > Clock at time: 9 : 8.15638375282 > [root@blekkulf /root]# ./t2.py > Seed (101743, 1959) > Clock at time: 1 : 7.98623776436 > Clock at time: 2 : 14.5040078163 > Clock at time: 3 : 11.3408681154 > Clock at time: 4 : 6.32757425308 > Clock at time: 5 : 8.94617521763 > Clock at time: 6 : 12.1802353859 > Clock at time: 7 : 12.0685124397 > Clock at time: 8 : 10.5330892205 > Clock at time: 9 : 10.9744755626 |
From: <jo...@oh...> - 2002-03-29 20:02:26
|
This code generates very non-random numbers, even when the seed value is = reinitialized. Take a look at the first number in each run ! Is this right ? -- JF=D8 #!/usr/local/bin/python2.1 # Python Virtual clock import RandomArray print "Seed", RandomArray.get_seed() for i in range(1000000,10000000,1000000): print "Clock at time:" , i/1000000, ":", = RandomArray.normal(10,2) [root@blekkulf /root]# ./t2.py=20 Seed (101743, 1951) Clock at time: 1 : 7.98493051529 Clock at time: 2 : 10.8439420462 Clock at time: 3 : 7.59234881401 Clock at time: 4 : 7.32021093369 Clock at time: 5 : 10.9444898367 Clock at time: 6 : 10.1128772199 Clock at time: 7 : 13.1178274155 Clock at time: 8 : 11.779414773 Clock at time: 9 : 10.7529922128 [root@blekkulf /root]# ./t2.py=20 Seed (101743, 1953) Clock at time: 1 : 7.98525762558 Clock at time: 2 : 9.38142818213 Clock at time: 3 : 7.11979293823 Clock at time: 4 : 10.867649436 Clock at time: 5 : 9.62882992625 Clock at time: 6 : 12.1940765381 Clock at time: 7 : 6.84895467758 Clock at time: 8 : 8.13472533226 Clock at time: 9 : 8.15638375282 [root@blekkulf /root]# ./t2.py=20 Seed (101743, 1959) Clock at time: 1 : 7.98623776436 Clock at time: 2 : 14.5040078163 Clock at time: 3 : 11.3408681154 Clock at time: 4 : 6.32757425308 Clock at time: 5 : 8.94617521763 Clock at time: 6 : 12.1802353859 Clock at time: 7 : 12.0685124397 Clock at time: 8 : 10.5330892205 Clock at time: 9 : 10.9744755626 |
From: Konrad H. <hi...@cn...> - 2002-03-28 16:27:39
|
Amitha P <ami...@ya...> writes: > irrevelent values. I could successfully return single > dimension Python array object but I am not able to > return 2D python array object. I am attaching the > code. Please look at it and point out the errors. > product = (PyArrayObject *)PyArray_FromDimsAndData(2, > dimensions, > PyArray_FLOAT,c); The variable c in this call must point to a storage area which holds the elements of the matrix, i.e. a one-dimensional float array. What you pass in your code is a list of pointers to the rows of the matrix. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hi...@cn... 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: Amitha P <ami...@ya...> - 2002-03-28 14:58:17
|
Hi all, I am new to Python/Python extension programming. I am writing a c-extension to python which takes a 3-Dimensional array object and returns the 2Dimensional array object. The c function returns the 2-D array and converts into Python object, but the 2D python array object doesnot contain the correct values, it's priting out some irrevelent values. I could successfully return single dimension Python array object but I am not able to return 2D python array object. I am attaching the code. Please look at it and point out the errors. Thank you very much.. ------------------------------------------------------- CMATRIXMUL16.c - This takes the array (the python 3D array) and returns the 2D array ------------------------------------------------------ #include <stdio.h> #include <math.h> float* cmatrixmul16(float *array,float *paddarr, int n,int r,int col,float **store) { int i,j,k; int devices; int pathpoints; int column; int len; float sum; float **a,**b,**c,**d; float *temp; static float **tracematrix; tracematrix = store; pathpoints=r; column = col; devices= n; len = pathpoints*2; temp = (float *)malloc( len* sizeof(float)); sum =0.0; a = (float **)malloc(devices * sizeof(float)); b = (float **)malloc(devices * sizeof(float)); c = (float **)malloc(devices * sizeof(float)); d = (float **)malloc(devices * sizeof(float)); for(i=0;i<devices;i++) { a[i] = (float *)malloc(pathpoints*sizeof(float)); b[i] = (float *)malloc(pathpoints*sizeof(float)); c[i] = (float *)malloc(pathpoints*sizeof(float)); d[i] = (float *)malloc(pathpoints*sizeof(float)); } for(k=0;k<devices;k++){ for(i=0;i<pathpoints;i++) { a[k][i] = (*(array+k*pathpoints*column+i*column+0))*(1.0/sqrt(2.0)); b[k][i] = (*(array+k*pathpoints*column+i*column+1))*(1.0/sqrt(2.0)); c[k][i] = (*(array+k*pathpoints*column+i*column+2))*(1.0/sqrt(2.0)); d[k][i] = (*(array+k*pathpoints*column+i*column+3))*(1.0/sqrt(2.0)); tracematrix[k][i] = a[k][i]*a[k][i]+b[k][i]*b[k][i]; tracematrix[k][pathpoints+i] = c[k][i]*c[k][i]+d[k][i]*d[k][i]; } fprintf(stderr,"tracematrix: %f\n", tracematrix[k][0]); } for(i=0;i<devices;i++) { free(a[i]); free(b[i]); free(c[i]); free(d[i]); } free(a); free(b); free(c); free(d); return (float *)tracematrix; } ------------------------------------------------------ This is the module which calls the function _tests16module.c ------------------------------------------------------- #include <Python.h> #include <arrayobject.h> #include <math.h> static PyObject * Py_arraytest1 (PyObject *, PyObject *); static char _tests17_module_doc[] ="tests11: module documentation"; static char arraytest1__doc__[]= "mytest:function documentation"; /********************************Python symbol table *****************************************/ static PyMethodDef _tests17_methods[] = { {"arraytest1" , (PyCFunction)Py_arraytest1 , METH_VARARGS,arraytest1__doc__ }, {NULL, (PyCFunction)NULL,0,NULL } /* terminates the list of methods */ }; /*********************************End of Symbol table ***************************************/ void init_tests17() { /* We will be using C-functions defined in the array module. So we * need to be sure that the shared library defining these functions * is loaded. */ import_array(); (void) Py_InitModule4( "_tests17", /* module name */ _tests17_methods, /* structure containing python symbol info */ _tests17_module_doc, /* module documentation string */ (PyObject *) NULL, PYTHON_API_VERSION); } /*function to calculate the product of two arrays */ static PyObject * Py_arraytest1(PyObject *self, PyObject *args) { PyArrayObject *array, *paddarr, *product; char *c; int n,r,col,i,j,k; int dimensions[2]; float **store; if (!PyArg_ParseTuple(args, "O!O!", &PyArray_Type, &array,&PyArray_Type,&paddarr)) return NULL; /* The arguments are the 3-D array and the 1-Dpaddarr */ n = (long) array->dimensions[0]; r = (long) array->dimensions[1]; col = (long) array->dimensions[2]; store = (float **)malloc(n*sizeof(float)); for(i=0;i<n;i++) store[i]=(float *)malloc(2*r*sizeof(float)); c= (char*)cmatrixmul16((float *)array->data,(float *)paddarr->data,n,r,col,store); dimensions[0] = n; dimensions[1] = 2*r; product = (PyArrayObject *)PyArray_FromDimsAndData(2, dimensions, PyArray_FLOAT,c); PyArray_Return(product); } __________________________________________________ Do You Yahoo!? Yahoo! Movies - coverage of the 74th Academy Awards® http://movies.yahoo.com/ |
From: Jochen <jo...@un...> - 2002-03-27 21:00:49
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wed, 27 Mar 2002 20:21:38 +0100 Magnus Lie Hetland wrote: Magnus> By the way: Is there any documentation of the numarray C API Magnus> anywhere yet? I think ,---- | http://stsdas.stsci.edu/numarray/DesignOverview.html `---- is all there is for now. And it's probably not exactly right any more... Greetings, Jochen - -- University of North Carolina phone: +1-919-962-4403 Department of Chemistry phone: +1-919-962-1579 Venable Hall CB#3290 (Kenan C148) fax: +1-919-843-6041 Chapel Hill, NC 27599, USA GnuPG key: 44BCCD8E -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6-cygwin-fcn-1 (Cygwin) Comment: Processed by Mailcrypt and GnuPG <http://www.gnupg.org/> iEYEARECAAYFAjyiMsIACgkQiJ/aUUS8zY6wfgCdHxsqk3NnWRzme0M/6wYcfpKK kA8AoJ0p0Kg05UOwCOk2QkPu6mQft5xj =WLhN -----END PGP SIGNATURE----- |
From: Magnus L. H. <ma...@he...> - 2002-03-27 19:21:48
|
Just something I've been thinking about for a few years (and never gotten around to doing anything about)... How realistic would it be to wrap a video file as a type of three-dimensional (assuming grayscale) array object and then use e.g. numarray to manipulate it? And how easy would it be to make this sort of thing "lazy", so that only the parts needed for the parts you actually access (for display or whatever) are processed? E.g. (silly example): >>> a = videoarray('somefile.mpg') >>> b = sin(a) # No real computation here >>> for frame in b: ... displayFrame(frame) # Computation performed here... Or something... Or maybe I'm just bonkers ;) By the way: Is there any documentation of the numarray C API anywhere yet? -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org |
From: ¸ô¸¶½ºÅ¸ <ma...@ko...> - 2002-03-27 14:35:44
|
<style> <!-- small {font-size:8pt;font-family:굴림} font,td,p {font-size: 9pt;text-decoration: none;font-family:굴림} <!-- A:link, A:active, A:visited {color:"#000000"; font-size:7pt; text-decoration: none} A:hover {text-decoration:none; color:"#666600"} .notice {font-size:10pt; color:black; text-decoration: none} a.01 {color:#7F7F7F; text-decoration:none} a.01:visited {color:#7F7F7F; text-decoration:none} a.01:hover {color:#4A4A4A; text-decoration:underline} --> </style> <base href="C:\Documents and Settings\Administrator\바탕 화면\"></head> <body bgcolor="white" text="black" link="blue" vlink="purple" alink="red"> <p> <table border="0" cellpadding="0" cellspacing="0" width="540" height="504" background="http://www.umaxmall.co.kr/shop/mail/mail_1/44.gif"> <tr> <td width="540" height="23" colspan="10"><p> </p></td> </tr> <tr> <td width="54" height="19"><p> </p></td> <td width="108" height="19" colspan="2"><p align="left"><font size="1"> </font></p></td> <td width="108" height="19" colspan="2"><p align="left"><font size="1"></font> </p></td> <td width="108" height="19" colspan="2"><p align="left"> </p></td> <td width="109" height="19" colspan="2"><p align="center"><font size="1"></font> </p></td> <td width="53" height="19"><p> </p></td> </tr> <tr> <td width="54" height="19"><p> </p></td> <td width="108" height="19" colspan="2"><p align="left"><font size="1"></font> </p></td> <td width="108" height="19" colspan="2"><p align="left"><font size="1"></font> </p></td> <td width="108" height="19" colspan="2"><p align="left"><font size="1"></font> </p></td> <td width="109" height="19" colspan="2"><p align="center"><font size="1"></font> </p></td> <td width="53" height="19"><p> </p></td> </tr> <tr> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="41" height="42"><p> </p></td> <td width="67" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="55" height="42"><p> </p></td> <td width="53" height="42"><p> </p></td> </tr> <tr> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="41" height="42"><p> </p></td> <td width="67" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="55" height="42"><p> </p></td> <td width="53" height="42"><p> </p></td> </tr> <tr> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="41" height="42"><p> </p></td> <td width="67" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="55" height="42"><p> </p></td> <td width="53" height="42"><p> </p></td> </tr> <tr> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="41" height="42"><p> </p></td> <td width="67" height="42"><p> </p></td> <td width="54" height="42"><p> </p></td> <td width="55" height="42"><p> </p></td> <td width="53" height="42"><p> </p></td> </tr> <tr> <td width="54" height="36"><p> </p></td> <td width="54" height="36"><p> </p></td> <td width="54" height="36"><p> </p></td> <td width="54" height="36"><p> </p></td> <td width="54" height="36"><p> </p></td> <td width="41" height="36"><p> </p></td> <td width="67" height="36"><p> </p></td> <td width="54" height="36"><p> </p></td> <td width="55" height="36"><p> </p></td> <td width="53" height="36"><p> </p></td> </tr> <tr> <td width="54" height="29"><p> </p></td> <td width="54" height="29"><p> </p></td> <td width="54" height="29"><p> </p></td> <td width="54" height="29"><p> </p></td> <td width="54" height="29"><p> </p></td> <td width="41" height="29"><p> </p></td> <td width="67" height="29"><p> </p></td> <td width="54" height="29"><p> </p></td> <td width="55" height="29"><p> </p></td> <td width="53" height="29"><p> </p></td> </tr> <tr> <td width="54" height="31"><p> </p></td> <td width="54" height="31" rowspan="2" colspan="4"><p><img src="http://www.umaxmall.co.kr/shop/mail/mail_1/sale_2.GIF" width="216" height="60" border="0"></p></td> <td width="41" height="31"><p> </p></td> <td width="67" height="31"><p> </p></td> <td width="54" height="31"><p> </p></td> <td width="55" height="31"><p> </p></td> <td width="53" height="31"><p> </p></td> </tr> <tr> <td width="54" height="31"><p> </p></td> <td width="41" height="31"><p> </p></td> <td width="67" height="31"><p> </p></td> <td width="54" height="31"><p> </p></td> <td width="55" height="31"><p> </p></td> <td width="53" height="31"><p> </p></td> </tr> <tr> <td width="54" height="47"><p> </p></td> <td height="47"><p> </p></td> <td height="47"><p> </p></td> <td height="47"><p> </p></td> <td height="47"><p> </p></td> <td width="41" height="47"><p> </p></td> <td width="229" height="85" rowspan="2" colspan="4"><p><a href="http://www.umaxmall.co.kr"><img src="http://www.umaxmall.co.kr/shop/mail/mail_1/right.gif" width="229" height="81" border="0"></a></p></td> </tr> <tr> <td width="54" height="38"><p> </p></td> <td height="38"></td> <td height="38"></td> <td height="38"></td> <td height="38"></td> <td width="41" height="38"></td> </tr> <tr> <td width="108" height="52" colspan="2"><p align="center"> <img src="http://www.umaxmall.co.kr/shop/mail/mail_1/im_stamp.gif" width="45" height="45" border="0"></p></td> <td width="379" height="52" colspan="7"><p align="left" valign="top"><font color="black">허락없이 메일을 보내서 죄송합니다. 이 메일은 </font>웹서핑중, <b>무작위로 추출한것이며</b> E-Mail 주소 외에, 다른 정보는 갖고 있지 않습니다. <font color="black">메일 수신을 원치 않으시면 </font><font color="red"><b><A href="mailto:di...@ko...?subject=수신거부&body=더이상num...@li...로 메일을 보내지 마세요..">수신거부</A></b></font><font color="black">를 해주십시요. 만약 불필요한 정보였다면 사과 드립니다 </font></p></td> <td width="53" height="52"><p> </p></td> </tr> <tr> <td width="540" height="11" colspan="10"><p> </p></td> </tr> </table></p> </body> |
From: Travis O. <oli...@ie...> - 2002-03-25 00:48:32
|
On Sunday 24 March 2002 02:38 pm, you wrote: > Hello, > > while writing a test driver for a minimum phase calculation routine I came > across the following problem. It is causing asymmetriesin the output of > > >>> N=512 > >>> lastpoint=2*pi > >>> w1=arange(0,lastpoint,lastpoint/N) > >>> w2=arange(0,N)*(lastpoint/N) > >>> lastpoint-w1[511]-w1[1] > > -6.3546390371982397e-014 > > >>> lastpoint-w2[511]-w2[1] > > 4.0245584642661925e-016 > > >>> w1[511] > > 6.2709134608765646 > > >>> w2[511] > > 6.2709134608765007 > > >>> w2[511]-w1[511] > > -6.3948846218409017e-014 > I just fixed this in Numeric. The arange in Numeric used to increment the value by the step amount. It now computes the value using value = start + i*step which fixes the problem. Thanks for pointing this out. |
From: Pearu P. <pe...@ce...> - 2002-03-24 17:58:28
|
Hi, Nummies might be interested how to wrap C codes with f2py. On Wed, 20 Mar 2002, Paul Dubois wrote: > For example, if you have this C code: > > double mydot(int n, double* x, double *y) { > int i; > double d; > d = 0.0; > for (i=0; i < n; ++i) d += x[i] * y[i]; > return d; > } > > Then you can create a Pyfort input file mymod.pyf: > function mydot (n, x, y) > integer:: n=size(x) > doubleprecision x(n), y(n) > doubleprecision mydot > end Different from pyfort, f2py needs the following signature file: python module mymod interface function mydot (n, x, y) intent(c) mydot integer intent(c):: n=size(x) doubleprecision x(n), y(n) doubleprecision mydot end end interface end python module > > Compile mydot.c into a library libmydot.a. > Then: > > pyfort -c cc -i -L. -l mydot mymod.pyf > > builds and installs the module mymod containing function mydot, With f2py the above is equivalent to f2py -c mydot.c mymod.pyf This compiles mydot.c and builds the module mymod into the current directory. > which you > can use from Python: > > import Numeric, mymod > x=Numeric.array([1.,2.3.]) > y=Numeric.array([5., -1., -1.]) > print mymod.mydot(x,y) Python session with f2py generated mymod: >>> import mymod >>> print mymod.mydot([1,2,3],[1,2,4.]) 17.0 Regards, Pearu |
From: Paul F D. <pa...@pf...> - 2002-03-24 16:48:58
|
Pyfort 7.0b2 is now available at sf.net/projects/pyfortran. Nummies who do not use Fortran may be interested in using Pyfort; with Michiel de Hoon's "C" option, it is now extremely easy to wrap a simple kind of C code for processing Numeric's arrays, like this: double ctry(int n, double* x, double* y) { int i; double d; d = 0.0; for (i=0; i < n; ++i) { d += x[i] * y[i]; } return d; } void cout(int n, double* x, double* y) { int i; for (i = 0; i < n; ++i) { y[i] = 1.414159 * x[i]; } } double c2(int n, int m, double x[n][m]) { double sum = 0.0; int i, j; for (i=0; i < n; i++) { for (j=0; j < m; j++) { sum += x[i][j]; } } return sum; } and then call it from Python like this: import testc, Numeric x = Numeric.array([1.,2.,3.]) y = Numeric.array([6.,-1.,-1.]) z = Numeric.arange(6) *1.0 z.shape=(3,2) print "Should be 1.0:", testc.ctry(x,y) print "Should be sqrt(2) * [1,2,3]:", testc.cout(x) print "Should be 15.0:", testc.c2(z) z.shape=(2,3) print "Should be 15.0:", testc.c2(z) ----------- notes Somehow 7.0b1 was missing the C examples. I apparently lost the changes I had made to the MANIFEST and did not realize my CVS commits had failed. Bad day at the office, I guess. I added testc back in, and added a 2-dimensional example. I also eliminated some warning errors in the generated code, and fixed an error in that case. My thanks to Michiel de Hoon and J.S. Whitaker. |
From: Huaiyu Z. <hua...@ya...> - 2002-03-23 08:31:04
|
On Thu, 21 Mar 2002, Pearu Peterson wrote: > On 20 Mar 2002, Jochen K=FCpper wrote: > > >>>> a > > Aureli> array([0, 1, 0, 0, 1, 0, 1, 0, 0, 1]) > > >>>> b > > Aureli> array([1, 1, 0, 1, 0, 0, 1, 1, 1, 0]) > >=20 > > >>>> Numeric.logical_and(a,b) > > Aureli> array([0, 1, 0, 0, 0, 0, 1, 0, 0, 0]) > >=20 > > This look's correct... > >=20 > > >>>> a and b > > Aureli> array([1, 1, 0, 1, 0, 0, 1, 1, 1, 0]) > >=20 > > ... and this suspiciously like b. >=20 > . and also correct. It is default behaviour of Python `and' > operation. From Python Language Reference: >=20 > The expression `x and y' first evaluates `x'; if `x' is false, its va= lue =20 > is returned; otherwise, `y' is evaluated and the resulting value is > returned.=20 >=20 > So, `and' operation is "object"-operation (unless redefined to somethin= g > else) while logical_and is "elementwise"-operation. There is a section in PEP-225 for elementwise/objectwise operators to=20 extend the meaning of ~ to an "elementizer", so that=20 [1, 0, 1, 0] and [0, 1, 1, 0] =3D> [0, 1, 1, 0] [1, 0, 1, 0] ~and [0, 1, 1, 0] =3D> [0, 0, 1, 0] There are several other places, entirely unrelated to numerical=20 computation, that elementization of an operator makes sense. Huaiyu |
From: Pearu P. <pe...@ce...> - 2002-03-21 07:57:43
|
On 20 Mar 2002, Jochen K=FCpper wrote: > >>>> a > Aureli> array([0, 1, 0, 0, 1, 0, 1, 0, 0, 1]) > >>>> b > Aureli> array([1, 1, 0, 1, 0, 0, 1, 1, 1, 0]) >=20 >=20 > >>>> Numeric.logical_and(a,b) > Aureli> array([0, 1, 0, 0, 0, 0, 1, 0, 0, 0]) >=20 > This look's correct... >=20 > >>>> a and b > Aureli> array([1, 1, 0, 1, 0, 0, 1, 1, 1, 0]) >=20 > ... and this suspiciously like b. =2E. and also correct. It is default behaviour of Python `and' operation. From Python Language Reference: The expression `x and y' first evaluates `x'; if `x' is false, its value = =20 is returned; otherwise, `y' is evaluated and the resulting value is returned.=20 So, `and' operation is "object"-operation (unless redefined to something else) while logical_and is "elementwise"-operation. Pearu |
From: Jochen <jo...@jo...> - 2002-03-21 03:05:28
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wed, 20 Mar 2002 19:43:03 +0100 Aureli Soria Frisch wrote: >>>> a Aureli> array([0, 1, 0, 0, 1, 0, 1, 0, 0, 1]) >>>> b Aureli> array([1, 1, 0, 1, 0, 0, 1, 1, 1, 0]) >>>> Numeric.logical_and(a,b) Aureli> array([0, 1, 0, 0, 0, 0, 1, 0, 0, 0]) This look's correct... >>>> a and b Aureli> array([1, 1, 0, 1, 0, 0, 1, 1, 1, 0]) ... and this suspiciously like b. Greetings, Jochen - -- Einigkeit und Recht und Freiheit http://www.Jochen-Kuepper.de Liberté, Égalité, Fraternité GnuPG key: 44BCCD8E Sex, drugs and rock-n-roll -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt and GnuPG <http://www.gnupg.org/> iD8DBQE8mU3jiJ/aUUS8zY4RAnxdAKCfrCyep4b7TKoF+c631cJiX53GmACgtmGo jcS9gt6j1eJJj937JqoUm6M= =TyKW -----END PGP SIGNATURE----- |
From: Paul D. <pa...@pf...> - 2002-03-20 21:13:20
|
A beta version of Pyfort 7.0 is available at pyfortran.sf.net. The documentation is not yet upgraded to this version. Pyfort 7.0 adds the ability to wrap Fortran-like C coding to extend Numpy. Dramatically illustrating the virtue of open source software, credit for this improvement goes to: Michiel de Hoon Human Genome Center University of Tokyo For example, if you have this C code: double mydot(int n, double* x, double *y) { int i; double d; d = 0.0; for (i=0; i < n; ++i) d += x[i] * y[i]; return d; } Then you can create a Pyfort input file mymod.pyf: function mydot (n, x, y) integer:: n=size(x) doubleprecision x(n), y(n) doubleprecision mydot end Compile mydot.c into a library libmydot.a. Then: pyfort -c cc -i -L. -l mydot mymod.pyf builds and installs the module mymod containing function mydot, which you can use from Python: import Numeric, mymod x=Numeric.array([1.,2.3.]) y=Numeric.array([5., -1., -1.]) print mymod.mydot(x,y) Note that by wrapping mydot in this way, Pyfort takes care of problems like converting input arrays of the wrong type, such as integer; making sure that x and y have the same length; and making sure x and y are contiguous. I added directory testc that contains an example like this and one where an array is output. Mr. de Hoon explained his patch as follows. "I have modified fortran_compiler.py to add gcc as a compiler. This enables pyfort to be used for C code instead of Fortran code only. To use this option, call pyfort with the -cgcc option to specify gcc as the compiler. In order to switch off the default TRANSPOSE and MIRROR options, some small modifications were needed in generator.py also. [Editor's note: both -c gcc and -c cc will work] Before writing this addition to pyfort, I tried to use swig to generate the wrapper for my C code. However, pyfort was easier to use in my case because it is integrated with numpy. I wasn't able to get swig use numpy arrays. In addition, I am writing extension code both in fortran and C, so it is easier having to use only one tool (pyfort) for both. In a sense, it is easier to extend python with C than with fortran because you don't have to worry about transposing the array. I tried to be minimally instrusive on the existing pyfort code to switch off transposing arrays; there may be prettier ways to do this than what I have done. With this modification, I was able to pass one- and two-dimensional numpy arrays from Python to C and back without problems, as well as scalar variables with intent(in) and intent(out). I have also used the modified Pyfort on some Fortran routines to make sure I didn't break something in the fortran part of Pyfort. I haven't done an extensive test of this addition, but I haven't found any problems with it so far. I hope this patch will be useful to other people trying to extend Python/numpy with C routines." Michiel de Hoon Human Genome Center University of Tokyo md...@im... |
From: Aureli S. F. <Aur...@ip...> - 2002-03-20 18:47:08
|
Hi all, In the version of Numeric with MacPython2.2 the functions "Numeric.logical_and" and "and" behave different, although up to the on-line documentation they should behave the same: >>> Numeric.logical_and(a,b) array([0, 1, 0, 0, 0, 0, 1, 0, 0, 0]) >>> a and b array([1, 1, 0, 1, 0, 0, 1, 1, 1, 0]) for arrays: >>> a array([0, 1, 0, 0, 1, 0, 1, 0, 0, 1]) >>> b array([1, 1, 0, 1, 0, 0, 1, 1, 1, 0]) or am I misunderstood something...? Regards, Aureli ################################# Aureli Soria Frisch Fraunhofer IPK Dept. Pattern Recognition post: Pascalstr. 8-9, 10587 Berlin, Germany e-mail: au...@ip... fon: +49 30 39006-150 fax: +49 30 3917517 web: http://vision.fhg.de/~aureli/web-aureli_en.html ################################# |
From: Prabhu R. <pr...@ae...> - 2002-03-20 18:22:01
|
hi, I'm sorry I havent been following the discussion too closely and this post might be completely unrelated. >>>>> "AS" == A Schmolck <a.s...@gm...> writes: AS> Ideally , I'd like to see a slim core numarray, without any AS> frills (and more streamlined to behave like standard python AS> containers (e.g. indexing and type/casts behavior)) for the AS> python core, something more enabled and efficient for numerics AS> (including matrices!) as a seperate package (like the XML AS> example you quote). And then maybe a bigger pre-bundled AS> collection of (ideally rather modular) numerical libraries for AS> really hard-core scientific users (maybe in the spirit of AS> xemacs-packages and sumo-tar-balls -- no bloat if you don't AS> need it, plenty of features in an instant if you do). AS> Anyway, is there at least general agreement that there should AS> be some new and wonderful matrix class (plus supporting AS> libraries) somewhere (rather than souping up array)? Ideally, I'd like something that also has a reasonably easy to use interface from C/C++. The idea is that it should be easy (and natural) for someone to use the same library from C/C++ when performance was desired. This would be really nice and very useful. prabhu |
From: Tim P. <ti...@co...> - 2002-03-20 02:20:45
|
[jo...@bo...] > Thanks for the quick answer. The problem is resolved. Cool! Glad to hear it. > Well, changing cvs from > release22-maint > to > r221c1 > helps. That is, everything seems to work fine with the cvs sources > tagged r221c1. That shouldn't have made any difference -- r221c1 is merely a tag on the release22-maint branch. Now I can spend a lot of time trying to guess why your checkout is screwed up (probably stale sticky flags, if it is), or you can try blowing away your checkout and starting over. I know which one gets my vote <wink>. CVS branches and tags are a nightmare: when in any doubt, kill the beast and start over. > Then, is it really necessary to mess up the cvs tags so much? Why > isn't it possible to have a single python-2.2 branch which one could > follow to get all the stuff that's incorporated into that version? That's what the release22-maint branch is supposed to be (and, AFIAK, is). > There are huge differences between release22-maint and r221c1, What makes you think so? I just did cvs diff -r release22-maint -r r221c1 and it turned up expected differences in the handful of files that indeed *have* changed since r221c1 was tagged, mostly in the docs and under the Mac subdirectory: Index: Doc/lib/libcopyreg.tex Index: Doc/lib/libthreading.tex Index: Lib/urllib.py Index: Mac/_checkversion.py Index: Mac/Build/PythonCore.mcp Index: Mac/Distributions/(vise)/Python 2.2.vct Index: Mac/Include/macbuildno.h Index: Mac/Modules/macfsmodule.c Index: Mac/Modules/macmodule.c Index: Misc/NEWS Index: PCbuild/BUILDno.txt > ... > Thanks for all your work, and thank you for the quick help again. And thanks for checking that your problem is fixed in 221c1. Had anyone tried this stuff in 22a1 or 22a2 or 22a3 or 22a4 or 22b1 or 22b2 or 22c1 (yes, we actually cut 7 full prerelease distributions for 2.2!), it would have worked in 2.2 out of the box. Keep that in mind when 2.3a1 comes out <wink>. |
From: Jochen <jo...@un...> - 2002-03-20 01:53:21
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tue, 19 Mar 2002 20:20:36 -0500 Tim Peters wrote: Thanks for the quick answer. The problem is resolved. Tim> [jo...@bo...] >> [1] If it is in there, it doesn't work for me with current python cvs >> branch release22-maint. I still have to manually add -lieee. >> (RedHat-7.0 with current updates.) Tim> I don't know what "current" meant to you at the time you wrote this. About 20:00 (8:00pm) EST today, March 19. Tim> Tim> Michael Hudson did backport the patch into 2.2.1c1, which Tim> Tim> was released yesterday. So please try 2.2.1c1, and if you Tim> Tim> still have a problem, file a bug report about it on Tim> Tim> SourceForge. 2.2.1 final is expected in about a week. Well, changing cvs from release22-maint to r221c1 helps. That is, everything seems to work fine with the cvs sources tagged r221c1. Then, is it really necessary to mess up the cvs tags so much? Why isn't it possible to have a single python-2.2 branch which one could follow to get all the stuff that's incorporated into that version? [1] There are huge differences between release22-maint and r221c1, it seems from the number of patches applied when going from one to the other. But then some files are in the same (non-main) branch. ??? Thanks for all your work, and thank you for the quick help again. Greetings, Jochen - -- University of North Carolina phone: +1-919-962-4403 Department of Chemistry phone: +1-919-962-1579 Venable Hall CB#3290 (Kenan C148) fax: +1-919-843-6041 Chapel Hill, NC 27599, USA GnuPG key: 44BCCD8E -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6-cygwin-fcn-1 (Cygwin) Comment: Processed by Mailcrypt and GnuPG <http://www.gnupg.org/> iEYEARECAAYFAjyX6yYACgkQiJ/aUUS8zY76QwCdGZsJd1b+0qJ19LJ5TlvwI5fP kbcAniNe/5eiPnEUfGbddLCpyYD1+gmr =fLmk -----END PGP SIGNATURE----- |
From: Tim P. <ti...@co...> - 2002-03-20 01:20:38
|
[jo...@bo...] > Ok, looking at SourceForge and google this seems to be fixed in cvs > HEAD. Would it be possible to put the same patch into the cvs > python-2.2 branch, please? [1] > > Greetings, > Jochen > > Footnotes: > [1] If it is in there, it doesn't work for me with current python cvs > branch release22-maint. I still have to manually add -lieee. > (RedHat-7.0 with current updates.) I don't know what "current" meant to you at the time you wrote this. Michael Hudson did backport the patch into 2.2.1c1, which was released yesterday. So please try 2.2.1c1, and if you still have a problem, file a bug report about it on SourceForge. 2.2.1 final is expected in about a week. |
From: Jochen <jo...@un...> - 2002-03-20 01:09:54
|
The following message is a courtesy copy of an article that has been posted to comp.lang.python as well. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sat, 09 Mar 2002 00:17:40 -0500 Tim Peters wrote: Tim> I hope the bogus underflow problem is fixed in CVS Python now. Tim> Since my platform didn't have the problem (and still doesn't, of Tim> course), we won't know for sure until people try it and report Tim> back. Ok, looking at SourceForge and google this seems to be fixed in cvs HEAD. Would it be possible to put the same patch into the cvs python-2.2 branch, please? [1] Greetings, Jochen Footnotes: [1] If it is in there, it doesn't work for me with current python cvs branch release22-maint. I still have to manually add -lieee. (RedHat-7.0 with current updates.) - -- University of North Carolina phone: +1-919-962-4403 Department of Chemistry phone: +1-919-962-1579 Venable Hall CB#3290 (Kenan C148) fax: +1-919-843-6041 Chapel Hill, NC 27599, USA GnuPG key: 44BCCD8E -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6-cygwin-fcn-1 (Cygwin) Comment: Processed by Mailcrypt and GnuPG <http://www.gnupg.org/> iEYEARECAAYFAjyX4IAACgkQiJ/aUUS8zY52jgCbB69a8KZmCuk9MYIKzNu7EpBR 3fIAmQEYH1/ipB7OoiBcBPIAHev3dRlU =5l6n -----END PGP SIGNATURE----- |
From: Todd M. <jm...@st...> - 2002-03-19 22:17:08
|
David Ascher wrote: >Can I suggest that the generated files not be included in the source >tarball? I'm making sure that numarray and Numeric will be available in >our PPM repository, and it's confusing the build script when the >setup.py tries to overwrite files that are under source code control. > >--david ascher > >PS: PPMs for numarray 0.3 and Numeric 21 coming up soon. =) > >_______________________________________________ >Numpy-discussion mailing list >Num...@li... >https://lists.sourceforge.net/lists/listinfo/numpy-discussion > Yes. I'll tighten up the MANIFEST.in for the next release. Todd -- Todd Miller jm...@st... STSCI / SSG (410) 338 4576 |
From: David A. <Da...@Ac...> - 2002-03-19 22:04:09
|
Can I suggest that the generated files not be included in the source tarball? I'm making sure that numarray and Numeric will be available in our PPM repository, and it's confusing the build script when the setup.py tries to overwrite files that are under source code control. --david ascher PS: PPMs for numarray 0.3 and Numeric 21 coming up soon. =) |
From: Konrad H. <hi...@cn...> - 2002-03-19 11:08:03
|
a.s...@gm... (A.Schmolck) writes: > > > feature aspirations and divisions of labor of numpy/numarray and scipy are > ^^^^^^^ > Darn, I made a confusing mistake -- this should read _future_. Or perhaps __future__ ;-) > I personally agree with all your above points -- if you have a look at our > "dotblas"-patch mentioned earlier (see [1]), you will find that it aims to do And I didn't know even about this... > It is however inconvinient for the maintainers. Whether one should bother > including it in this or some other way depends, among the obvious question of There could be two teams, one maintaining a standard portable implementation, and another one taking care of optimization add-ons. From the user's point of view, what matters most is a single entry-point for finding everything that is available. > The monolithic approach is not entirely without its charms (remember > python's "batteries included" jinggle)? Apart from convinience Sure, but... That's the standard library. Everybody has it, in identical form, and its consistency and portability is taken care off by the Python development team. There can be only *one* standard library that works like this. I see no problem either with providing a larger integrated distribution for specific user communities. But such distribution and packaging strategies should be distinct from development projects. If I can get a certain package only as part of a juge distribution that I can't or don't want to install, then that package is effectively lost for me. Worse, if one package comes with its personalized version of another package (SciPy with NumPy), then I end up having to worry about internal conflicts within my installation. On the other hand, package interdependencies are a big problem in the Open Source community at large, and I have personally been bitten more than once by an incompatible change in NumPy that broke my modules. But I don't see any other solution than better communication between development teams. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hi...@cn... 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 ------------------------------------------------------------------------------- |