# [Scipy-svn] r4529 - trunk/scipy/sandbox/mkufunc/examples

scipy-svn@scip... scipy-svn@scip...
Sat Jul 5 11:18:47 CDT 2008

```Author: ilan
Date: 2008-07-05 11:18:46 -0500 (Sat, 05 Jul 2008)
New Revision: 4529

Modified:
trunk/scipy/sandbox/mkufunc/examples/mandel.py
Log:
Improved example

Modified: trunk/scipy/sandbox/mkufunc/examples/mandel.py
===================================================================
--- trunk/scipy/sandbox/mkufunc/examples/mandel.py	2008-07-04 18:28:31 UTC (rev 4528)
+++ trunk/scipy/sandbox/mkufunc/examples/mandel.py	2008-07-05 16:18:46 UTC (rev 4529)
@@ -6,18 +6,18 @@
-1
>>> mandel(10, 10)
1
->>> mandel(N.array([-1, 0, 10]), N.array([.3, 0, 10]))
+>>> mandel(array([-1, 0, 10]), array([.3, 0, 10]))
array([36, -1,  1])
"""
import hashlib

-import numpy as N
+from numpy import array
from scipy import weave

support_code = '''
#define D 1000

-long depth(double cr, double ci)
+long iterations(double cr, double ci)
{
long d = 1;
double zr=cr, zi=ci, zr2, zi2;
@@ -42,15 +42,10 @@
char *ip1 = args[1];
char *op = args[2];
n = dimensions[0];
-        double cr, ci;

for(i = 0; i < n; i++) {
-                cr = *(double *)ip0;
-                ci = *(double *)ip1;
-                long *out = (long *)op;
-
-                *out = depth(cr, ci);
-
+                *(long *)op = iterations(*(double *)ip0,
+                                         *(double *)ip1);
ip0 += is0;
ip1 += is1;
op += os;
@@ -80,7 +75,7 @@
1,             /* nout */
PyUFunc_None,  /* identity */
"mandel",      /* name */
-            "returns depth from cr, ci",         /* doc */
+            "returns number of iterations from cr, ci",    /* doc */
0);
''',
support_code=support_code,

```