[Scipy-svn] r4788 - trunk/scipy/stats

scipy-svn@scip... scipy-svn@scip...
Thu Oct 9 02:29:57 CDT 2008


Author: peridot
Date: 2008-10-09 02:29:54 -0500 (Thu, 09 Oct 2008)
New Revision: 4788

Added:
   trunk/scipy/stats/vonmises.py
   trunk/scipy/stats/vonmises_cython.c
   trunk/scipy/stats/vonmises_cython.pyx
Modified:
   trunk/scipy/stats/distributions.py
   trunk/scipy/stats/setup.py
Log:
Replaced implementation of von Mises CDF with cython implementation that should have better numerical performance. Note that for large k it uses array operations rather than cython code since we need scipy.stats.norm.cdf and scipy.special.i0. 

Note also that the C code is *not* automatically rebuilt when the cython code changes.


Modified: trunk/scipy/stats/distributions.py
===================================================================
--- trunk/scipy/stats/distributions.py	2008-10-09 05:26:59 UTC (rev 4787)
+++ trunk/scipy/stats/distributions.py	2008-10-09 07:29:54 UTC (rev 4788)
@@ -21,6 +21,7 @@
 from numpy import flatnonzero as nonzero
 from scipy.special import gammaln as gamln
 from copy import copy
+import vonmises_cython
 
 __all__ = [
            'rv_continuous',
@@ -3079,46 +3080,14 @@
 
 eps = numpy.finfo(float).eps
 
+
 class vonmises_gen(rv_continuous):
     def _rvs(self, b):
         return mtrand.vonmises(0.0, b, size=self._size)
     def _pdf(self, x, b):
         return exp(b*cos(x)) / (2*pi*special.i0(b))
     def _cdf(self, x, b):
-        x = arr(angle(exp(1j*x)))
-        eps2 = sqrt(eps)
-
-        c_xsimple = atleast_1d((b==0)&(x==x))
-        c_xiter = atleast_1d((b<100)&(b > 0)&(x==x))
-        c_xnormal = atleast_1d((b>=100)&(x==x))
-        c_bad = atleast_1d((b<=0) | (x != x))
-
-        indxiter = nonzero(c_xiter)
-        xiter = take(x, indxiter, 0)
-
-        vals = ones(len(c_xsimple),float)
-        putmask(vals, c_bad, nan)
-        putmask(vals, c_xsimple, x / 2.0/pi)
-        st = 1./sqrt(b-0.5)
-        st = where(isnan(st),0.0,st)
-        putmask(vals, c_xnormal, norm.cdf(x, scale=st))
-
-        biter = take(atleast_1d(b)*(x==x), indxiter, 0)
-        if len(xiter) > 0:
-            fac = special.i0(biter)
-            x2 = xiter
-            val = x2 / 2.0/ pi
-            for j in range(1,501):
-                trm1 = special.iv(j,biter)/j/fac
-                trm2 = sin(j*x2)/pi
-                val += trm1*trm2
-                if all(trm1 < eps2):
-                    break
-            if (j == 500):
-                print "Warning: did not converge..."
-            put(vals, indxiter, val)
-        vals[c_xiter]+=0.5
-        return numpy.clip(vals,0,1)
+        return vonmises_cython.von_mises_cdf(b,x)
     def _stats(self, b):
         return 0, None, 0, None
 vonmises = vonmises_gen(name='vonmises', longname="A Von Mises",

Modified: trunk/scipy/stats/setup.py
===================================================================
--- trunk/scipy/stats/setup.py	2008-10-09 05:26:59 UTC (rev 4787)
+++ trunk/scipy/stats/setup.py	2008-10-09 07:29:54 UTC (rev 4788)
@@ -2,6 +2,7 @@
 
 from os.path import join
 
+
 def configuration(parent_package='',top_path=None):
     from numpy.distutils.misc_util import Configuration
     config = Configuration('stats', parent_package, top_path)
@@ -18,6 +19,11 @@
         libraries=['statlib'],
     )
 
+    # add vonmises_cython module
+    config.add_extension('vonmises_cython',
+        sources=['vonmises_cython.c'], # FIXME: use cython source
+    )
+
     # add futil module
     config.add_extension('futil',
         sources=['futil.f'],

Added: trunk/scipy/stats/vonmises.py
===================================================================
--- trunk/scipy/stats/vonmises.py	2008-10-09 05:26:59 UTC (rev 4787)
+++ trunk/scipy/stats/vonmises.py	2008-10-09 07:29:54 UTC (rev 4788)
@@ -0,0 +1,45 @@
+import numpy as np
+import scipy.stats
+from scipy.special import i0
+import numpy.testing
+
+def von_mises_cdf_series(k,x,p):
+    x = float(x)
+    s = np.sin(x)
+    c = np.cos(x)
+    sn = np.sin(p*x)
+    cn = np.cos(p*x)
+    R = 0
+    V = 0
+    for n in range(p-1,0,-1):
+        sn, cn = sn*c - cn*s, cn*c + sn*s
+        R = 1./(2*n/k + R)
+        V = R*(sn/n+V)
+
+    return 0.5+x/(2*np.pi) + V/np.pi
+
+def von_mises_cdf_normalapprox(k,x,C1):
+    b = np.sqrt(2/np.pi)*np.exp(k)/i0(k)
+    z = b*np.sin(x/2.)
+    C = 24*k
+    chi = z - z**3/((C-2*z**2-16)/3.-(z**4+7/4.*z**2+167./2)/(C+C1-z**2+3))**2
+    return scipy.stats.norm.cdf(z)
+
+def von_mises_cdf(k,x):
+    ix = 2*np.pi*np.round(x/(2*np.pi))
+    x = x-ix
+    k = float(k)
+
+    # These values should give 12 decimal digits
+    CK=50
+    a = [28., 0.5, 100., 5.0]
+    C1 = 50.1
+
+    if k<CK:
+        p = int(np.ceil(a[0]+a[1]*k-a[2]/(k+a[3])))
+
+        F = np.clip(von_mises_cdf_series(k,x,p),0,1)
+    else:
+        F = von_mises_cdf_normalapprox(k,x,C1)
+
+    return F+ix

Added: trunk/scipy/stats/vonmises_cython.c
===================================================================
--- trunk/scipy/stats/vonmises_cython.c	2008-10-09 05:26:59 UTC (rev 4787)
+++ trunk/scipy/stats/vonmises_cython.c	2008-10-09 07:29:54 UTC (rev 4788)
@@ -0,0 +1,2666 @@
+/* Generated by Cython 0.9.8.1.1 on Thu Oct  9 03:26:22 2008 */
+
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#include "structmember.h"
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#ifndef DL_EXPORT
+  #define DL_EXPORT(t) t
+#endif
+#if PY_VERSION_HEX < 0x02040000
+  #define METH_COEXIST 0
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  typedef int Py_ssize_t;
+  #define PY_SSIZE_T_MAX INT_MAX
+  #define PY_SSIZE_T_MIN INT_MIN
+  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
+  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
+  #define PyNumber_Index(o)    PyNumber_Int(o)
+  #define PyIndex_Check(o)     PyNumber_Check(o)
+#endif
+#if PY_VERSION_HEX < 0x02060000
+  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
+  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
+  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
+  #define PyVarObject_HEAD_INIT(type, size) \
+          PyObject_HEAD_INIT(type) size,
+  #define PyType_Modified(t)
+
+  typedef struct {
+       void *buf;
+       Py_ssize_t len;
+       int readonly;
+       const char *format;
+       int ndim;
+       Py_ssize_t *shape;
+       Py_ssize_t *strides;
+       Py_ssize_t *suboffsets;
+       Py_ssize_t itemsize;
+       void *internal;
+  } Py_buffer;
+
+  #define PyBUF_SIMPLE 0
+  #define PyBUF_WRITABLE 0x0001
+  #define PyBUF_LOCK 0x0002
+  #define PyBUF_FORMAT 0x0004
+  #define PyBUF_ND 0x0008
+  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
+  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
+  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
+  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
+  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
+
+#endif
+#if PY_MAJOR_VERSION < 3
+  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
+#else
+  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define Py_TPFLAGS_CHECKTYPES 0
+  #define Py_TPFLAGS_HAVE_INDEX 0
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBaseString_Type            PyUnicode_Type
+  #define PyString_Type                PyBytes_Type
+  #define PyInt_Type                   PyLong_Type
+  #define PyInt_Check(op)              PyLong_Check(op)
+  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
+  #define PyInt_FromString             PyLong_FromString
+  #define PyInt_FromUnicode            PyLong_FromUnicode
+  #define PyInt_FromLong               PyLong_FromLong
+  #define PyInt_FromSize_t             PyLong_FromSize_t
+  #define PyInt_FromSsize_t            PyLong_FromSsize_t
+  #define PyInt_AsLong                 PyLong_AsLong
+  #define PyInt_AS_LONG                PyLong_AS_LONG
+  #define PyInt_AsSsize_t              PyLong_AsSsize_t
+  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
+  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+#else
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
+  #define PyBytes_Type                 PyString_Type
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
+#endif
+#if !defined(WIN32) && !defined(MS_WINDOWS)
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+#else
+  #define _USE_MATH_DEFINES
+#endif
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+#include <math.h>
+#define __PYX_HAVE_API__scipy__stats__vonmises_cython
+#include "math.h"
+#include "numpy/arrayobject.h"
+
+
+#ifdef __GNUC__
+#define INLINE __inline__
+#elif _WIN32
+#define INLINE __inline
+#else
+#define INLINE 
+#endif
+
+typedef struct {PyObject **p; char *s; long n; char is_unicode; char intern; char is_identifier;} __Pyx_StringTabEntry; /*proto*/
+
+
+
+static int __pyx_skip_dispatch = 0;
+
+
+/* Type Conversion Predeclarations */
+
+#if PY_MAJOR_VERSION < 3
+#define __Pyx_PyBytes_FromString PyString_FromString
+#define __Pyx_PyBytes_AsString   PyString_AsString
+#else
+#define __Pyx_PyBytes_FromString PyBytes_FromString
+#define __Pyx_PyBytes_AsString   PyBytes_AsString
+#endif
+
+#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
+static INLINE int __Pyx_PyObject_IsTrue(PyObject* x);
+static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x);
+static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x);
+static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b);
+
+#define __pyx_PyInt_AsLong(x) (PyInt_CheckExact(x) ? PyInt_AS_LONG(x) : PyInt_AsLong(x))
+#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+
+static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x);
+static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x);
+static INLINE char __pyx_PyInt_char(PyObject* x);
+static INLINE short __pyx_PyInt_short(PyObject* x);
+static INLINE int __pyx_PyInt_int(PyObject* x);
+static INLINE long __pyx_PyInt_long(PyObject* x);
+static INLINE signed char __pyx_PyInt_signed_char(PyObject* x);
+static INLINE signed short __pyx_PyInt_signed_short(PyObject* x);
+static INLINE signed int __pyx_PyInt_signed_int(PyObject* x);
+static INLINE signed long __pyx_PyInt_signed_long(PyObject* x);
+static INLINE long double __pyx_PyInt_long_double(PyObject* x);
+#ifdef __GNUC__
+/* Test for GCC > 2.95 */
+#if __GNUC__ > 2 ||               (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
+#define likely(x)   __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* __GNUC__ > 2 ... */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ > 2 ... */
+#else /* __GNUC__ */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ */
+    
+static PyObject *__pyx_m;
+static PyObject *__pyx_b;
+static PyObject *__pyx_empty_tuple;
+static int __pyx_lineno;
+static int __pyx_clineno = 0;
+static const char * __pyx_cfilenm= __FILE__;
+static const char *__pyx_filename;
+static const char **__pyx_f;
+static INLINE void __Pyx_SafeReleaseBuffer(PyObject* obj, Py_buffer* info);
+static INLINE void __Pyx_ZeroBuffer(Py_buffer* buf); /*proto*/
+static INLINE const char* __Pyx_ConsumeWhitespace(const char* ts); /*proto*/
+static INLINE const char* __Pyx_BufferTypestringCheckEndian(const char* ts); /*proto*/
+static void __Pyx_BufferNdimError(Py_buffer* buffer, int expected_ndim); /*proto*/
+static const char* __Pyx_BufferTypestringCheck_item_double(const char* ts); /*proto*/
+
+static int __Pyx_GetBuffer_double(PyObject* obj, Py_buffer* buf, int flags, int nd); /*proto*/
+
+static void __Pyx_RaiseBufferFallbackError(void); /*proto*/
+#define __Pyx_BufPtrStrided1d(buf, i0, s0) ((char*)buf + i0 * s0)
+
+static INLINE void __Pyx_RaiseArgtupleTooLong(Py_ssize_t num_expected, Py_ssize_t num_found); /*proto*/
+#if (PY_MAJOR_VERSION < 3) && !(Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER)
+static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
+static void __Pyx_ReleaseBuffer(PyObject *obj, Py_buffer *view);
+#else
+#define __Pyx_GetBuffer PyObject_GetBuffer
+#define __Pyx_ReleaseBuffer PyObject_ReleaseBuffer
+#endif
+
+Py_ssize_t __Pyx_zeros[] = {0};
+Py_ssize_t __Pyx_minusones[] = {-1};
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
+
+static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
+static int __Pyx_EndUnpack(PyObject *); /*proto*/
+
+static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
+
+static INLINE PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i, int is_unsigned) {
+    PyObject *r;
+    if (PyList_CheckExact(o) && 0 <= i && i < PyList_GET_SIZE(o)) {
+        r = PyList_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (PyTuple_CheckExact(o) && 0 <= i && i < PyTuple_GET_SIZE(o)) {
+        r = PyTuple_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0) || !is_unsigned))
+        r = PySequence_GetItem(o, i);
+    else {
+        PyObject *j = (likely(i >= 0) || !is_unsigned) ? PyInt_FromLong(i) : PyLong_FromUnsignedLongLong((sizeof(unsigned long long) > sizeof(Py_ssize_t) ? (1ULL << (sizeof(Py_ssize_t)*8)) : 0) + i);
+        if (!j)
+            return 0;
+        r = PyObject_GetItem(o, j);
+        Py_DECREF(j);
+    }
+    return r;
+}
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
+static void __Pyx_WriteUnraisable(const char *name); /*proto*/
+
+static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size);  /*proto*/
+
+static PyObject *__Pyx_ImportModule(char *name); /*proto*/
+
+static void __Pyx_AddTraceback(const char *funcname); /*proto*/
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+
+/* Type declarations */
+
+typedef npy_int8 __pyx_t_5numpy_int8_t;
+
+typedef npy_int16 __pyx_t_5numpy_int16_t;
+
+typedef npy_int32 __pyx_t_5numpy_int32_t;
+
+typedef npy_int64 __pyx_t_5numpy_int64_t;
+
+typedef npy_uint8 __pyx_t_5numpy_uint8_t;
+
+typedef npy_uint16 __pyx_t_5numpy_uint16_t;
+
+typedef npy_uint32 __pyx_t_5numpy_uint32_t;
+
+typedef npy_uint64 __pyx_t_5numpy_uint64_t;
+
+typedef npy_float32 __pyx_t_5numpy_float32_t;
+
+typedef npy_float64 __pyx_t_5numpy_float64_t;
+
+typedef npy_long __pyx_t_5numpy_int_t;
+
+typedef npy_longlong __pyx_t_5numpy_long_t;
+
+typedef npy_ulong __pyx_t_5numpy_uint_t;
+
+typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
+
+typedef npy_double __pyx_t_5numpy_float_t;
+
+typedef npy_double __pyx_t_5numpy_double_t;
+
+typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
+/* Module declarations from numpy */
+
+/* Module declarations from numpy */
+
+static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
+/* Module declarations from cython */
+
+/* Module declarations from scipy.stats.vonmises_cython */
+
+static double __pyx_f_5scipy_5stats_15vonmises_cython_von_mises_cdf_series(double, double, unsigned int); /*proto*/
+
+
+/* Implementation of scipy.stats.vonmises_cython */
+static PyObject *__pyx_int_2;
+static PyObject *__pyx_int_24;
+static PyObject *__pyx_int_3;
+static PyObject *__pyx_int_16;
+static PyObject *__pyx_int_4;
+static PyObject *__pyx_int_0;
+static char __pyx_k_numpy[] = "numpy";
+static PyObject *__pyx_kp_numpy;
+static char __pyx_k_np[] = "np";
+static PyObject *__pyx_kp_np;
+static char __pyx_k_17[] = "scipy.stats";
+static PyObject *__pyx_kp_17;
+static char __pyx_k_scipy[] = "scipy";
+static PyObject *__pyx_kp_scipy;
+static char __pyx_k_18[] = "scipy.special";
+static PyObject *__pyx_kp_18;
+static char __pyx_k_i0[] = "i0";
+static PyObject *__pyx_kp_i0;
+static char __pyx_k_19[] = "numpy.testing";
+static PyObject *__pyx_kp_19;
+static char __pyx_k_pi[] = "pi";
+static PyObject *__pyx_kp_pi;
+static char __pyx_k_sqrt[] = "sqrt";
+static PyObject *__pyx_kp_sqrt;
+static char __pyx_k_exp[] = "exp";
+static PyObject *__pyx_kp_exp;
+static char __pyx_k_sin[] = "sin";
+static PyObject *__pyx_kp_sin;
+static char __pyx_k_stats[] = "stats";
+static PyObject *__pyx_kp_stats;
+static char __pyx_k_norm[] = "norm";
+static PyObject *__pyx_kp_norm;
+static char __pyx_k_cdf[] = "cdf";
+static PyObject *__pyx_kp_cdf;
+static char __pyx_k_asarray[] = "asarray";
+static PyObject *__pyx_kp_asarray;
+static char __pyx_k_ndim[] = "ndim";
+static PyObject *__pyx_kp_ndim;
+static char __pyx_k_20[] = "atleast_1d";
+static PyObject *__pyx_kp_20;
+static char __pyx_k_round[] = "round";
+static PyObject *__pyx_kp_round;
+static char __pyx_k_broadcast_arrays[] = "broadcast_arrays";
+static PyObject *__pyx_kp_broadcast_arrays;
+static char __pyx_k_empty[] = "empty";
+static PyObject *__pyx_kp_empty;
+static char __pyx_k_shape[] = "shape";
+static PyObject *__pyx_kp_shape;
+static char __pyx_k_dtype[] = "dtype";
+static PyObject *__pyx_kp_dtype;
+static char __pyx_k_float[] = "float";
+static PyObject *__pyx_kp_float;
+static char __pyx_k_astype[] = "astype";
+static PyObject *__pyx_kp_astype;
+static char __pyx_k_21[] = "von_mises_cdf_normalapprox";
+static PyObject *__pyx_kp_21;
+static char __pyx_k___getbuffer__[] = "__getbuffer__";
+static PyObject *__pyx_kp___getbuffer__;
+static char __pyx_k_RuntimeError[] = "RuntimeError";
+static PyObject *__pyx_kp_RuntimeError;
+static char __pyx_k_ValueError[] = "ValueError";
+static PyObject *__pyx_kp_ValueError;
+static PyObject *__pyx_kp_1;
+static PyObject *__pyx_kp_16;
+static PyObject *__pyx_builtin_RuntimeError;
+static PyObject *__pyx_builtin_ValueError;
+static char __pyx_k_1[] = "Py_intptr_t and Py_ssize_t differs in size, numpy.pxd does not support this";
+static char __pyx_k_2[] = "b";
+static char __pyx_k_3[] = "B";
+static char __pyx_k_4[] = "h";
+static char __pyx_k_5[] = "H";
+static char __pyx_k_6[] = "i";
+static char __pyx_k_7[] = "I";
+static char __pyx_k_8[] = "l";
+static char __pyx_k_9[] = "L";
+static char __pyx_k_10[] = "q";
+static char __pyx_k_11[] = "Q";
+static char __pyx_k_12[] = "f";
+static char __pyx_k_13[] = "d";
+static char __pyx_k_14[] = "g";
+static char __pyx_k_15[] = "O";
+static char __pyx_k_16[] = "only objects, int and float dtypes supported for ndarray buffer access so far (dtype is %d)";
+
+/* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":12
+ * 
+ * 
+ * cdef double von_mises_cdf_series(double k,double x,unsigned int p):             # <<<<<<<<<<<<<<
+ *     cdef double s, c, sn, cn, R, V
+ *     cdef unsigned int n
+ */
+
+static  double __pyx_f_5scipy_5stats_15vonmises_cython_von_mises_cdf_series(double __pyx_v_k, double __pyx_v_x, unsigned int __pyx_v_p) {
+  double __pyx_v_s;
+  double __pyx_v_c;
+  double __pyx_v_sn;
+  double __pyx_v_cn;
+  double __pyx_v_R;
+  double __pyx_v_V;
+  unsigned int __pyx_v_n;
+  double __pyx_r;
+  double __pyx_1;
+  double __pyx_2;
+  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_4 = 0;
+  PyObject *__pyx_5 = 0;
+  PyObject *__pyx_6 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":15
+ *     cdef double s, c, sn, cn, R, V
+ *     cdef unsigned int n
+ *     s = sin(x)             # <<<<<<<<<<<<<<
+ *     c = cos(x)
+ *     sn = sin(p*x)
+ */
+  __pyx_v_s = sin(__pyx_v_x);
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":16
+ *     cdef unsigned int n
+ *     s = sin(x)
+ *     c = cos(x)             # <<<<<<<<<<<<<<
+ *     sn = sin(p*x)
+ *     cn = cos(p*x)
+ */
+  __pyx_v_c = cos(__pyx_v_x);
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":17
+ *     s = sin(x)
+ *     c = cos(x)
+ *     sn = sin(p*x)             # <<<<<<<<<<<<<<
+ *     cn = cos(p*x)
+ *     R = 0
+ */
+  __pyx_v_sn = sin((__pyx_v_p * __pyx_v_x));
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":18
+ *     c = cos(x)
+ *     sn = sin(p*x)
+ *     cn = cos(p*x)             # <<<<<<<<<<<<<<
+ *     R = 0
+ *     V = 0
+ */
+  __pyx_v_cn = cos((__pyx_v_p * __pyx_v_x));
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":19
+ *     sn = sin(p*x)
+ *     cn = cos(p*x)
+ *     R = 0             # <<<<<<<<<<<<<<
+ *     V = 0
+ *     for n in range(p-1,0,-1):
+ */
+  __pyx_v_R = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":20
+ *     cn = cos(p*x)
+ *     R = 0
+ *     V = 0             # <<<<<<<<<<<<<<
+ *     for n in range(p-1,0,-1):
+ *         sn, cn = sn*c - cn*s, cn*c + sn*s
+ */
+  __pyx_v_V = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":21
+ *     R = 0
+ *     V = 0
+ *     for n in range(p-1,0,-1):             # <<<<<<<<<<<<<<
+ *         sn, cn = sn*c - cn*s, cn*c + sn*s
+ *         R = 1./(2*n/k + R)
+ */
+  for (__pyx_v_n = (__pyx_v_p - 1); __pyx_v_n > 0; __pyx_v_n-=1) {
+
+    /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":22
+ *     V = 0
+ *     for n in range(p-1,0,-1):
+ *         sn, cn = sn*c - cn*s, cn*c + sn*s             # <<<<<<<<<<<<<<
+ *         R = 1./(2*n/k + R)
+ *         V = R*(sn/n+V)
+ */
+    __pyx_1 = ((__pyx_v_sn * __pyx_v_c) - (__pyx_v_cn * __pyx_v_s));
+    __pyx_2 = ((__pyx_v_cn * __pyx_v_c) + (__pyx_v_sn * __pyx_v_s));
+    __pyx_v_sn = __pyx_1;
+    __pyx_v_cn = __pyx_2;
+
+    /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":23
+ *     for n in range(p-1,0,-1):
+ *         sn, cn = sn*c - cn*s, cn*c + sn*s
+ *         R = 1./(2*n/k + R)             # <<<<<<<<<<<<<<
+ *         V = R*(sn/n+V)
+ * 
+ */
+    __pyx_v_R = (1. / (((2 * __pyx_v_n) / __pyx_v_k) + __pyx_v_R));
+
+    /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":24
+ *         sn, cn = sn*c - cn*s, cn*c + sn*s
+ *         R = 1./(2*n/k + R)
+ *         V = R*(sn/n+V)             # <<<<<<<<<<<<<<
+ * 
+ *     return 0.5+x/(2*np.pi) + V/np.pi
+ */
+    __pyx_v_V = (__pyx_v_R * ((__pyx_v_sn / __pyx_v_n) + __pyx_v_V));
+  }
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":26
+ *         V = R*(sn/n+V)
+ * 
+ *     return 0.5+x/(2*np.pi) + V/np.pi             # <<<<<<<<<<<<<<
+ * 
+ * def von_mises_cdf_normalapprox(k,x,C1):
+ */
+  __pyx_3 = PyFloat_FromDouble(0.5); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_4 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_kp_pi); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_5); __pyx_5 = 0;
+  __pyx_5 = PyNumber_Multiply(__pyx_int_2, __pyx_6); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_6); __pyx_6 = 0;
+  __pyx_6 = __Pyx_PyNumber_Divide(__pyx_4, __pyx_5); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  Py_DECREF(__pyx_5); __pyx_5 = 0;
+  __pyx_4 = PyNumber_Add(__pyx_3, __pyx_6); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  Py_DECREF(__pyx_6); __pyx_6 = 0;
+  __pyx_5 = PyFloat_FromDouble(__pyx_v_V); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_6 = PyObject_GetAttr(__pyx_3, __pyx_kp_pi); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_3 = __Pyx_PyNumber_Divide(__pyx_5, __pyx_6); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_5); __pyx_5 = 0;
+  Py_DECREF(__pyx_6); __pyx_6 = 0;
+  __pyx_5 = PyNumber_Add(__pyx_4, __pyx_3); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_1 = __pyx_PyFloat_AsDouble(__pyx_5); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_5); __pyx_5 = 0;
+  __pyx_r = __pyx_1;
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  Py_XDECREF(__pyx_3);
+  Py_XDECREF(__pyx_4);
+  Py_XDECREF(__pyx_5);
+  Py_XDECREF(__pyx_6);
+  __Pyx_WriteUnraisable("scipy.stats.vonmises_cython.von_mises_cdf_series");
+  __pyx_r = 0;
+  __pyx_L0:;
+  return __pyx_r;
+}
+
+/* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":28
+ *     return 0.5+x/(2*np.pi) + V/np.pi
+ * 
+ * def von_mises_cdf_normalapprox(k,x,C1):             # <<<<<<<<<<<<<<
+ *     b = np.sqrt(2/np.pi)*np.exp(k)/i0(k)
+ *     z = b*np.sin(x/2.)
+ */
+
+static PyObject *__pyx_pf_5scipy_5stats_15vonmises_cython_von_mises_cdf_normalapprox(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_5scipy_5stats_15vonmises_cython_von_mises_cdf_normalapprox(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_k = 0;
+  PyObject *__pyx_v_x = 0;
+  PyObject *__pyx_v_C1 = 0;
+  PyObject *__pyx_v_b;
+  PyObject *__pyx_v_z;
+  PyObject *__pyx_v_C;
+  PyObject *__pyx_v_chi;
+  PyObject *__pyx_r;
+  PyObject *__pyx_1 = 0;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_4 = 0;
+  PyObject *__pyx_5 = 0;
+  PyObject *__pyx_6 = 0;
+  static char *__pyx_argnames[] = {"k","x","C1",0};
+  __pyx_self = __pyx_self;
+  if (likely(!__pyx_kwds) && likely(PyTuple_GET_SIZE(__pyx_args) == 3)) {
+    __pyx_v_k = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_x = PyTuple_GET_ITEM(__pyx_args, 1);
+    __pyx_v_C1 = PyTuple_GET_ITEM(__pyx_args, 2);
+  }
+  else {
+    if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_k, &__pyx_v_x, &__pyx_v_C1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4;
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("scipy.stats.vonmises_cython.von_mises_cdf_normalapprox");
+  return NULL;
+  __pyx_L4:;
+  __pyx_v_b = Py_None; Py_INCREF(Py_None);
+  __pyx_v_z = Py_None; Py_INCREF(Py_None);
+  __pyx_v_C = Py_None; Py_INCREF(Py_None);
+  __pyx_v_chi = Py_None; Py_INCREF(Py_None);
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":29
+ * 
+ * def von_mises_cdf_normalapprox(k,x,C1):
+ *     b = np.sqrt(2/np.pi)*np.exp(k)/i0(k)             # <<<<<<<<<<<<<<
+ *     z = b*np.sin(x/2.)
+ *     C = 24*k
+ */
+  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_sqrt); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_kp_pi); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  __pyx_1 = __Pyx_PyNumber_Divide(__pyx_int_2, __pyx_3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
+  __pyx_1 = 0;
+  __pyx_1 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_exp); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_v_k);
+  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_k);
+  __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
+  __pyx_3 = PyNumber_Multiply(__pyx_1, __pyx_4); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_i0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_v_k);
+  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_k);
+  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
+  __pyx_2 = __Pyx_PyNumber_Divide(__pyx_3, __pyx_4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  Py_DECREF(__pyx_v_b);
+  __pyx_v_b = __pyx_2;
+  __pyx_2 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":30
+ * def von_mises_cdf_normalapprox(k,x,C1):
+ *     b = np.sqrt(2/np.pi)*np.exp(k)/i0(k)
+ *     z = b*np.sin(x/2.)             # <<<<<<<<<<<<<<
+ *     C = 24*k
+ *     chi = z - z**3/((C-2*z**2-16)/3.-(z**4+7/4.*z**2+167./2)/(C+C1-z**2+3))**2
+ */
+  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_kp_sin); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  __pyx_4 = PyFloat_FromDouble(2.); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = __Pyx_PyNumber_Divide(__pyx_v_x, __pyx_4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
+  __pyx_2 = 0;
+  __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
+  __pyx_2 = PyNumber_Multiply(__pyx_v_b, __pyx_4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  Py_DECREF(__pyx_v_z);
+  __pyx_v_z = __pyx_2;
+  __pyx_2 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":31
+ *     b = np.sqrt(2/np.pi)*np.exp(k)/i0(k)
+ *     z = b*np.sin(x/2.)
+ *     C = 24*k             # <<<<<<<<<<<<<<
+ *     chi = z - z**3/((C-2*z**2-16)/3.-(z**4+7/4.*z**2+167./2)/(C+C1-z**2+3))**2
+ *     return scipy.stats.norm.cdf(z)
+ */
+  __pyx_3 = PyNumber_Multiply(__pyx_int_24, __pyx_v_k); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_v_C);
+  __pyx_v_C = __pyx_3;
+  __pyx_3 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":32
+ *     z = b*np.sin(x/2.)
+ *     C = 24*k
+ *     chi = z - z**3/((C-2*z**2-16)/3.-(z**4+7/4.*z**2+167./2)/(C+C1-z**2+3))**2             # <<<<<<<<<<<<<<
+ *     return scipy.stats.norm.cdf(z)
+ * 
+ */
+  __pyx_1 = PyNumber_Power(__pyx_v_z, __pyx_int_3, Py_None); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_4 = PyNumber_Power(__pyx_v_z, __pyx_int_2, Py_None); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = PyNumber_Multiply(__pyx_int_2, __pyx_4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  __pyx_3 = PyNumber_Subtract(__pyx_v_C, __pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_4 = PyNumber_Subtract(__pyx_3, __pyx_int_16); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_2 = PyFloat_FromDouble(3.); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_3 = __Pyx_PyNumber_Divide(__pyx_4, __pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_4 = PyNumber_Power(__pyx_v_z, __pyx_int_4, Py_None); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = PyFloat_FromDouble((7 / 4.)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_5 = PyNumber_Power(__pyx_v_z, __pyx_int_2, Py_None); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_6 = PyNumber_Multiply(__pyx_2, __pyx_5); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  Py_DECREF(__pyx_5); __pyx_5 = 0;
+  __pyx_2 = PyNumber_Add(__pyx_4, __pyx_6); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  Py_DECREF(__pyx_6); __pyx_6 = 0;
+  __pyx_5 = PyFloat_FromDouble((167. / 2)); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_4 = PyNumber_Add(__pyx_2, __pyx_5); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  Py_DECREF(__pyx_5); __pyx_5 = 0;
+  __pyx_6 = PyNumber_Add(__pyx_v_C, __pyx_v_C1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = PyNumber_Power(__pyx_v_z, __pyx_int_2, Py_None); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_5 = PyNumber_Subtract(__pyx_6, __pyx_2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_6); __pyx_6 = 0;
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_6 = PyNumber_Add(__pyx_5, __pyx_int_3); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_5); __pyx_5 = 0;
+  __pyx_2 = __Pyx_PyNumber_Divide(__pyx_4, __pyx_6); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  Py_DECREF(__pyx_6); __pyx_6 = 0;
+  __pyx_5 = PyNumber_Subtract(__pyx_3, __pyx_2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_4 = PyNumber_Power(__pyx_5, __pyx_int_2, Py_None); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_5); __pyx_5 = 0;
+  __pyx_6 = __Pyx_PyNumber_Divide(__pyx_1, __pyx_4); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  __pyx_3 = PyNumber_Subtract(__pyx_v_z, __pyx_6); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_6); __pyx_6 = 0;
+  Py_DECREF(__pyx_v_chi);
+  __pyx_v_chi = __pyx_3;
+  __pyx_3 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":33
+ *     C = 24*k
+ *     chi = z - z**3/((C-2*z**2-16)/3.-(z**4+7/4.*z**2+167./2)/(C+C1-z**2+3))**2
+ *     return scipy.stats.norm.cdf(z)             # <<<<<<<<<<<<<<
+ * 
+ * cimport cython
+ */
+  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_scipy); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_kp_stats); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_1 = PyObject_GetAttr(__pyx_5, __pyx_kp_norm); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_5); __pyx_5 = 0;
+  __pyx_4 = PyObject_GetAttr(__pyx_1, __pyx_kp_cdf); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_v_z);
+  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_z);
+  __pyx_3 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_4); __pyx_4 = 0;
+  Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
+  __pyx_r = __pyx_3;
+  __pyx_3 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  Py_XDECREF(__pyx_1);
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  Py_XDECREF(__pyx_4);
+  Py_XDECREF(__pyx_5);
+  Py_XDECREF(__pyx_6);
+  __Pyx_AddTraceback("scipy.stats.vonmises_cython.von_mises_cdf_normalapprox");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_b);
+  Py_DECREF(__pyx_v_z);
+  Py_DECREF(__pyx_v_C);
+  Py_DECREF(__pyx_v_chi);
+  return __pyx_r;
+}
+
+/* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":37
+ * cimport cython
+ * @cython.boundscheck(False)
+ * def von_mises_cdf(k,x):             # <<<<<<<<<<<<<<
+ *     cdef np.ndarray[double, ndim=1] temp, temp_xs, temp_ks
+ *     cdef unsigned int i, p
+ */
+
+static PyObject *__pyx_pf_5scipy_5stats_15vonmises_cython_von_mises_cdf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_5scipy_5stats_15vonmises_cython_von_mises_cdf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_k = 0;
+  PyObject *__pyx_v_x = 0;
+  PyArrayObject *__pyx_v_temp;
+  PyArrayObject *__pyx_v_temp_xs;
+  PyArrayObject *__pyx_v_temp_ks;
+  unsigned int __pyx_v_i;
+  unsigned int __pyx_v_p;
+  double __pyx_v_a1;
+  double __pyx_v_a2;
+  double __pyx_v_a3;
+  double __pyx_v_a4;
+  double __pyx_v_C1;
+  double __pyx_v_CK;
+  PyObject *__pyx_v_zerodim;
+  PyObject *__pyx_v_ix;
+  PyObject *__pyx_v_bx;
+  PyObject *__pyx_v_bk;
+  PyObject *__pyx_v_result;
+  PyObject *__pyx_v_c_small_k;
+  Py_buffer __pyx_bstruct_temp;
+  Py_ssize_t __pyx_bstride_0_temp = 0;
+  Py_ssize_t __pyx_bshape_0_temp = 0;
+  Py_buffer __pyx_bstruct_temp_xs;
+  Py_ssize_t __pyx_bstride_0_temp_xs = 0;
+  Py_ssize_t __pyx_bshape_0_temp_xs = 0;
+  Py_buffer __pyx_bstruct_temp_ks;
+  Py_ssize_t __pyx_bstride_0_temp_ks = 0;
+  Py_ssize_t __pyx_bshape_0_temp_ks = 0;
+  PyObject *__pyx_r;
+  PyObject *__pyx_1 = 0;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  int __pyx_4;
+  double __pyx_5;
+  double __pyx_6;
+  double __pyx_7;
+  double __pyx_8;
+  PyObject *__pyx_9 = 0;
+  PyObject *__pyx_10 = 0;
+  Py_ssize_t __pyx_11 = 0;
+  int __pyx_12;
+  PyArrayObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  unsigned int __pyx_t_6;
+  unsigned int __pyx_t_7;
+  unsigned int __pyx_t_8;
+  unsigned int __pyx_t_9;
+  unsigned int __pyx_t_10;
+  unsigned int __pyx_t_11;
+  unsigned int __pyx_t_12;
+  unsigned int __pyx_t_13;
+  unsigned int __pyx_t_14;
+  static char *__pyx_argnames[] = {"k","x",0};
+  __pyx_self = __pyx_self;
+  if (likely(!__pyx_kwds) && likely(PyTuple_GET_SIZE(__pyx_args) == 2)) {
+    __pyx_v_k = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_x = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  else {
+    if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_k, &__pyx_v_x))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4;
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("scipy.stats.vonmises_cython.von_mises_cdf");
+  return NULL;
+  __pyx_L4:;
+  Py_INCREF(__pyx_v_k);
+  Py_INCREF(__pyx_v_x);
+  __pyx_v_temp = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
+  __pyx_bstruct_temp.buf = NULL;
+  __pyx_v_temp_xs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
+  __pyx_bstruct_temp_xs.buf = NULL;
+  __pyx_v_temp_ks = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
+  __pyx_bstruct_temp_ks.buf = NULL;
+  __pyx_v_zerodim = Py_None; Py_INCREF(Py_None);
+  __pyx_v_ix = Py_None; Py_INCREF(Py_None);
+  __pyx_v_bx = Py_None; Py_INCREF(Py_None);
+  __pyx_v_bk = Py_None; Py_INCREF(Py_None);
+  __pyx_v_result = Py_None; Py_INCREF(Py_None);
+  __pyx_v_c_small_k = Py_None; Py_INCREF(Py_None);
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":42
+ *     cdef double a1, a2, a3, a4, C1, CK
+ *     #k,x = np.broadcast_arrays(np.asarray(k),np.asarray(x))
+ *     k = np.asarray(k)             # <<<<<<<<<<<<<<
+ *     x = np.asarray(x)
+ *     zerodim = k.ndim==0 and x.ndim==0
+ */
+  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_asarray); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_v_k);
+  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_k);
+  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
+  Py_DECREF(__pyx_v_k);
+  __pyx_v_k = __pyx_3;
+  __pyx_3 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":43
+ *     #k,x = np.broadcast_arrays(np.asarray(k),np.asarray(x))
+ *     k = np.asarray(k)
+ *     x = np.asarray(x)             # <<<<<<<<<<<<<<
+ *     zerodim = k.ndim==0 and x.ndim==0
+ * 
+ */
+  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_kp_asarray); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_v_x);
+  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_x);
+  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+  Py_DECREF(__pyx_v_x);
+  __pyx_v_x = __pyx_2;
+  __pyx_2 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":44
+ *     k = np.asarray(k)
+ *     x = np.asarray(x)
+ *     zerodim = k.ndim==0 and x.ndim==0             # <<<<<<<<<<<<<<
+ * 
+ *     k = np.atleast_1d(k)
+ */
+  __pyx_3 = PyObject_GetAttr(__pyx_v_k, __pyx_kp_ndim); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_1 = PyObject_RichCompare(__pyx_3, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_4) {
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    __pyx_2 = PyObject_GetAttr(__pyx_v_x, __pyx_kp_ndim); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_1 = PyObject_RichCompare(__pyx_2, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+  }
+  Py_DECREF(__pyx_v_zerodim);
+  __pyx_v_zerodim = __pyx_1;
+  __pyx_1 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":46
+ *     zerodim = k.ndim==0 and x.ndim==0
+ * 
+ *     k = np.atleast_1d(k)             # <<<<<<<<<<<<<<
+ *     x = np.atleast_1d(x)
+ *     ix = np.round(x/(2*np.pi))
+ */
+  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_kp_20); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_v_k);
+  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_k);
+  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
+  Py_DECREF(__pyx_v_k);
+  __pyx_v_k = __pyx_3;
+  __pyx_3 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":47
+ * 
+ *     k = np.atleast_1d(k)
+ *     x = np.atleast_1d(x)             # <<<<<<<<<<<<<<
+ *     ix = np.round(x/(2*np.pi))
+ *     x = x-ix
+ */
+  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_kp_20); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_v_x);
+  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_x);
+  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+  Py_DECREF(__pyx_v_x);
+  __pyx_v_x = __pyx_2;
+  __pyx_2 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":48
+ *     k = np.atleast_1d(k)
+ *     x = np.atleast_1d(x)
+ *     ix = np.round(x/(2*np.pi))             # <<<<<<<<<<<<<<
+ *     x = x-ix
+ * 
+ */
+  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_kp_round); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_kp_pi); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_2 = PyNumber_Multiply(__pyx_int_2, __pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  __pyx_1 = __Pyx_PyNumber_Divide(__pyx_v_x, __pyx_2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
+  __pyx_1 = 0;
+  __pyx_1 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
+  Py_DECREF(__pyx_v_ix);
+  __pyx_v_ix = __pyx_1;
+  __pyx_1 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":49
+ *     x = np.atleast_1d(x)
+ *     ix = np.round(x/(2*np.pi))
+ *     x = x-ix             # <<<<<<<<<<<<<<
+ * 
+ *     # These values should give 12 decimal digits
+ */
+  __pyx_3 = PyNumber_Subtract(__pyx_v_x, __pyx_v_ix); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_v_x);
+  __pyx_v_x = __pyx_3;
+  __pyx_3 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":52
+ * 
+ *     # These values should give 12 decimal digits
+ *     CK=50             # <<<<<<<<<<<<<<
+ *     a1, a2, a3, a4 = [28., 0.5, 100., 5.0]
+ *     C1 = 50.1
+ */
+  __pyx_v_CK = 50;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":53
+ *     # These values should give 12 decimal digits
+ *     CK=50
+ *     a1, a2, a3, a4 = [28., 0.5, 100., 5.0]             # <<<<<<<<<<<<<<
+ *     C1 = 50.1
+ * 
+ */
+  __pyx_5 = 28.;
+  __pyx_6 = 0.5;
+  __pyx_7 = 100.;
+  __pyx_8 = 5.0;
+  __pyx_v_a1 = __pyx_5;
+  __pyx_v_a2 = __pyx_6;
+  __pyx_v_a3 = __pyx_7;
+  __pyx_v_a4 = __pyx_8;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":54
+ *     CK=50
+ *     a1, a2, a3, a4 = [28., 0.5, 100., 5.0]
+ *     C1 = 50.1             # <<<<<<<<<<<<<<
+ * 
+ *     bx, bk = np.broadcast_arrays(x,k)
+ */
+  __pyx_v_C1 = 50.1;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":56
+ *     C1 = 50.1
+ * 
+ *     bx, bk = np.broadcast_arrays(x,k)             # <<<<<<<<<<<<<<
+ *     result = np.empty(bx.shape,dtype=np.float)
+ * 
+ */
+  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_kp_broadcast_arrays); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_v_x);
+  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_x);
+  Py_INCREF(__pyx_v_k);
+  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_k);
+  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+  if (PyTuple_CheckExact(__pyx_2) && PyTuple_GET_SIZE(__pyx_2) == 2) {
+    PyObject* tuple = __pyx_2;
+    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
+    Py_INCREF(__pyx_3);
+    Py_DECREF(__pyx_v_bx);
+    __pyx_v_bx = __pyx_3;
+    __pyx_3 = 0;
+    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
+    Py_INCREF(__pyx_3);
+    Py_DECREF(__pyx_v_bk);
+    __pyx_v_bk = __pyx_3;
+    __pyx_3 = 0;
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+  }
+  else {
+    __pyx_1 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    __pyx_3 = __Pyx_UnpackItem(__pyx_1, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_v_bx);
+    __pyx_v_bx = __pyx_3;
+    __pyx_3 = 0;
+    __pyx_3 = __Pyx_UnpackItem(__pyx_1, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_v_bk);
+    __pyx_v_bk = __pyx_3;
+    __pyx_3 = 0;
+    if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+  }
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":57
+ * 
+ *     bx, bk = np.broadcast_arrays(x,k)
+ *     result = np.empty(bx.shape,dtype=np.float)             # <<<<<<<<<<<<<<
+ * 
+ *     c_small_k = bk<CK
+ */
+  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_kp_empty); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_1 = PyObject_GetAttr(__pyx_v_bx, __pyx_kp_shape); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
+  __pyx_1 = 0;
+  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_9 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_10 = PyObject_GetAttr(__pyx_9, __pyx_kp_float); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_9); __pyx_9 = 0;
+  if (PyDict_SetItem(__pyx_1, __pyx_kp_dtype, __pyx_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_10); __pyx_10 = 0;
+  __pyx_9 = PyEval_CallObjectWithKeywords(__pyx_2, ((PyObject *)__pyx_3), ((PyObject *)__pyx_1)); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
+  Py_DECREF(__pyx_v_result);
+  __pyx_v_result = __pyx_9;
+  __pyx_9 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":59
+ *     result = np.empty(bx.shape,dtype=np.float)
+ * 
+ *     c_small_k = bk<CK             # <<<<<<<<<<<<<<
+ *     temp = result[c_small_k]
+ *     temp_xs = bx[c_small_k].astype(np.float)
+ */
+  __pyx_10 = PyFloat_FromDouble(__pyx_v_CK); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = PyObject_RichCompare(__pyx_v_bk, __pyx_10, Py_LT); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_10); __pyx_10 = 0;
+  Py_DECREF(__pyx_v_c_small_k);
+  __pyx_v_c_small_k = __pyx_2;
+  __pyx_2 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":60
+ * 
+ *     c_small_k = bk<CK
+ *     temp = result[c_small_k]             # <<<<<<<<<<<<<<
+ *     temp_xs = bx[c_small_k].astype(np.float)
+ *     temp_ks = bk[c_small_k].astype(np.float)
+ */
+  __pyx_3 = PyObject_GetItem(__pyx_v_result, __pyx_v_c_small_k); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((PyArrayObject *)__pyx_3);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_temp, &__pyx_bstruct_temp);
+  __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_1, &__pyx_bstruct_temp, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1);
+  if (unlikely(__pyx_t_2 < 0)) 
+  {
+      PyErr_Fetch(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
+      if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_temp, &__pyx_bstruct_temp, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1) == -1)) {
+          Py_XDECREF(__pyx_t_3); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5);
+          __Pyx_RaiseBufferFallbackError();
+        } else {
+          PyErr_Restore(__pyx_t_3, __pyx_t_4, __pyx_t_5);
+      }
+  }
+  __pyx_bstride_0_temp = __pyx_bstruct_temp.strides[0];
+  __pyx_bshape_0_temp = __pyx_bstruct_temp.shape[0];
+  if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = 0;
+  Py_DECREF(((PyObject *)__pyx_v_temp));
+  __pyx_v_temp = ((PyArrayObject *)__pyx_3);
+  __pyx_3 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":61
+ *     c_small_k = bk<CK
+ *     temp = result[c_small_k]
+ *     temp_xs = bx[c_small_k].astype(np.float)             # <<<<<<<<<<<<<<
+ *     temp_ks = bk[c_small_k].astype(np.float)
+ *     for i in range(len(temp)):
+ */
+  __pyx_1 = PyObject_GetItem(__pyx_v_bx, __pyx_v_c_small_k); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_9 = PyObject_GetAttr(__pyx_1, __pyx_kp_astype); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  __pyx_10 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = PyObject_GetAttr(__pyx_10, __pyx_kp_float); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_10); __pyx_10 = 0;
+  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
+  __pyx_2 = 0;
+  __pyx_1 = PyObject_Call(__pyx_9, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_9); __pyx_9 = 0;
+  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((PyArrayObject *)__pyx_1);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_temp_xs, &__pyx_bstruct_temp_xs);
+  __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_1, &__pyx_bstruct_temp_xs, PyBUF_FORMAT| PyBUF_STRIDES, 1);
+  if (unlikely(__pyx_t_2 < 0)) 
+  {
+      PyErr_Fetch(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
+      if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_temp_xs, &__pyx_bstruct_temp_xs, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+          Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_3);
+          __Pyx_RaiseBufferFallbackError();
+        } else {
+          PyErr_Restore(__pyx_t_5, __pyx_t_4, __pyx_t_3);
+      }
+  }
+  __pyx_bstride_0_temp_xs = __pyx_bstruct_temp_xs.strides[0];
+  __pyx_bshape_0_temp_xs = __pyx_bstruct_temp_xs.shape[0];
+  if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = 0;
+  Py_DECREF(((PyObject *)__pyx_v_temp_xs));
+  __pyx_v_temp_xs = ((PyArrayObject *)__pyx_1);
+  __pyx_1 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":62
+ *     temp = result[c_small_k]
+ *     temp_xs = bx[c_small_k].astype(np.float)
+ *     temp_ks = bk[c_small_k].astype(np.float)             # <<<<<<<<<<<<<<
+ *     for i in range(len(temp)):
+ *         p = <int>(1+a1+a2*temp_ks[i]-a3/(temp_ks[i]+a4))
+ */
+  __pyx_10 = PyObject_GetItem(__pyx_v_bk, __pyx_v_c_small_k); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = PyObject_GetAttr(__pyx_10, __pyx_kp_astype); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_10); __pyx_10 = 0;
+  __pyx_9 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_3 = PyObject_GetAttr(__pyx_9, __pyx_kp_float); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_9); __pyx_9 = 0;
+  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
+  __pyx_3 = 0;
+  __pyx_10 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
+  if (!(__Pyx_TypeTest(__pyx_10, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((PyArrayObject *)__pyx_10);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_temp_ks, &__pyx_bstruct_temp_ks);
+  __pyx_t_2 = __Pyx_GetBuffer_double((PyObject*)__pyx_t_1, &__pyx_bstruct_temp_ks, PyBUF_FORMAT| PyBUF_STRIDES, 1);
+  if (unlikely(__pyx_t_2 < 0)) 
+  {
+      PyErr_Fetch(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
+      if (unlikely(__Pyx_GetBuffer_double((PyObject*)__pyx_v_temp_ks, &__pyx_bstruct_temp_ks, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+          Py_XDECREF(__pyx_t_3); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5);
+          __Pyx_RaiseBufferFallbackError();
+        } else {
+          PyErr_Restore(__pyx_t_3, __pyx_t_4, __pyx_t_5);
+      }
+  }
+  __pyx_bstride_0_temp_ks = __pyx_bstruct_temp_ks.strides[0];
+  __pyx_bshape_0_temp_ks = __pyx_bstruct_temp_ks.shape[0];
+  if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = 0;
+  Py_DECREF(((PyObject *)__pyx_v_temp_ks));
+  __pyx_v_temp_ks = ((PyArrayObject *)__pyx_10);
+  __pyx_10 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":63
+ *     temp_xs = bx[c_small_k].astype(np.float)
+ *     temp_ks = bk[c_small_k].astype(np.float)
+ *     for i in range(len(temp)):             # <<<<<<<<<<<<<<
+ *         p = <int>(1+a1+a2*temp_ks[i]-a3/(temp_ks[i]+a4))
+ *         temp[i] = von_mises_cdf_series(temp_ks[i],temp_xs[i],p)
+ */
+  __pyx_11 = PyObject_Length(((PyObject *)__pyx_v_temp)); if (unlikely(__pyx_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  for (__pyx_v_i = 0; __pyx_v_i < __pyx_11; __pyx_v_i+=1) {
+
+    /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":64
+ *     temp_ks = bk[c_small_k].astype(np.float)
+ *     for i in range(len(temp)):
+ *         p = <int>(1+a1+a2*temp_ks[i]-a3/(temp_ks[i]+a4))             # <<<<<<<<<<<<<<
+ *         temp[i] = von_mises_cdf_series(temp_ks[i],temp_xs[i],p)
+ *         if temp[i]<0:
+ */
+    __pyx_t_6 = __pyx_v_i;
+    __pyx_5 = *((double *)((double *)__Pyx_BufPtrStrided1d(__pyx_bstruct_temp_ks.buf, __pyx_t_6, __pyx_bstride_0_temp_ks)));
+    __pyx_t_7 = __pyx_v_i;
+    __pyx_6 = *((double *)((double *)__Pyx_BufPtrStrided1d(__pyx_bstruct_temp_ks.buf, __pyx_t_7, __pyx_bstride_0_temp_ks)));
+    __pyx_v_p = ((int)(((1 + __pyx_v_a1) + (__pyx_v_a2 * __pyx_5)) - (__pyx_v_a3 / (__pyx_6 + __pyx_v_a4))));
+
+    /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":65
+ *     for i in range(len(temp)):
+ *         p = <int>(1+a1+a2*temp_ks[i]-a3/(temp_ks[i]+a4))
+ *         temp[i] = von_mises_cdf_series(temp_ks[i],temp_xs[i],p)             # <<<<<<<<<<<<<<
+ *         if temp[i]<0:
+ *             temp[i]=0
+ */
+    __pyx_t_8 = __pyx_v_i;
+    __pyx_7 = *((double *)((double *)__Pyx_BufPtrStrided1d(__pyx_bstruct_temp_ks.buf, __pyx_t_8, __pyx_bstride_0_temp_ks)));
+    __pyx_t_9 = __pyx_v_i;
+    __pyx_8 = *((double *)((double *)__Pyx_BufPtrStrided1d(__pyx_bstruct_temp_xs.buf, __pyx_t_9, __pyx_bstride_0_temp_xs)));
+    __pyx_t_10 = __pyx_v_i;
+    *((double *)__Pyx_BufPtrStrided1d(__pyx_bstruct_temp.buf, __pyx_t_10, __pyx_bstride_0_temp)) = __pyx_f_5scipy_5stats_15vonmises_cython_von_mises_cdf_series(__pyx_7, __pyx_8, __pyx_v_p);
+
+    /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":66
+ *         p = <int>(1+a1+a2*temp_ks[i]-a3/(temp_ks[i]+a4))
+ *         temp[i] = von_mises_cdf_series(temp_ks[i],temp_xs[i],p)
+ *         if temp[i]<0:             # <<<<<<<<<<<<<<
+ *             temp[i]=0
+ *         elif temp[i]>1:
+ */
+    __pyx_t_11 = __pyx_v_i;
+    __pyx_5 = *((double *)((double *)__Pyx_BufPtrStrided1d(__pyx_bstruct_temp.buf, __pyx_t_11, __pyx_bstride_0_temp)));
+    __pyx_4 = (__pyx_5 < 0);
+    if (__pyx_4) {
+
+      /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":67
+ *         temp[i] = von_mises_cdf_series(temp_ks[i],temp_xs[i],p)
+ *         if temp[i]<0:
+ *             temp[i]=0             # <<<<<<<<<<<<<<
+ *         elif temp[i]>1:
+ *             temp[i]=1
+ */
+      __pyx_t_12 = __pyx_v_i;
+      *((double *)__Pyx_BufPtrStrided1d(__pyx_bstruct_temp.buf, __pyx_t_12, __pyx_bstride_0_temp)) = 0;
+      goto __pyx_L7;
+    }
+
+    /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":68
+ *         if temp[i]<0:
+ *             temp[i]=0
+ *         elif temp[i]>1:             # <<<<<<<<<<<<<<
+ *             temp[i]=1
+ *     result[c_small_k] = temp
+ */
+    __pyx_t_13 = __pyx_v_i;
+    __pyx_6 = *((double *)((double *)__Pyx_BufPtrStrided1d(__pyx_bstruct_temp.buf, __pyx_t_13, __pyx_bstride_0_temp)));
+    __pyx_4 = (__pyx_6 > 1);
+    if (__pyx_4) {
+
+      /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":69
+ *             temp[i]=0
+ *         elif temp[i]>1:
+ *             temp[i]=1             # <<<<<<<<<<<<<<
+ *     result[c_small_k] = temp
+ *     result[~c_small_k] = von_mises_cdf_normalapprox(bk[~c_small_k],bx[~c_small_k],C1)
+ */
+      __pyx_t_14 = __pyx_v_i;
+      *((double *)__Pyx_BufPtrStrided1d(__pyx_bstruct_temp.buf, __pyx_t_14, __pyx_bstride_0_temp)) = 1;
+      goto __pyx_L7;
+    }
+    __pyx_L7:;
+  }
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":70
+ *         elif temp[i]>1:
+ *             temp[i]=1
+ *     result[c_small_k] = temp             # <<<<<<<<<<<<<<
+ *     result[~c_small_k] = von_mises_cdf_normalapprox(bk[~c_small_k],bx[~c_small_k],C1)
+ * 
+ */
+  if (PyObject_SetItem(__pyx_v_result, __pyx_v_c_small_k, ((PyObject *)__pyx_v_temp)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":71
+ *             temp[i]=1
+ *     result[c_small_k] = temp
+ *     result[~c_small_k] = von_mises_cdf_normalapprox(bk[~c_small_k],bx[~c_small_k],C1)             # <<<<<<<<<<<<<<
+ * 
+ *     if not zerodim:
+ */
+  __pyx_9 = __Pyx_GetName(__pyx_m, __pyx_kp_21); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_3 = PyNumber_Invert(__pyx_v_c_small_k); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_2 = PyObject_GetItem(__pyx_v_bk, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_1 = PyNumber_Invert(__pyx_v_c_small_k); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_10 = PyObject_GetItem(__pyx_v_bx, __pyx_1); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  __pyx_3 = PyFloat_FromDouble(__pyx_v_C1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_1 = PyTuple_New(3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
+  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_10);
+  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_3);
+  __pyx_2 = 0;
+  __pyx_10 = 0;
+  __pyx_3 = 0;
+  __pyx_2 = PyObject_Call(__pyx_9, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_9); __pyx_9 = 0;
+  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
+  __pyx_10 = PyNumber_Invert(__pyx_v_c_small_k); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_v_result, __pyx_10, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_10); __pyx_10 = 0;
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":73
+ *     result[~c_small_k] = von_mises_cdf_normalapprox(bk[~c_small_k],bx[~c_small_k],C1)
+ * 
+ *     if not zerodim:             # <<<<<<<<<<<<<<
+ *         return result+(2*np.pi)*ix
+ *     else:
+ */
+  __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_zerodim); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_12 = (!__pyx_4);
+  if (__pyx_12) {
+
+    /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":74
+ * 
+ *     if not zerodim:
+ *         return result+(2*np.pi)*ix             # <<<<<<<<<<<<<<
+ *     else:
+ *         return (result+(2*np.pi)*ix)[0]
+ */
+    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_9 = PyObject_GetAttr(__pyx_3, __pyx_kp_pi); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    __pyx_1 = PyNumber_Multiply(__pyx_int_2, __pyx_9); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_9); __pyx_9 = 0;
+    __pyx_2 = PyNumber_Multiply(__pyx_1, __pyx_v_ix); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    __pyx_10 = PyNumber_Add(__pyx_v_result, __pyx_2); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    __pyx_r = __pyx_10;
+    __pyx_10 = 0;
+    goto __pyx_L0;
+    goto __pyx_L8;
+  }
+  /*else*/ {
+
+    /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":76
+ *         return result+(2*np.pi)*ix
+ *     else:
+ *         return (result+(2*np.pi)*ix)[0]             # <<<<<<<<<<<<<<
+ */
+    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_9 = PyObject_GetAttr(__pyx_3, __pyx_kp_pi); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    __pyx_1 = PyNumber_Multiply(__pyx_int_2, __pyx_9); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_9); __pyx_9 = 0;
+    __pyx_2 = PyNumber_Multiply(__pyx_1, __pyx_v_ix); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    __pyx_10 = PyNumber_Add(__pyx_v_result, __pyx_2); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    __pyx_3 = __Pyx_GetItemInt(__pyx_10, 0, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_10); __pyx_10 = 0;
+    __pyx_r = __pyx_3;
+    __pyx_3 = 0;
+    goto __pyx_L0;
+  }
+  __pyx_L8:;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  Py_XDECREF(__pyx_1);
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  Py_XDECREF(__pyx_9);
+  Py_XDECREF(__pyx_10);
+  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
+    PyErr_Fetch(&__pyx_type, &__pyx_value, &__pyx_tb);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_temp, &__pyx_bstruct_temp);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_temp_xs, &__pyx_bstruct_temp_xs);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_temp_ks, &__pyx_bstruct_temp_ks);
+  PyErr_Restore(__pyx_type, __pyx_value, __pyx_tb);}
+  __Pyx_AddTraceback("scipy.stats.vonmises_cython.von_mises_cdf");
+  __pyx_r = NULL;
+  goto __pyx_L2;
+  __pyx_L0:;
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_temp, &__pyx_bstruct_temp);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_temp_xs, &__pyx_bstruct_temp_xs);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_temp_ks, &__pyx_bstruct_temp_ks);
+  __pyx_L2:;
+  Py_DECREF(__pyx_v_temp);
+  Py_DECREF(__pyx_v_temp_xs);
+  Py_DECREF(__pyx_v_temp_ks);
+  Py_DECREF(__pyx_v_zerodim);
+  Py_DECREF(__pyx_v_ix);
+  Py_DECREF(__pyx_v_bx);
+  Py_DECREF(__pyx_v_bk);
+  Py_DECREF(__pyx_v_result);
+  Py_DECREF(__pyx_v_c_small_k);
+  Py_DECREF(__pyx_v_k);
+  Py_DECREF(__pyx_v_x);
+  return __pyx_r;
+}
+
+/* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":36
+ *         # experimental exception made for __getbuffer__ and __releasebuffer__
+ *         # -- the details of this may change.
+ *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
+ *             # This implementation of getbuffer is geared towards Cython
+ *             # requirements, and does not yet fullfill the PEP (specifically,
+ */
+
+static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
+static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
+  int __pyx_v_t;
+  char *__pyx_v_f;
+  int __pyx_r;
+  int __pyx_1;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":42
+ *             # so the flags are not even checked).
+ * 
+ *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
+ *                 raise RuntimeError("Py_intptr_t and Py_ssize_t differs in size, numpy.pxd does not support this")
+ * 
+ */
+  __pyx_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
+  if (__pyx_1) {
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":43
+ * 
+ *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
+ *                 raise RuntimeError("Py_intptr_t and Py_ssize_t differs in size, numpy.pxd does not support this")             # <<<<<<<<<<<<<<
+ * 
+ *             info.buf = PyArray_DATA(self)
+ */
+    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_INCREF(__pyx_kp_1);
+    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_kp_1);
+    __pyx_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
+    __Pyx_Raise(__pyx_3, 0, 0);
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":45
+ *                 raise RuntimeError("Py_intptr_t and Py_ssize_t differs in size, numpy.pxd does not support this")
+ * 
+ *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
+ *             info.ndim = PyArray_NDIM(self)
+ *             info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
+ */
+  __pyx_v_info->buf = PyArray_DATA(((PyArrayObject *)__pyx_v_self));
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":46
+ * 
+ *             info.buf = PyArray_DATA(self)
+ *             info.ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
+ *             info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
+ *             info.shape = <Py_ssize_t*>PyArray_DIMS(self)
+ */
+  __pyx_v_info->ndim = PyArray_NDIM(((PyArrayObject *)__pyx_v_self));
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":47
+ *             info.buf = PyArray_DATA(self)
+ *             info.ndim = PyArray_NDIM(self)
+ *             info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
+ *             info.shape = <Py_ssize_t*>PyArray_DIMS(self)
+ *             info.suboffsets = NULL
+ */
+  __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_v_self)));
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":48
+ *             info.ndim = PyArray_NDIM(self)
+ *             info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
+ *             info.shape = <Py_ssize_t*>PyArray_DIMS(self)             # <<<<<<<<<<<<<<
+ *             info.suboffsets = NULL
+ *             info.itemsize = PyArray_ITEMSIZE(self)
+ */
+  __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(((PyArrayObject *)__pyx_v_self)));
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":49
+ *             info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
+ *             info.shape = <Py_ssize_t*>PyArray_DIMS(self)
+ *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
+ *             info.itemsize = PyArray_ITEMSIZE(self)
+ *             info.readonly = not PyArray_ISWRITEABLE(self)
+ */
+  __pyx_v_info->suboffsets = NULL;
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":50
+ *             info.shape = <Py_ssize_t*>PyArray_DIMS(self)
+ *             info.suboffsets = NULL
+ *             info.itemsize = PyArray_ITEMSIZE(self)             # <<<<<<<<<<<<<<
+ *             info.readonly = not PyArray_ISWRITEABLE(self)
+ * 
+ */
+  __pyx_v_info->itemsize = PyArray_ITEMSIZE(((PyArrayObject *)__pyx_v_self));
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":51
+ *             info.suboffsets = NULL
+ *             info.itemsize = PyArray_ITEMSIZE(self)
+ *             info.readonly = not PyArray_ISWRITEABLE(self)             # <<<<<<<<<<<<<<
+ * 
+ *             # Formats that are not tested and working in Cython are not
+ */
+  __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(((PyArrayObject *)__pyx_v_self)));
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":55
+ *             # Formats that are not tested and working in Cython are not
+ *             # made available from this pxd file yet.
+ *             cdef int t = PyArray_TYPE(self)             # <<<<<<<<<<<<<<
+ *             cdef char* f = NULL
+ *             if   t == NPY_BYTE:       f = "b"
+ */
+  __pyx_v_t = PyArray_TYPE(((PyArrayObject *)__pyx_v_self));
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":56
+ *             # made available from this pxd file yet.
+ *             cdef int t = PyArray_TYPE(self)
+ *             cdef char* f = NULL             # <<<<<<<<<<<<<<
+ *             if   t == NPY_BYTE:       f = "b"
+ *             elif t == NPY_UBYTE:      f = "B"
+ */
+  __pyx_v_f = NULL;
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":57
+ *             cdef int t = PyArray_TYPE(self)
+ *             cdef char* f = NULL
+ *             if   t == NPY_BYTE:       f = "b"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_UBYTE:      f = "B"
+ *             elif t == NPY_SHORT:      f = "h"
+ */
+  switch (__pyx_v_t) {
+    case NPY_BYTE:
+    __pyx_v_f = __pyx_k_2;
+    break;
+    case NPY_UBYTE:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":58
+ *             cdef char* f = NULL
+ *             if   t == NPY_BYTE:       f = "b"
+ *             elif t == NPY_UBYTE:      f = "B"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_SHORT:      f = "h"
+ *             elif t == NPY_USHORT:     f = "H"
+ */
+    __pyx_v_f = __pyx_k_3;
+    break;
+    case NPY_SHORT:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":59
+ *             if   t == NPY_BYTE:       f = "b"
+ *             elif t == NPY_UBYTE:      f = "B"
+ *             elif t == NPY_SHORT:      f = "h"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_USHORT:     f = "H"
+ *             elif t == NPY_INT:        f = "i"
+ */
+    __pyx_v_f = __pyx_k_4;
+    break;
+    case NPY_USHORT:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":60
+ *             elif t == NPY_UBYTE:      f = "B"
+ *             elif t == NPY_SHORT:      f = "h"
+ *             elif t == NPY_USHORT:     f = "H"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_INT:        f = "i"
+ *             elif t == NPY_UINT:       f = "I"
+ */
+    __pyx_v_f = __pyx_k_5;
+    break;
+    case NPY_INT:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":61
+ *             elif t == NPY_SHORT:      f = "h"
+ *             elif t == NPY_USHORT:     f = "H"
+ *             elif t == NPY_INT:        f = "i"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_UINT:       f = "I"
+ *             elif t == NPY_LONG:       f = "l"
+ */
+    __pyx_v_f = __pyx_k_6;
+    break;
+    case NPY_UINT:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":62
+ *             elif t == NPY_USHORT:     f = "H"
+ *             elif t == NPY_INT:        f = "i"
+ *             elif t == NPY_UINT:       f = "I"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_LONG:       f = "l"
+ *             elif t == NPY_ULONG:      f = "L"
+ */
+    __pyx_v_f = __pyx_k_7;
+    break;
+    case NPY_LONG:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":63
+ *             elif t == NPY_INT:        f = "i"
+ *             elif t == NPY_UINT:       f = "I"
+ *             elif t == NPY_LONG:       f = "l"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_ULONG:      f = "L"
+ *             elif t == NPY_LONGLONG:   f = "q"
+ */
+    __pyx_v_f = __pyx_k_8;
+    break;
+    case NPY_ULONG:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":64
+ *             elif t == NPY_UINT:       f = "I"
+ *             elif t == NPY_LONG:       f = "l"
+ *             elif t == NPY_ULONG:      f = "L"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_LONGLONG:   f = "q"
+ *             elif t == NPY_ULONGLONG:  f = "Q"
+ */
+    __pyx_v_f = __pyx_k_9;
+    break;
+    case NPY_LONGLONG:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":65
+ *             elif t == NPY_LONG:       f = "l"
+ *             elif t == NPY_ULONG:      f = "L"
+ *             elif t == NPY_LONGLONG:   f = "q"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_ULONGLONG:  f = "Q"
+ *             elif t == NPY_FLOAT:      f = "f"
+ */
+    __pyx_v_f = __pyx_k_10;
+    break;
+    case NPY_ULONGLONG:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":66
+ *             elif t == NPY_ULONG:      f = "L"
+ *             elif t == NPY_LONGLONG:   f = "q"
+ *             elif t == NPY_ULONGLONG:  f = "Q"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_FLOAT:      f = "f"
+ *             elif t == NPY_DOUBLE:     f = "d"
+ */
+    __pyx_v_f = __pyx_k_11;
+    break;
+    case NPY_FLOAT:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":67
+ *             elif t == NPY_LONGLONG:   f = "q"
+ *             elif t == NPY_ULONGLONG:  f = "Q"
+ *             elif t == NPY_FLOAT:      f = "f"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_DOUBLE:     f = "d"
+ *             elif t == NPY_LONGDOUBLE: f = "g"
+ */
+    __pyx_v_f = __pyx_k_12;
+    break;
+    case NPY_DOUBLE:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":68
+ *             elif t == NPY_ULONGLONG:  f = "Q"
+ *             elif t == NPY_FLOAT:      f = "f"
+ *             elif t == NPY_DOUBLE:     f = "d"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_LONGDOUBLE: f = "g"
+ *             elif t == NPY_OBJECT:     f = "O"
+ */
+    __pyx_v_f = __pyx_k_13;
+    break;
+    case NPY_LONGDOUBLE:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":69
+ *             elif t == NPY_FLOAT:      f = "f"
+ *             elif t == NPY_DOUBLE:     f = "d"
+ *             elif t == NPY_LONGDOUBLE: f = "g"             # <<<<<<<<<<<<<<
+ *             elif t == NPY_OBJECT:     f = "O"
+ * 
+ */
+    __pyx_v_f = __pyx_k_14;
+    break;
+    case NPY_OBJECT:
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":70
+ *             elif t == NPY_DOUBLE:     f = "d"
+ *             elif t == NPY_LONGDOUBLE: f = "g"
+ *             elif t == NPY_OBJECT:     f = "O"             # <<<<<<<<<<<<<<
+ * 
+ *             if f == NULL:
+ */
+    __pyx_v_f = __pyx_k_15;
+    break;
+  }
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":72
+ *             elif t == NPY_OBJECT:     f = "O"
+ * 
+ *             if f == NULL:             # <<<<<<<<<<<<<<
+ *                 raise ValueError("only objects, int and float dtypes supported for ndarray buffer access so far (dtype is %d)" % t)
+ *             info.format = f
+ */
+  __pyx_1 = (__pyx_v_f == NULL);
+  if (__pyx_1) {
+
+    /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":73
+ * 
+ *             if f == NULL:
+ *                 raise ValueError("only objects, int and float dtypes supported for ndarray buffer access so far (dtype is %d)" % t)             # <<<<<<<<<<<<<<
+ *             info.format = f
+ * 
+ */
+    __pyx_2 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_3 = PyNumber_Remainder(__pyx_kp_16, __pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
+    __pyx_3 = 0;
+    __pyx_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
+    __Pyx_Raise(__pyx_3, 0, 0);
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":74
+ *             if f == NULL:
+ *                 raise ValueError("only objects, int and float dtypes supported for ndarray buffer access so far (dtype is %d)" % t)
+ *             info.format = f             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_v_info->format = __pyx_v_f;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  return __pyx_r;
+}
+
+static struct PyMethodDef __pyx_methods[] = {
+  {"von_mises_cdf_normalapprox", (PyCFunction)__pyx_pf_5scipy_5stats_15vonmises_cython_von_mises_cdf_normalapprox, METH_VARARGS|METH_KEYWORDS, 0},
+  {"von_mises_cdf", (PyCFunction)__pyx_pf_5scipy_5stats_15vonmises_cython_von_mises_cdf, METH_VARARGS|METH_KEYWORDS, 0},
+  {0, 0, 0, 0}
+};
+
+static void __pyx_init_filenames(void); /*proto*/
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef __pyx_moduledef = {
+    PyModuleDef_HEAD_INIT,
+    "vonmises_cython",
+    0, /* m_doc */
+    -1, /* m_size */
+    __pyx_methods /* m_methods */,
+    NULL, /* m_reload */
+    NULL, /* m_traverse */
+    NULL, /* m_clear */
+    NULL /* m_free */
+};
+#endif
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {&__pyx_kp_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 1, 1, 1},
+  {&__pyx_kp_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 1, 1},
+  {&__pyx_kp_17, __pyx_k_17, sizeof(__pyx_k_17), 1, 1, 1},
+  {&__pyx_kp_scipy, __pyx_k_scipy, sizeof(__pyx_k_scipy), 0, 1, 1},
+  {&__pyx_kp_18, __pyx_k_18, sizeof(__pyx_k_18), 1, 1, 1},
+  {&__pyx_kp_i0, __pyx_k_i0, sizeof(__pyx_k_i0), 1, 1, 1},
+  {&__pyx_kp_19, __pyx_k_19, sizeof(__pyx_k_19), 1, 1, 1},
+  {&__pyx_kp_pi, __pyx_k_pi, sizeof(__pyx_k_pi), 1, 1, 1},
+  {&__pyx_kp_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 1, 1, 1},
+  {&__pyx_kp_exp, __pyx_k_exp, sizeof(__pyx_k_exp), 1, 1, 1},
+  {&__pyx_kp_sin, __pyx_k_sin, sizeof(__pyx_k_sin), 1, 1, 1},
+  {&__pyx_kp_stats, __pyx_k_stats, sizeof(__pyx_k_stats), 1, 1, 1},
+  {&__pyx_kp_norm, __pyx_k_norm, sizeof(__pyx_k_norm), 1, 1, 1},
+  {&__pyx_kp_cdf, __pyx_k_cdf, sizeof(__pyx_k_cdf), 1, 1, 1},
+  {&__pyx_kp_asarray, __pyx_k_asarray, sizeof(__pyx_k_asarray), 1, 1, 1},
+  {&__pyx_kp_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 1, 1, 1},
+  {&__pyx_kp_20, __pyx_k_20, sizeof(__pyx_k_20), 1, 1, 1},
+  {&__pyx_kp_round, __pyx_k_round, sizeof(__pyx_k_round), 1, 1, 1},
+  {&__pyx_kp_broadcast_arrays, __pyx_k_broadcast_arrays, sizeof(__pyx_k_broadcast_arrays), 1, 1, 1},
+  {&__pyx_kp_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 1, 1, 1},
+  {&__pyx_kp_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 1, 1, 1},
+  {&__pyx_kp_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 1, 1, 1},
+  {&__pyx_kp_float, __pyx_k_float, sizeof(__pyx_k_float), 1, 1, 1},
+  {&__pyx_kp_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 1, 1, 1},
+  {&__pyx_kp_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 1, 1},
+  {&__pyx_kp___getbuffer__, __pyx_k___getbuffer__, sizeof(__pyx_k___getbuffer__), 0, 1, 1},
+  {&__pyx_kp_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 1, 1, 1},
+  {&__pyx_kp_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 1, 1, 1},
+  {&__pyx_kp_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 0},
+  {&__pyx_kp_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 0},
+  {0, 0, 0, 0, 0, 0}
+};
+static int __Pyx_InitCachedBuiltins(void) {
+  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_kp_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_kp_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+static int __Pyx_InitGlobals(void) {
+  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_24 = PyInt_FromLong(24); if (unlikely(!__pyx_int_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+#if PY_MAJOR_VERSION < 3
+PyMODINIT_FUNC initvonmises_cython(void); /*proto*/
+PyMODINIT_FUNC initvonmises_cython(void)
+#else
+PyMODINIT_FUNC PyInit_vonmises_cython(void); /*proto*/
+PyMODINIT_FUNC PyInit_vonmises_cython(void)
+#endif
+{
+  PyObject *__pyx_1 = 0;
+  PyObject *__pyx_2 = 0;
+  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Libary function declarations ---*/
+  __pyx_init_filenames();
+  /*--- Initialize various global constants etc. ---*/
+  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Module creation code ---*/
+  #if PY_MAJOR_VERSION < 3
+  __pyx_m = Py_InitModule4("vonmises_cython", __pyx_methods, 0, 0, PYTHON_API_VERSION);
+  #else
+  __pyx_m = PyModule_Create(&__pyx_moduledef);
+  #endif
+  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  #if PY_MAJOR_VERSION < 3
+  Py_INCREF(__pyx_m);
+  #endif
+  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME);
+  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  /*--- Builtin init code ---*/
+  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_skip_dispatch = 0;
+  /*--- Global init code ---*/
+  /*--- Function export code ---*/
+  /*--- Type init code ---*/
+  /*--- Type import code ---*/
+  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Function import code ---*/
+  /*--- Execution code ---*/
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":1
+ * import numpy as np             # <<<<<<<<<<<<<<
+ * import scipy.stats
+ * from scipy.special import i0
+ */
+  __pyx_1 = __Pyx_Import(__pyx_kp_numpy, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_kp_np, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":2
+ * import numpy as np
+ * import scipy.stats             # <<<<<<<<<<<<<<
+ * from scipy.special import i0
+ * import numpy.testing
+ */
+  __pyx_1 = __Pyx_Import(__pyx_kp_17, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_kp_scipy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":3
+ * import numpy as np
+ * import scipy.stats
+ * from scipy.special import i0             # <<<<<<<<<<<<<<
+ * import numpy.testing
+ * cimport numpy as np
+ */
+  __pyx_1 = PyList_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_kp_i0);
+  PyList_SET_ITEM(__pyx_1, 0, __pyx_kp_i0);
+  __pyx_2 = __Pyx_Import(__pyx_kp_18, ((PyObject *)__pyx_1)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
+  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_kp_i0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_kp_i0, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+
+  /* "/home/peridot/software/scipy/svn/trunk/scipy/stats/vonmises_cython.pyx":4
+ * import scipy.stats
+ * from scipy.special import i0
+ * import numpy.testing             # <<<<<<<<<<<<<<
+ * cimport numpy as np
+ * 
+ */
+  __pyx_2 = __Pyx_Import(__pyx_kp_19, 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_kp_numpy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+
+  /* "/home/peridot/devlib/lib/python2.5/site-packages/Cython-0.9.8.1.1-py2.5-linux-i686.egg/Cython/Includes/numpy.pxd":36
+ *         # experimental exception made for __getbuffer__ and __releasebuffer__
+ *         # -- the details of this may change.
+ *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
+ *             # This implementation of getbuffer is geared towards Cython
+ *             # requirements, and does not yet fullfill the PEP (specifically,
+ */
+  #if PY_MAJOR_VERSION < 3
+  return;
+  #else
+  return __pyx_m;
+  #endif
+  __pyx_L1_error:;
+  Py_XDECREF(__pyx_1);
+  Py_XDECREF(__pyx_2);
+  __Pyx_AddTraceback("scipy.stats.vonmises_cython");
+  #if PY_MAJOR_VERSION >= 3
+  return NULL;
+  #endif
+}
+
+static const char *__pyx_filenames[] = {
+  "vonmises_cython.pyx",
+  "numpy.pxd",
+};
+
+/* Runtime support code */
+
+static void __pyx_init_filenames(void) {
+  __pyx_f = __pyx_filenames;
+}
+
+static INLINE void __Pyx_SafeReleaseBuffer(PyObject* obj, Py_buffer* info) {
+  if (info->buf == NULL) return;
+  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
+  __Pyx_ReleaseBuffer(obj, info);
+}
+
+static INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
+  buf->buf = NULL;
+  buf->strides = __Pyx_zeros;
+  buf->shape = __Pyx_zeros;
+  buf->suboffsets = __Pyx_minusones;
+}
+
+static INLINE const char* __Pyx_ConsumeWhitespace(const char* ts) {
+  while (1) {
+    switch (*ts) {
+      case 10:
+      case 13:
+      case ' ':
+        ++ts;
+      default:
+        return ts;
+    }
+  }
+}
+
+static INLINE const char* __Pyx_BufferTypestringCheckEndian(const char* ts) {
+  int num = 1;
+  int little_endian = ((char*)&num)[0];
+  int ok = 1;
+  switch (*ts) {
+    case '@':
+    case '=':
+      ++ts; break;
+    case '<':
+      if (little_endian) ++ts;
+      else ok = 0;
+      break;
+    case '>':
+    case '!':
+      if (!little_endian) ++ts;
+      else ok = 0;
+      break;
+  }
+  if (!ok) {
+    PyErr_Format(PyExc_ValueError, "Buffer has wrong endianness (rejecting on '%s')", ts);
+    return NULL;
+  }
+  return ts;
+}
+
+static void __Pyx_BufferNdimError(Py_buffer* buffer, int expected_ndim) {
+  PyErr_Format(PyExc_ValueError,
+               "Buffer has wrong number of dimensions (expected %d, got %d)",
+               expected_ndim, buffer->ndim);
+}
+
+
+static const char* __Pyx_BufferTypestringCheck_item_double(const char* ts) {
+  if (*ts == '1') ++ts;
+  if (*ts != 'd') {
+    PyErr_Format(PyExc_ValueError, "Buffer datatype mismatch (expected 'd', got '%s')", ts);
+    return NULL;
+  } else return ts + 1;
+  
+}
+
+static int __Pyx_GetBuffer_double(PyObject* obj, Py_buffer* buf, int flags, int nd) {
+  const char* ts;
+  if (obj == Py_None) {
+    __Pyx_ZeroBuffer(buf);
+    return 0;
+  }
+  buf->buf = NULL;
+  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
+  if (buf->ndim != nd) {
+    __Pyx_BufferNdimError(buf, nd);
+    goto fail;
+  }
+  ts = buf->format;
+  ts = __Pyx_ConsumeWhitespace(ts);
+  ts = __Pyx_BufferTypestringCheckEndian(ts);
+  if (!ts) goto fail;
+  ts = __Pyx_ConsumeWhitespace(ts);
+  ts = __Pyx_BufferTypestringCheck_item_double(ts);
+  if (!ts) goto fail;
+  ts = __Pyx_ConsumeWhitespace(ts);
+  if (*ts != 0) {
+    PyErr_Format(PyExc_ValueError,
+      "Expected non-struct buffer data type (expected end, got '%s')", ts);
+    goto fail;
+  }
+  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
+  return 0;
+fail:;
+  __Pyx_ZeroBuffer(buf);
+  return -1;
+}
+static void __Pyx_RaiseBufferFallbackError(void) {
+  PyErr_Format(PyExc_ValueError,
+     "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
+}
+
+
+static INLINE void __Pyx_RaiseArgtupleTooLong(
+    Py_ssize_t num_expected,
+    Py_ssize_t num_found)
+{
+    const char* error_message =
+    #if PY_VERSION_HEX < 0x02050000
+        "function takes at most %d positional arguments (%d given)";
+    #else
+        "function takes at most %zd positional arguments (%zd given)";
+    #endif
+    PyErr_Format(PyExc_TypeError, error_message, num_expected, num_found);
+}
+
+#if (PY_MAJOR_VERSION < 3) && !(Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER)
+static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
+  if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pf_5numpy_7ndarray___getbuffer__(obj, view, flags);
+  else {
+  PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
+  return -1;
+    }
+}
+
+static void __Pyx_ReleaseBuffer(PyObject *obj, Py_buffer *view) {
+
+}
+
+#endif
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
+    PyObject *__import__ = 0;
+    PyObject *empty_list = 0;
+    PyObject *module = 0;
+    PyObject *global_dict = 0;
+    PyObject *empty_dict = 0;
+    PyObject *list;
+    __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
+    if (!__import__)
+        goto bad;
+    if (from_list)
+        list = from_list;
+    else {
+        empty_list = PyList_New(0);
+        if (!empty_list)
+            goto bad;
+        list = empty_list;
+    }
+    global_dict = PyModule_GetDict(__pyx_m);
+    if (!global_dict)
+        goto bad;
+    empty_dict = PyDict_New();
+    if (!empty_dict)
+        goto bad;
+    module = PyObject_CallFunction(__import__, "OOOO",
+        name, global_dict, empty_dict, list);
+bad:
+    Py_XDECREF(empty_list);
+    Py_XDECREF(__import__);
+    Py_XDECREF(empty_dict);
+    return module;
+}
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
+    PyObject *result;
+    result = PyObject_GetAttr(dict, name);
+    if (!result)
+        PyErr_SetObject(PyExc_NameError, name);
+    return result;
+}
+
+static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
+    PyObject *item;
+    if (!(item = PyIter_Next(iter))) {
+        if (!PyErr_Occurred()) {
+            PyErr_Format(PyExc_ValueError,
+                #if PY_VERSION_HEX < 0x02050000
+                    "need more than %d values to unpack", (int)index);
+                #else
+                    "need more than %zd values to unpack", index);
+                #endif
+        }
+    }
+    return item;
+}
+
+static int __Pyx_EndUnpack(PyObject *iter) {
+    PyObject *item;
+    if ((item = PyIter_Next(iter))) {
+        Py_DECREF(item);
+        PyErr_SetString(PyExc_ValueError, "too many values to unpack");
+        return -1;
+    }
+    else if (!PyErr_Occurred())
+        return 0;
+    else
+        return -1;
+}
+
+static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
+    if (!type) {
+        PyErr_Format(PyExc_SystemError, "Missing type object");
+        return 0;
+    }
+    if (obj == Py_None || PyObject_TypeCheck(obj, type))
+        return 1;
+    PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s",
+        Py_TYPE(obj)->tp_name, type->tp_name);
+    return 0;
+}
+
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
+    Py_XINCREF(type);
+    Py_XINCREF(value);
+    Py_XINCREF(tb);
+    /* First, check the traceback argument, replacing None with NULL. */
+    if (tb == Py_None) {
+        Py_DECREF(tb);
+        tb = 0;
+    }
+    else if (tb != NULL && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto raise_error;
+    }
+    /* Next, replace a missing value with None */
+    if (value == NULL) {
+        value = Py_None;
+        Py_INCREF(value);
+    }
+    #if PY_VERSION_HEX < 0x02050000
+    if (!PyClass_Check(type))
+    #else
+    if (!PyType_Check(type))
+    #endif
+    {
+        /* Raising an instance.  The value should be a dummy. */
+        if (value != Py_None) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto raise_error;
+        }
+        /* Normalize to raise <class>, <instance> */
+        Py_DECREF(value);
+        value = type;
+        #if PY_VERSION_HEX < 0x02050000
+            if (PyInstance_Check(type)) {
+                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
+                Py_INCREF(type);
+            }
+            else {
+                type = 0;
+                PyErr_SetString(PyExc_TypeError,
+                    "raise: exception must be an old-style class or instance");
+                goto raise_error;
+            }
+        #else
+            type = (PyObject*) Py_TYPE(type);
+            Py_INCREF(type);
+            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
+                PyErr_SetString(PyExc_TypeError,
+                    "raise: exception class must be a subclass of BaseException");
+                goto raise_error;
+            }
+        #endif
+    }
+    PyErr_Restore(type, value, tb);
+    return;
+raise_error:
+    Py_XDECREF(value);
+    Py_XDECREF(type);
+    Py_XDECREF(tb);
+    return;
+}
+
+static void __Pyx_WriteUnraisable(const char *name) {
+    PyObject *old_exc, *old_val, *old_tb;
+    PyObject *ctx;
+    PyErr_Fetch(&old_exc, &old_val, &old_tb);
+    #if PY_MAJOR_VERSION < 3
+    ctx = PyString_FromString(name);
+    #else
+    ctx = PyUnicode_FromString(name);
+    #endif
+    PyErr_Restore(old_exc, old_val, old_tb);
+    if (!ctx)
+        ctx = Py_None;
+    PyErr_WriteUnraisable(ctx);
+}
+
+#ifndef __PYX_HAVE_RT_ImportType
+#define __PYX_HAVE_RT_ImportType
+static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name,
+    long size)
+{
+    PyObject *py_module = 0;
+    PyObject *result = 0;
+    PyObject *py_name = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_name = PyString_FromString(module_name);
+    #else
+    py_name = PyUnicode_FromString(module_name);
+    #endif
+    if (!py_name)
+        goto bad;
+
+    py_module = __Pyx_ImportModule(module_name);
+    if (!py_module)
+        goto bad;
+    result = PyObject_GetAttrString(py_module, class_name);
+    if (!result)
+        goto bad;
+    if (!PyType_Check(result)) {
+        PyErr_Format(PyExc_TypeError, 
+            "%s.%s is not a type object",
+            module_name, class_name);
+        goto bad;
+    }
+    if (((PyTypeObject *)result)->tp_basicsize != size) {
+        PyErr_Format(PyExc_ValueError, 
+            "%s.%s does not appear to be the correct type object",
+            module_name, class_name);
+        goto bad;
+    }
+    return (PyTypeObject *)result;
+bad:
+    Py_XDECREF(py_name);
+    Py_XDECREF(result);
+    return 0;
+}
+#endif
+
+#ifndef __PYX_HAVE_RT_ImportModule
+#define __PYX_HAVE_RT_ImportModule
+static PyObject *__Pyx_ImportModule(char *name) {
+    PyObject *py_name = 0;
+    PyObject *py_module = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_name = PyString_FromString(name);
+    #else
+    py_name = PyUnicode_FromString(name);
+    #endif
+    if (!py_name)
+        goto bad;
+    py_module = PyImport_Import(py_name);
+    Py_DECREF(py_name);
+    return py_module;
+bad:
+    Py_XDECREF(py_name);
+    return 0;
+}
+#endif
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+
+static void __Pyx_AddTraceback(const char *funcname) {
+    PyObject *py_srcfile = 0;
+    PyObject *py_funcname = 0;
+    PyObject *py_globals = 0;
+    PyObject *empty_string = 0;
+    PyCodeObject *py_code = 0;
+    PyFrameObject *py_frame = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_srcfile = PyString_FromString(__pyx_filename);
+    #else
+    py_srcfile = PyUnicode_FromString(__pyx_filename);
+    #endif
+    if (!py_srcfile) goto bad;
+    if (__pyx_clineno) {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
+        #else
+        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
+        #endif
+    }
+    else {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromString(funcname);
+        #else
+        py_funcname = PyUnicode_FromString(funcname);
+        #endif
+    }
+    if (!py_funcname) goto bad;
+    py_globals = PyModule_GetDict(__pyx_m);
+    if (!py_globals) goto bad;
+    #if PY_MAJOR_VERSION < 3
+    empty_string = PyString_FromStringAndSize("", 0);
+    #else
+    empty_string = PyBytes_FromStringAndSize("", 0);
+    #endif
+    if (!empty_string) goto bad;
+    py_code = PyCode_New(
+        0,            /*int argcount,*/
+        #if PY_MAJOR_VERSION >= 3
+        0,            /*int kwonlyargcount,*/
+        #endif
+        0,            /*int nlocals,*/
+        0,            /*int stacksize,*/
+        0,            /*int flags,*/
+        empty_string, /*PyObject *code,*/
+        __pyx_empty_tuple,  /*PyObject *consts,*/
+        __pyx_empty_tuple,  /*PyObject *names,*/
+        __pyx_empty_tuple,  /*PyObject *varnames,*/
+        __pyx_empty_tuple,  /*PyObject *freevars,*/
+        __pyx_empty_tuple,  /*PyObject *cellvars,*/
+        py_srcfile,   /*PyObject *filename,*/
+        py_funcname,  /*PyObject *name,*/
+        __pyx_lineno,   /*int firstlineno,*/
+        empty_string  /*PyObject *lnotab*/
+    );
+    if (!py_code) goto bad;
+    py_frame = PyFrame_New(
+        PyThreadState_Get(), /*PyThreadState *tstate,*/
+        py_code,             /*PyCodeObject *code,*/
+        py_globals,          /*PyObject *globals,*/
+        0                    /*PyObject *locals*/
+    );
+    if (!py_frame) goto bad;
+    py_frame->f_lineno = __pyx_lineno;
+    PyTraceBack_Here(py_frame);
+bad:
+    Py_XDECREF(py_srcfile);
+    Py_XDECREF(py_funcname);
+    Py_XDECREF(empty_string);
+    Py_XDECREF(py_code);
+    Py_XDECREF(py_frame);
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+    while (t->p) {
+        #if PY_MAJOR_VERSION < 3
+        if (t->is_unicode && (!t->is_identifier)) {
+            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
+        } else if (t->intern) {
+            *t->p = PyString_InternFromString(t->s);
+        } else {
+            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+        }
+        #else  /* Python 3+ has unicode identifiers */
+        if (t->is_identifier || (t->is_unicode && t->intern)) {
+            *t->p = PyUnicode_InternFromString(t->s);
+        } else if (t->is_unicode) {
+            *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
+        } else {
+            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
+        }
+        #endif
+        if (!*t->p)
+            return -1;
+        ++t;
+    }
+    return 0;
+}
+
+/* Type Conversion Functions */
+
+static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b) {
+  Py_ssize_t ival;
+  PyObject* x = PyNumber_Index(b);
+  if (!x) return -1;
+  ival = PyInt_AsSsize_t(x);
+  Py_DECREF(x);
+  return ival;
+}
+
+static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
+   if (x == Py_True) return 1;
+   else if (x == Py_False) return 0;
+   else return PyObject_IsTrue(x);
+}
+
+static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) {
+    if (PyInt_CheckExact(x)) {
+        return PyInt_AS_LONG(x);
+    }
+    else if (PyLong_CheckExact(x)) {
+        return PyLong_AsLongLong(x);
+    }
+    else {
+        PY_LONG_LONG val;
+        PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
+        val = __pyx_PyInt_AsLongLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
+    if (PyInt_CheckExact(x)) {
+        long val = PyInt_AS_LONG(x);
+        if (unlikely(val < 0)) {
+            PyErr_SetString(PyExc_TypeError, "Negative assignment to unsigned type.");
+            return (unsigned PY_LONG_LONG)-1;
+        }
+        return val;
+    }
+    else if (PyLong_CheckExact(x)) {
+        return PyLong_AsUnsignedLongLong(x);
+    }
+    else {
+        PY_LONG_LONG val;
+        PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
+        val = __pyx_PyInt_AsUnsignedLongLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+
+static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x) {
+    if (sizeof(unsigned char) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        unsigned char val = (unsigned char)long_val;
+        if (unlikely((val != long_val)  || (long_val < 0))) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned char");
+            return (unsigned char)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x) {
+    if (sizeof(unsigned short) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        unsigned short val = (unsigned short)long_val;
+        if (unlikely((val != long_val)  || (long_val < 0))) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned short");
+            return (unsigned short)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE char __pyx_PyInt_char(PyObject* x) {
+    if (sizeof(char) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        char val = (char)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to char");
+            return (char)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE short __pyx_PyInt_short(PyObject* x) {
+    if (sizeof(short) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        short val = (short)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to short");
+            return (short)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE int __pyx_PyInt_int(PyObject* x) {
+    if (sizeof(int) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        int val = (int)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to int");
+            return (int)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE long __pyx_PyInt_long(PyObject* x) {
+    if (sizeof(long) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        long val = (long)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to long");
+            return (long)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE signed char __pyx_PyInt_signed_char(PyObject* x) {
+    if (sizeof(signed char) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        signed char val = (signed char)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed char");
+            return (signed char)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE signed short __pyx_PyInt_signed_short(PyObject* x) {
+    if (sizeof(signed short) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        signed short val = (signed short)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed short");
+            return (signed short)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE signed int __pyx_PyInt_signed_int(PyObject* x) {
+    if (sizeof(signed int) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        signed int val = (signed int)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed int");
+            return (signed int)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE signed long __pyx_PyInt_signed_long(PyObject* x) {
+    if (sizeof(signed long) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        signed long val = (signed long)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed long");
+            return (signed long)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE long double __pyx_PyInt_long_double(PyObject* x) {
+    if (sizeof(long double) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        long double val = (long double)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to long double");
+            return (long double)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+

Added: trunk/scipy/stats/vonmises_cython.pyx
===================================================================
--- trunk/scipy/stats/vonmises_cython.pyx	2008-10-09 05:26:59 UTC (rev 4787)
+++ trunk/scipy/stats/vonmises_cython.pyx	2008-10-09 07:29:54 UTC (rev 4788)
@@ -0,0 +1,76 @@
+import numpy as np
+import scipy.stats
+from scipy.special import i0
+import numpy.testing
+cimport numpy as np
+
+cdef extern from "math.h":
+    double cos(double theta)
+    double sin(double theta)
+
+
+cdef double von_mises_cdf_series(double k,double x,unsigned int p):
+    cdef double s, c, sn, cn, R, V
+    cdef unsigned int n
+    s = sin(x)
+    c = cos(x)
+    sn = sin(p*x)
+    cn = cos(p*x)
+    R = 0
+    V = 0
+    for n in range(p-1,0,-1):
+        sn, cn = sn*c - cn*s, cn*c + sn*s
+        R = 1./(2*n/k + R)
+        V = R*(sn/n+V)
+
+    return 0.5+x/(2*np.pi) + V/np.pi
+
+def von_mises_cdf_normalapprox(k,x,C1):
+    b = np.sqrt(2/np.pi)*np.exp(k)/i0(k)
+    z = b*np.sin(x/2.)
+    C = 24*k
+    chi = z - z**3/((C-2*z**2-16)/3.-(z**4+7/4.*z**2+167./2)/(C+C1-z**2+3))**2
+    return scipy.stats.norm.cdf(z)
+
+cimport cython
+@cython.boundscheck(False)
+def von_mises_cdf(k,x):
+    cdef np.ndarray[double, ndim=1] temp, temp_xs, temp_ks
+    cdef unsigned int i, p
+    cdef double a1, a2, a3, a4, C1, CK
+    #k,x = np.broadcast_arrays(np.asarray(k),np.asarray(x))
+    k = np.asarray(k)
+    x = np.asarray(x)
+    zerodim = k.ndim==0 and x.ndim==0
+
+    k = np.atleast_1d(k)
+    x = np.atleast_1d(x)
+    ix = np.round(x/(2*np.pi))
+    x = x-ix
+
+    # These values should give 12 decimal digits
+    CK=50
+    a1, a2, a3, a4 = [28., 0.5, 100., 5.0]
+    C1 = 50.1
+
+    bx, bk = np.broadcast_arrays(x,k)
+    result = np.empty(bx.shape,dtype=np.float)
+     
+    c_small_k = bk<CK
+    temp = result[c_small_k]
+    temp_xs = bx[c_small_k].astype(np.float)
+    temp_ks = bk[c_small_k].astype(np.float)
+    for i in range(len(temp)):
+        p = <int>(1+a1+a2*temp_ks[i]-a3/(temp_ks[i]+a4))
+        temp[i] = von_mises_cdf_series(temp_ks[i],temp_xs[i],p)
+        if temp[i]<0:
+            temp[i]=0
+        elif temp[i]>1:
+            temp[i]=1
+    result[c_small_k] = temp
+    result[~c_small_k] = von_mises_cdf_normalapprox(bk[~c_small_k],bx[~c_small_k],C1)
+
+    if not zerodim:
+        return result+(2*np.pi)*ix
+    else:
+        return (result+(2*np.pi)*ix)[0]



More information about the Scipy-svn mailing list