~ubuntu-branches/ubuntu/natty/python-cogent/natty

« back to all changes in this revision

Viewing changes to cogent/maths/_period.c

  • Committer: Bazaar Package Importer
  • Author(s): Steffen Moeller
  • Date: 2010-12-04 22:30:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101204223035-j11kinhcrrdgg2p2
Tags: 1.5-1
* Bumped standard to 3.9.1, no changes required.
* New upstream version.
  - major additions to Cookbook
  - added AlleleFreqs attribute to ensembl Variation objects.
  - added getGeneByStableId method to genome objects.
  - added Introns attribute to Transcript objects and an Intron class.
  - added Mann-Whitney test and a Monte-Carlo version
  - exploratory and confirmatory period estimation techniques (suitable for
    symbolic and continuous data)
  - Information theoretic measures (AIC and BIC) added
  - drawing of trees with collapsed nodes
  - progress display indicator support for terminal and GUI apps
  - added parser for illumina HiSeq2000 and GAiix sequence files as 
    cogent.parse.illumina_sequence.MinimalIlluminaSequenceParser.
  - added parser to FASTQ files, one of the output options for illumina's
    workflow, also added cookbook demo.
  - added functionality for parsing of SFF files without the Roche tools in
    cogent.parse.binary_sff
  - thousand fold performance improvement to nmds
  - >10-fold performance improvements to some Table operations

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Generated by Cython 0.12.1 on Mon Sep 13 10:01:55 2010 */
 
2
 
 
3
#define PY_SSIZE_T_CLEAN
 
4
#include "Python.h"
 
5
#include "structmember.h"
 
6
#ifndef Py_PYTHON_H
 
7
    #error Python headers needed to compile C extensions, please install development version of Python.
 
8
#else
 
9
 
 
10
#ifndef PY_LONG_LONG
 
11
  #define PY_LONG_LONG LONG_LONG
 
12
#endif
 
13
#ifndef DL_EXPORT
 
14
  #define DL_EXPORT(t) t
 
15
#endif
 
16
#if PY_VERSION_HEX < 0x02040000
 
17
  #define METH_COEXIST 0
 
18
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
 
19
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
 
20
#endif
 
21
 
 
22
#if PY_VERSION_HEX < 0x02050000
 
23
  typedef int Py_ssize_t;
 
24
  #define PY_SSIZE_T_MAX INT_MAX
 
25
  #define PY_SSIZE_T_MIN INT_MIN
 
26
  #define PY_FORMAT_SIZE_T ""
 
27
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
 
28
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
 
29
  #define PyNumber_Index(o)    PyNumber_Int(o)
 
30
  #define PyIndex_Check(o)     PyNumber_Check(o)
 
31
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
 
32
#endif
 
33
 
 
34
#if PY_VERSION_HEX < 0x02060000
 
35
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
 
36
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
 
37
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
 
38
  #define PyVarObject_HEAD_INIT(type, size) \
 
39
          PyObject_HEAD_INIT(type) size,
 
40
  #define PyType_Modified(t)
 
41
 
 
42
  typedef struct {
 
43
     void *buf;
 
44
     PyObject *obj;
 
45
     Py_ssize_t len;
 
46
     Py_ssize_t itemsize;
 
47
     int readonly;
 
48
     int ndim;
 
49
     char *format;
 
50
     Py_ssize_t *shape;
 
51
     Py_ssize_t *strides;
 
52
     Py_ssize_t *suboffsets;
 
53
     void *internal;
 
54
  } Py_buffer;
 
55
 
 
56
  #define PyBUF_SIMPLE 0
 
57
  #define PyBUF_WRITABLE 0x0001
 
58
  #define PyBUF_FORMAT 0x0004
 
59
  #define PyBUF_ND 0x0008
 
60
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
 
61
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
 
62
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
 
63
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
 
64
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
 
65
 
 
66
#endif
 
67
 
 
68
#if PY_MAJOR_VERSION < 3
 
69
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
 
70
#else
 
71
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
 
72
#endif
 
73
 
 
74
#if PY_MAJOR_VERSION >= 3
 
75
  #define Py_TPFLAGS_CHECKTYPES 0
 
76
  #define Py_TPFLAGS_HAVE_INDEX 0
 
77
#endif
 
78
 
 
79
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
 
80
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
 
81
#endif
 
82
 
 
83
#if PY_MAJOR_VERSION >= 3
 
84
  #define PyBaseString_Type            PyUnicode_Type
 
85
  #define PyString_Type                PyUnicode_Type
 
86
  #define PyString_CheckExact          PyUnicode_CheckExact
 
87
#else
 
88
  #define PyBytes_Type                 PyString_Type
 
89
  #define PyBytes_CheckExact           PyString_CheckExact
 
90
#endif
 
91
 
 
92
#if PY_MAJOR_VERSION >= 3
 
93
  #define PyInt_Type                   PyLong_Type
 
94
  #define PyInt_Check(op)              PyLong_Check(op)
 
95
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
 
96
  #define PyInt_FromString             PyLong_FromString
 
97
  #define PyInt_FromUnicode            PyLong_FromUnicode
 
98
  #define PyInt_FromLong               PyLong_FromLong
 
99
  #define PyInt_FromSize_t             PyLong_FromSize_t
 
100
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
 
101
  #define PyInt_AsLong                 PyLong_AsLong
 
102
  #define PyInt_AS_LONG                PyLong_AS_LONG
 
103
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
 
104
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
 
105
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
 
106
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
 
107
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
 
108
#else
 
109
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
 
110
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
 
111
 
 
112
#endif
 
113
 
 
114
#if PY_MAJOR_VERSION >= 3
 
115
  #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
 
116
#endif
 
117
 
 
118
#if !defined(WIN32) && !defined(MS_WINDOWS)
 
119
  #ifndef __stdcall
 
120
    #define __stdcall
 
121
  #endif
 
122
  #ifndef __cdecl
 
123
    #define __cdecl
 
124
  #endif
 
125
  #ifndef __fastcall
 
126
    #define __fastcall
 
127
  #endif
 
128
#else
 
129
  #define _USE_MATH_DEFINES
 
130
#endif
 
131
 
 
132
#if PY_VERSION_HEX < 0x02050000
 
133
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
 
134
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
 
135
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
 
136
#else
 
137
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
 
138
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
 
139
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
 
140
#endif
 
141
 
 
142
#if PY_VERSION_HEX < 0x02050000
 
143
  #define __Pyx_NAMESTR(n) ((char *)(n))
 
144
  #define __Pyx_DOCSTR(n)  ((char *)(n))
 
145
#else
 
146
  #define __Pyx_NAMESTR(n) (n)
 
147
  #define __Pyx_DOCSTR(n)  (n)
 
148
#endif
 
149
#ifdef __cplusplus
 
150
#define __PYX_EXTERN_C extern "C"
 
151
#else
 
152
#define __PYX_EXTERN_C extern
 
153
#endif
 
154
#include <math.h>
 
155
#define __PYX_HAVE_API__cogent__maths___period
 
156
#include "stdlib.h"
 
157
#include "stdio.h"
 
158
#include "numpy/arrayobject.h"
 
159
#include "numpy/ufuncobject.h"
 
160
 
 
161
#ifndef CYTHON_INLINE
 
162
  #if defined(__GNUC__)
 
163
    #define CYTHON_INLINE __inline__
 
164
  #elif defined(_MSC_VER)
 
165
    #define CYTHON_INLINE __inline
 
166
  #else
 
167
    #define CYTHON_INLINE 
 
168
  #endif
 
169
#endif
 
170
 
 
171
typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
 
172
 
 
173
 
 
174
/* Type Conversion Predeclarations */
 
175
 
 
176
#if PY_MAJOR_VERSION < 3
 
177
#define __Pyx_PyBytes_FromString          PyString_FromString
 
178
#define __Pyx_PyBytes_FromStringAndSize   PyString_FromStringAndSize
 
179
#define __Pyx_PyBytes_AsString            PyString_AsString
 
180
#else
 
181
#define __Pyx_PyBytes_FromString          PyBytes_FromString
 
182
#define __Pyx_PyBytes_FromStringAndSize   PyBytes_FromStringAndSize
 
183
#define __Pyx_PyBytes_AsString            PyBytes_AsString
 
184
#endif
 
185
 
 
186
#define __Pyx_PyBytes_FromUString(s)      __Pyx_PyBytes_FromString((char*)s)
 
187
#define __Pyx_PyBytes_AsUString(s)        ((unsigned char*) __Pyx_PyBytes_AsString(s))
 
188
 
 
189
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
 
190
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
 
191
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
 
192
 
 
193
#if !defined(T_PYSSIZET)
 
194
#if PY_VERSION_HEX < 0x02050000
 
195
#define T_PYSSIZET T_INT
 
196
#elif !defined(T_LONGLONG)
 
197
#define T_PYSSIZET \
 
198
        ((sizeof(Py_ssize_t) == sizeof(int))  ? T_INT  : \
 
199
        ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1))
 
200
#else
 
201
#define T_PYSSIZET \
 
202
        ((sizeof(Py_ssize_t) == sizeof(int))          ? T_INT      : \
 
203
        ((sizeof(Py_ssize_t) == sizeof(long))         ? T_LONG     : \
 
204
        ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))
 
205
#endif
 
206
#endif
 
207
 
 
208
 
 
209
#if !defined(T_ULONGLONG)
 
210
#define __Pyx_T_UNSIGNED_INT(x) \
 
211
        ((sizeof(x) == sizeof(unsigned char))  ? T_UBYTE : \
 
212
        ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \
 
213
        ((sizeof(x) == sizeof(unsigned int))   ? T_UINT : \
 
214
        ((sizeof(x) == sizeof(unsigned long))  ? T_ULONG : -1))))
 
215
#else
 
216
#define __Pyx_T_UNSIGNED_INT(x) \
 
217
        ((sizeof(x) == sizeof(unsigned char))  ? T_UBYTE : \
 
218
        ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \
 
219
        ((sizeof(x) == sizeof(unsigned int))   ? T_UINT : \
 
220
        ((sizeof(x) == sizeof(unsigned long))  ? T_ULONG : \
 
221
        ((sizeof(x) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))))
 
222
#endif
 
223
#if !defined(T_LONGLONG)
 
224
#define __Pyx_T_SIGNED_INT(x) \
 
225
        ((sizeof(x) == sizeof(char))  ? T_BYTE : \
 
226
        ((sizeof(x) == sizeof(short)) ? T_SHORT : \
 
227
        ((sizeof(x) == sizeof(int))   ? T_INT : \
 
228
        ((sizeof(x) == sizeof(long))  ? T_LONG : -1))))
 
229
#else
 
230
#define __Pyx_T_SIGNED_INT(x) \
 
231
        ((sizeof(x) == sizeof(char))  ? T_BYTE : \
 
232
        ((sizeof(x) == sizeof(short)) ? T_SHORT : \
 
233
        ((sizeof(x) == sizeof(int))   ? T_INT : \
 
234
        ((sizeof(x) == sizeof(long))  ? T_LONG : \
 
235
        ((sizeof(x) == sizeof(PY_LONG_LONG))   ? T_LONGLONG : -1)))))
 
236
#endif
 
237
 
 
238
#define __Pyx_T_FLOATING(x) \
 
239
        ((sizeof(x) == sizeof(float)) ? T_FLOAT : \
 
240
        ((sizeof(x) == sizeof(double)) ? T_DOUBLE : -1))
 
241
 
 
242
#if !defined(T_SIZET)
 
243
#if !defined(T_ULONGLONG)
 
244
#define T_SIZET \
 
245
        ((sizeof(size_t) == sizeof(unsigned int))  ? T_UINT  : \
 
246
        ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1))
 
247
#else
 
248
#define T_SIZET \
 
249
        ((sizeof(size_t) == sizeof(unsigned int))          ? T_UINT      : \
 
250
        ((sizeof(size_t) == sizeof(unsigned long))         ? T_ULONG     : \
 
251
        ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))
 
252
#endif
 
253
#endif
 
254
 
 
255
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
 
256
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
 
257
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
 
258
 
 
259
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
 
260
 
 
261
 
 
262
#ifdef __GNUC__
 
263
/* Test for GCC > 2.95 */
 
264
#if __GNUC__ > 2 ||               (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
 
265
#define likely(x)   __builtin_expect(!!(x), 1)
 
266
#define unlikely(x) __builtin_expect(!!(x), 0)
 
267
#else /* __GNUC__ > 2 ... */
 
268
#define likely(x)   (x)
 
269
#define unlikely(x) (x)
 
270
#endif /* __GNUC__ > 2 ... */
 
271
#else /* __GNUC__ */
 
272
#define likely(x)   (x)
 
273
#define unlikely(x) (x)
 
274
#endif /* __GNUC__ */
 
275
    
 
276
static PyObject *__pyx_m;
 
277
static PyObject *__pyx_b;
 
278
static PyObject *__pyx_empty_tuple;
 
279
static PyObject *__pyx_empty_bytes;
 
280
static int __pyx_lineno;
 
281
static int __pyx_clineno = 0;
 
282
static const char * __pyx_cfilenm= __FILE__;
 
283
static const char *__pyx_filename;
 
284
static const char **__pyx_f;
 
285
 
 
286
 
 
287
#if !defined(CYTHON_CCOMPLEX)
 
288
  #if defined(__cplusplus)
 
289
    #define CYTHON_CCOMPLEX 1
 
290
  #elif defined(_Complex_I)
 
291
    #define CYTHON_CCOMPLEX 1
 
292
  #else
 
293
    #define CYTHON_CCOMPLEX 0
 
294
  #endif
 
295
#endif
 
296
 
 
297
#if CYTHON_CCOMPLEX
 
298
  #ifdef __cplusplus
 
299
    #include <complex>
 
300
  #else
 
301
    #include <complex.h>
 
302
  #endif
 
303
#endif
 
304
 
 
305
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
 
306
  #undef _Complex_I
 
307
  #define _Complex_I 1.0fj
 
308
#endif
 
309
 
 
310
typedef npy_int8 __pyx_t_5numpy_int8_t;
 
311
 
 
312
typedef npy_int16 __pyx_t_5numpy_int16_t;
 
313
 
 
314
typedef npy_int32 __pyx_t_5numpy_int32_t;
 
315
 
 
316
typedef npy_int64 __pyx_t_5numpy_int64_t;
 
317
 
 
318
typedef npy_uint8 __pyx_t_5numpy_uint8_t;
 
319
 
 
320
typedef npy_uint16 __pyx_t_5numpy_uint16_t;
 
321
 
 
322
typedef npy_uint32 __pyx_t_5numpy_uint32_t;
 
323
 
 
324
typedef npy_uint64 __pyx_t_5numpy_uint64_t;
 
325
 
 
326
typedef npy_float32 __pyx_t_5numpy_float32_t;
 
327
 
 
328
typedef npy_float64 __pyx_t_5numpy_float64_t;
 
329
 
 
330
typedef npy_long __pyx_t_5numpy_int_t;
 
331
 
 
332
typedef npy_longlong __pyx_t_5numpy_long_t;
 
333
 
 
334
typedef npy_intp __pyx_t_5numpy_intp_t;
 
335
 
 
336
typedef npy_uintp __pyx_t_5numpy_uintp_t;
 
337
 
 
338
typedef npy_ulong __pyx_t_5numpy_uint_t;
 
339
 
 
340
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
 
341
 
 
342
typedef npy_double __pyx_t_5numpy_float_t;
 
343
 
 
344
typedef npy_double __pyx_t_5numpy_double_t;
 
345
 
 
346
typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
 
347
 
 
348
#if CYTHON_CCOMPLEX
 
349
  #ifdef __cplusplus
 
350
    typedef ::std::complex< double > __pyx_t_double_complex;
 
351
  #else
 
352
    typedef double _Complex __pyx_t_double_complex;
 
353
  #endif
 
354
#else
 
355
    typedef struct { double real, imag; } __pyx_t_double_complex;
 
356
#endif
 
357
 
 
358
#if CYTHON_CCOMPLEX
 
359
  #ifdef __cplusplus
 
360
    typedef ::std::complex< npy_float64 > __pyx_t_npy_float64_complex;
 
361
  #else
 
362
    typedef npy_float64 _Complex __pyx_t_npy_float64_complex;
 
363
  #endif
 
364
#else
 
365
    typedef struct { npy_float64 real, imag; } __pyx_t_npy_float64_complex;
 
366
#endif
 
367
 
 
368
#if CYTHON_CCOMPLEX
 
369
  #ifdef __cplusplus
 
370
    typedef ::std::complex< float > __pyx_t_float_complex;
 
371
  #else
 
372
    typedef float _Complex __pyx_t_float_complex;
 
373
  #endif
 
374
#else
 
375
    typedef struct { float real, imag; } __pyx_t_float_complex;
 
376
#endif
 
377
 
 
378
/* Type declarations */
 
379
 
 
380
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
 
381
 
 
382
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
 
383
 
 
384
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
 
385
 
 
386
typedef npy_cdouble __pyx_t_5numpy_complex_t;
 
387
 
 
388
#ifndef CYTHON_REFNANNY
 
389
  #define CYTHON_REFNANNY 0
 
390
#endif
 
391
 
 
392
#if CYTHON_REFNANNY
 
393
  typedef struct {
 
394
    void (*INCREF)(void*, PyObject*, int);
 
395
    void (*DECREF)(void*, PyObject*, int);
 
396
    void (*GOTREF)(void*, PyObject*, int);
 
397
    void (*GIVEREF)(void*, PyObject*, int);
 
398
    void* (*SetupContext)(const char*, int, const char*);
 
399
    void (*FinishContext)(void**);
 
400
  } __Pyx_RefNannyAPIStruct;
 
401
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
 
402
  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
 
403
    PyObject *m = NULL, *p = NULL;
 
404
    void *r = NULL;
 
405
    m = PyImport_ImportModule((char *)modname);
 
406
    if (!m) goto end;
 
407
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
 
408
    if (!p) goto end;
 
409
    r = PyLong_AsVoidPtr(p);
 
410
  end:
 
411
    Py_XDECREF(p);
 
412
    Py_XDECREF(m);
 
413
    return (__Pyx_RefNannyAPIStruct *)r;
 
414
  }
 
415
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
 
416
  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
 
417
  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
418
  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
419
  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
420
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
 
421
  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
 
422
#else
 
423
  #define __Pyx_RefNannySetupContext(name)
 
424
  #define __Pyx_RefNannyFinishContext()
 
425
  #define __Pyx_INCREF(r) Py_INCREF(r)
 
426
  #define __Pyx_DECREF(r) Py_DECREF(r)
 
427
  #define __Pyx_GOTREF(r)
 
428
  #define __Pyx_GIVEREF(r)
 
429
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
 
430
#endif /* CYTHON_REFNANNY */
 
431
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
 
432
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
 
433
 
 
434
static void __Pyx_RaiseDoubleKeywordsError(
 
435
    const char* func_name, PyObject* kw_name); /*proto*/
 
436
 
 
437
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
 
438
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
 
439
 
 
440
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
 
441
 
 
442
/* Run-time type information about structs used with buffers */
 
443
struct __Pyx_StructField_;
 
444
 
 
445
typedef struct {
 
446
  const char* name; /* for error messages only */
 
447
  struct __Pyx_StructField_* fields;
 
448
  size_t size;     /* sizeof(type) */
 
449
  char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject */
 
450
} __Pyx_TypeInfo;
 
451
 
 
452
typedef struct __Pyx_StructField_ {
 
453
  __Pyx_TypeInfo* type;
 
454
  const char* name;
 
455
  size_t offset;
 
456
} __Pyx_StructField;
 
457
 
 
458
typedef struct {
 
459
  __Pyx_StructField* field;
 
460
  size_t parent_offset;
 
461
} __Pyx_BufFmt_StackElem;
 
462
 
 
463
 
 
464
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
 
465
static int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
 
466
static void __Pyx_RaiseBufferIndexError(int axis); /*proto*/
 
467
#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
 
468
 
 
469
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 
470
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
 
471
 
 
472
#include <string.h>
 
473
 
 
474
 
 
475
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
 
476
    PyObject *r;
 
477
    if (!j) return NULL;
 
478
    r = PyObject_GetItem(o, j);
 
479
    Py_DECREF(j);
 
480
    return r;
 
481
}
 
482
 
 
483
 
 
484
#define __Pyx_GetItemInt_List(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
 
485
                                                    __Pyx_GetItemInt_List_Fast(o, i, size <= sizeof(long)) : \
 
486
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
 
487
 
 
488
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
 
489
    if (likely(o != Py_None)) {
 
490
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
 
491
            PyObject *r = PyList_GET_ITEM(o, i);
 
492
            Py_INCREF(r);
 
493
            return r;
 
494
        }
 
495
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
 
496
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
 
497
            Py_INCREF(r);
 
498
            return r;
 
499
        }
 
500
    }
 
501
    return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
 
502
}
 
503
 
 
504
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
 
505
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i, size <= sizeof(long)) : \
 
506
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
 
507
 
 
508
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
 
509
    if (likely(o != Py_None)) {
 
510
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
 
511
            PyObject *r = PyTuple_GET_ITEM(o, i);
 
512
            Py_INCREF(r);
 
513
            return r;
 
514
        }
 
515
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
 
516
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
 
517
            Py_INCREF(r);
 
518
            return r;
 
519
        }
 
520
    }
 
521
    return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
 
522
}
 
523
 
 
524
 
 
525
#define __Pyx_GetItemInt(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
 
526
                                                    __Pyx_GetItemInt_Fast(o, i, size <= sizeof(long)) : \
 
527
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
 
528
 
 
529
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
 
530
    PyObject *r;
 
531
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
 
532
        r = PyList_GET_ITEM(o, i);
 
533
        Py_INCREF(r);
 
534
    }
 
535
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
 
536
        r = PyTuple_GET_ITEM(o, i);
 
537
        Py_INCREF(r);
 
538
    }
 
539
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
 
540
        r = PySequence_GetItem(o, i);
 
541
    }
 
542
    else {
 
543
        r = __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
 
544
    }
 
545
    return r;
 
546
}
 
547
 
 
548
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
 
549
 
 
550
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void);
 
551
 
 
552
static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
 
553
static int __Pyx_EndUnpack(PyObject *); /*proto*/
 
554
 
 
555
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
 
556
 
 
557
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
 
558
 
 
559
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/
 
560
 
 
561
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
 
562
    const char *name, int exact); /*proto*/
 
563
#if PY_MAJOR_VERSION < 3
 
564
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
 
565
static void __Pyx_ReleaseBuffer(Py_buffer *view);
 
566
#else
 
567
#define __Pyx_GetBuffer PyObject_GetBuffer
 
568
#define __Pyx_ReleaseBuffer PyBuffer_Release
 
569
#endif
 
570
 
 
571
Py_ssize_t __Pyx_zeros[] = {0};
 
572
Py_ssize_t __Pyx_minusones[] = {-1};
 
573
 
 
574
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
 
575
 
 
576
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
 
577
 
 
578
#if CYTHON_CCOMPLEX
 
579
  #ifdef __cplusplus
 
580
    #define __Pyx_CREAL(z) ((z).real())
 
581
    #define __Pyx_CIMAG(z) ((z).imag())
 
582
  #else
 
583
    #define __Pyx_CREAL(z) (__real__(z))
 
584
    #define __Pyx_CIMAG(z) (__imag__(z))
 
585
  #endif
 
586
#else
 
587
    #define __Pyx_CREAL(z) ((z).real)
 
588
    #define __Pyx_CIMAG(z) ((z).imag)
 
589
#endif
 
590
 
 
591
#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX
 
592
    #define __Pyx_SET_CREAL(z,x) ((z).real(x))
 
593
    #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
 
594
#else
 
595
    #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
 
596
    #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
 
597
#endif
 
598
 
 
599
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
 
600
 
 
601
#if CYTHON_CCOMPLEX
 
602
    #define __Pyx_c_eq(a, b)   ((a)==(b))
 
603
    #define __Pyx_c_sum(a, b)  ((a)+(b))
 
604
    #define __Pyx_c_diff(a, b) ((a)-(b))
 
605
    #define __Pyx_c_prod(a, b) ((a)*(b))
 
606
    #define __Pyx_c_quot(a, b) ((a)/(b))
 
607
    #define __Pyx_c_neg(a)     (-(a))
 
608
  #ifdef __cplusplus
 
609
    #define __Pyx_c_is_zero(z) ((z)==(double)0)
 
610
    #define __Pyx_c_conj(z)    (::std::conj(z))
 
611
    /*#define __Pyx_c_abs(z)     (::std::abs(z))*/
 
612
  #else
 
613
    #define __Pyx_c_is_zero(z) ((z)==0)
 
614
    #define __Pyx_c_conj(z)    (conj(z))
 
615
    /*#define __Pyx_c_abs(z)     (cabs(z))*/
 
616
 #endif
 
617
#else
 
618
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex);
 
619
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex);
 
620
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex);
 
621
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex);
 
622
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex);
 
623
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex);
 
624
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex);
 
625
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex);
 
626
    /*static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex);*/
 
627
#endif
 
628
 
 
629
static CYTHON_INLINE __pyx_t_npy_float64_complex __pyx_t_npy_float64_complex_from_parts(npy_float64, npy_float64);
 
630
 
 
631
#if CYTHON_CCOMPLEX
 
632
    #define __Pyx_c_eq_npy_float64(a, b)   ((a)==(b))
 
633
    #define __Pyx_c_sum_npy_float64(a, b)  ((a)+(b))
 
634
    #define __Pyx_c_diff_npy_float64(a, b) ((a)-(b))
 
635
    #define __Pyx_c_prod_npy_float64(a, b) ((a)*(b))
 
636
    #define __Pyx_c_quot_npy_float64(a, b) ((a)/(b))
 
637
    #define __Pyx_c_neg_npy_float64(a)     (-(a))
 
638
  #ifdef __cplusplus
 
639
    #define __Pyx_c_is_zero_npy_float64(z) ((z)==(npy_float64)0)
 
640
    #define __Pyx_c_conj_npy_float64(z)    (::std::conj(z))
 
641
    /*#define __Pyx_c_abs_npy_float64(z)     (::std::abs(z))*/
 
642
  #else
 
643
    #define __Pyx_c_is_zero_npy_float64(z) ((z)==0)
 
644
    #define __Pyx_c_conj_npy_float64(z)    (conj_npy_float64(z))
 
645
    /*#define __Pyx_c_abs_npy_float64(z)     (cabs_npy_float64(z))*/
 
646
 #endif
 
647
#else
 
648
    static CYTHON_INLINE int __Pyx_c_eq_npy_float64(__pyx_t_npy_float64_complex, __pyx_t_npy_float64_complex);
 
649
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_sum_npy_float64(__pyx_t_npy_float64_complex, __pyx_t_npy_float64_complex);
 
650
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_diff_npy_float64(__pyx_t_npy_float64_complex, __pyx_t_npy_float64_complex);
 
651
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_prod_npy_float64(__pyx_t_npy_float64_complex, __pyx_t_npy_float64_complex);
 
652
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_quot_npy_float64(__pyx_t_npy_float64_complex, __pyx_t_npy_float64_complex);
 
653
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_neg_npy_float64(__pyx_t_npy_float64_complex);
 
654
    static CYTHON_INLINE int __Pyx_c_is_zero_npy_float64(__pyx_t_npy_float64_complex);
 
655
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_conj_npy_float64(__pyx_t_npy_float64_complex);
 
656
    /*static CYTHON_INLINE npy_float64 __Pyx_c_abs_npy_float64(__pyx_t_npy_float64_complex);*/
 
657
#endif
 
658
 
 
659
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
 
660
 
 
661
#if CYTHON_CCOMPLEX
 
662
    #define __Pyx_c_eqf(a, b)   ((a)==(b))
 
663
    #define __Pyx_c_sumf(a, b)  ((a)+(b))
 
664
    #define __Pyx_c_difff(a, b) ((a)-(b))
 
665
    #define __Pyx_c_prodf(a, b) ((a)*(b))
 
666
    #define __Pyx_c_quotf(a, b) ((a)/(b))
 
667
    #define __Pyx_c_negf(a)     (-(a))
 
668
  #ifdef __cplusplus
 
669
    #define __Pyx_c_is_zerof(z) ((z)==(float)0)
 
670
    #define __Pyx_c_conjf(z)    (::std::conj(z))
 
671
    /*#define __Pyx_c_absf(z)     (::std::abs(z))*/
 
672
  #else
 
673
    #define __Pyx_c_is_zerof(z) ((z)==0)
 
674
    #define __Pyx_c_conjf(z)    (conjf(z))
 
675
    /*#define __Pyx_c_absf(z)     (cabsf(z))*/
 
676
 #endif
 
677
#else
 
678
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex);
 
679
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex);
 
680
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex);
 
681
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex);
 
682
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex);
 
683
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex);
 
684
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex);
 
685
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex);
 
686
    /*static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex);*/
 
687
#endif
 
688
 
 
689
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 
690
 
 
691
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
 
692
 
 
693
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
 
694
 
 
695
static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
 
696
 
 
697
static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
 
698
 
 
699
static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
 
700
 
 
701
static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
 
702
 
 
703
static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
 
704
 
 
705
static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
 
706
 
 
707
static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
 
708
 
 
709
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
 
710
 
 
711
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
 
712
 
 
713
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
 
714
 
 
715
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
 
716
 
 
717
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
 
718
 
 
719
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
 
720
 
 
721
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/
 
722
 
 
723
static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
 
724
 
 
725
static void __Pyx_AddTraceback(const char *funcname); /*proto*/
 
726
 
 
727
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
 
728
/* Module declarations from python_buffer */
 
729
 
 
730
/* Module declarations from python_ref */
 
731
 
 
732
/* Module declarations from stdlib */
 
733
 
 
734
/* Module declarations from stdio */
 
735
 
 
736
/* Module declarations from numpy */
 
737
 
 
738
/* Module declarations from numpy */
 
739
 
 
740
static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
 
741
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
 
742
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
 
743
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
 
744
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
 
745
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *); /*proto*/
 
746
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *, PyObject *); /*proto*/
 
747
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *, PyObject *, PyObject *); /*proto*/
 
748
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
 
749
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
 
750
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/
 
751
static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *, PyObject *); /*proto*/
 
752
static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *); /*proto*/
 
753
/* Module declarations from cogent.maths._period */
 
754
 
 
755
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "numpy.float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), 'R' };
 
756
static __Pyx_TypeInfo __Pyx_TypeInfo___pyx_t_double_complex = { "double complex", NULL, sizeof(__pyx_t_double_complex), 'C' };
 
757
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t = { "numpy.uint8_t", NULL, sizeof(__pyx_t_5numpy_uint8_t), 'U' };
 
758
#define __Pyx_MODULE_NAME "cogent.maths._period"
 
759
int __pyx_module_is_main_cogent__maths___period = 0;
 
760
 
 
761
/* Implementation of cogent.maths._period */
 
762
static PyObject *__pyx_builtin_range;
 
763
static PyObject *__pyx_builtin_ValueError;
 
764
static PyObject *__pyx_builtin_RuntimeError;
 
765
static char __pyx_k_1[] = "ndarray is not C contiguous";
 
766
static char __pyx_k_2[] = "ndarray is not Fortran contiguous";
 
767
static char __pyx_k_3[] = "Non-native byte order not supported";
 
768
static char __pyx_k_4[] = "unknown dtype code in numpy.pxd (%d)";
 
769
static char __pyx_k_5[] = "Format string allocated too short, see comment in numpy.pxd";
 
770
static char __pyx_k_6[] = "Format string allocated too short.";
 
771
static char __pyx_k_7[] = "goertzel_inner (line 6)";
 
772
static char __pyx_k_8[] = "ipdft_inner (line 22)";
 
773
static char __pyx_k__B[] = "B";
 
774
static char __pyx_k__H[] = "H";
 
775
static char __pyx_k__I[] = "I";
 
776
static char __pyx_k__L[] = "L";
 
777
static char __pyx_k__N[] = "N";
 
778
static char __pyx_k__O[] = "O";
 
779
static char __pyx_k__Q[] = "Q";
 
780
static char __pyx_k__W[] = "W";
 
781
static char __pyx_k__X[] = "X";
 
782
static char __pyx_k__b[] = "b";
 
783
static char __pyx_k__d[] = "d";
 
784
static char __pyx_k__f[] = "f";
 
785
static char __pyx_k__g[] = "g";
 
786
static char __pyx_k__h[] = "h";
 
787
static char __pyx_k__i[] = "i";
 
788
static char __pyx_k__l[] = "l";
 
789
static char __pyx_k__q[] = "q";
 
790
static char __pyx_k__x[] = "x";
 
791
static char __pyx_k__Zd[] = "Zd";
 
792
static char __pyx_k__Zf[] = "Zf";
 
793
static char __pyx_k__Zg[] = "Zg";
 
794
static char __pyx_k__pi[] = "pi";
 
795
static char __pyx_k__xc[] = "xc";
 
796
static char __pyx_k__buf[] = "buf";
 
797
static char __pyx_k__cos[] = "cos";
 
798
static char __pyx_k__exp[] = "exp";
 
799
static char __pyx_k__obj[] = "obj";
 
800
static char __pyx_k__seq[] = "seq";
 
801
static char __pyx_k__base[] = "base";
 
802
static char __pyx_k__ndim[] = "ndim";
 
803
static char __pyx_k__sqrt[] = "sqrt";
 
804
static char __pyx_k__ulim[] = "ulim";
 
805
static char __pyx_k__descr[] = "descr";
 
806
static char __pyx_k__names[] = "names";
 
807
static char __pyx_k__numpy[] = "numpy";
 
808
static char __pyx_k__range[] = "range";
 
809
static char __pyx_k__shape[] = "shape";
 
810
static char __pyx_k__fields[] = "fields";
 
811
static char __pyx_k__format[] = "format";
 
812
static char __pyx_k__motifs[] = "motifs";
 
813
static char __pyx_k__period[] = "period";
 
814
static char __pyx_k__result[] = "result";
 
815
static char __pyx_k__strides[] = "strides";
 
816
static char __pyx_k____main__[] = "__main__";
 
817
static char __pyx_k____test__[] = "__test__";
 
818
static char __pyx_k__itemsize[] = "itemsize";
 
819
static char __pyx_k__readonly[] = "readonly";
 
820
static char __pyx_k__type_num[] = "type_num";
 
821
static char __pyx_k__byteorder[] = "byteorder";
 
822
static char __pyx_k__ValueError[] = "ValueError";
 
823
static char __pyx_k__suboffsets[] = "suboffsets";
 
824
static char __pyx_k__ipdft_inner[] = "ipdft_inner";
 
825
static char __pyx_k__RuntimeError[] = "RuntimeError";
 
826
static char __pyx_k__motif_length[] = "motif_length";
 
827
static char __pyx_k__goertzel_inner[] = "goertzel_inner";
 
828
static PyObject *__pyx_kp_u_1;
 
829
static PyObject *__pyx_kp_u_2;
 
830
static PyObject *__pyx_kp_u_3;
 
831
static PyObject *__pyx_kp_u_4;
 
832
static PyObject *__pyx_kp_u_5;
 
833
static PyObject *__pyx_kp_u_6;
 
834
static PyObject *__pyx_kp_u_7;
 
835
static PyObject *__pyx_kp_u_8;
 
836
static PyObject *__pyx_n_s__N;
 
837
static PyObject *__pyx_n_s__RuntimeError;
 
838
static PyObject *__pyx_n_s__ValueError;
 
839
static PyObject *__pyx_n_s__W;
 
840
static PyObject *__pyx_n_s__X;
 
841
static PyObject *__pyx_n_s____main__;
 
842
static PyObject *__pyx_n_s____test__;
 
843
static PyObject *__pyx_n_s__base;
 
844
static PyObject *__pyx_n_s__buf;
 
845
static PyObject *__pyx_n_s__byteorder;
 
846
static PyObject *__pyx_n_s__cos;
 
847
static PyObject *__pyx_n_s__descr;
 
848
static PyObject *__pyx_n_s__exp;
 
849
static PyObject *__pyx_n_s__fields;
 
850
static PyObject *__pyx_n_s__format;
 
851
static PyObject *__pyx_n_s__goertzel_inner;
 
852
static PyObject *__pyx_n_s__ipdft_inner;
 
853
static PyObject *__pyx_n_s__itemsize;
 
854
static PyObject *__pyx_n_s__motif_length;
 
855
static PyObject *__pyx_n_s__motifs;
 
856
static PyObject *__pyx_n_s__names;
 
857
static PyObject *__pyx_n_s__ndim;
 
858
static PyObject *__pyx_n_s__numpy;
 
859
static PyObject *__pyx_n_s__obj;
 
860
static PyObject *__pyx_n_s__period;
 
861
static PyObject *__pyx_n_s__pi;
 
862
static PyObject *__pyx_n_s__range;
 
863
static PyObject *__pyx_n_s__readonly;
 
864
static PyObject *__pyx_n_s__result;
 
865
static PyObject *__pyx_n_s__seq;
 
866
static PyObject *__pyx_n_s__shape;
 
867
static PyObject *__pyx_n_s__sqrt;
 
868
static PyObject *__pyx_n_s__strides;
 
869
static PyObject *__pyx_n_s__suboffsets;
 
870
static PyObject *__pyx_n_s__type_num;
 
871
static PyObject *__pyx_n_s__ulim;
 
872
static PyObject *__pyx_n_s__x;
 
873
static PyObject *__pyx_n_s__xc;
 
874
static PyObject *__pyx_int_2;
 
875
static PyObject *__pyx_int_15;
 
876
 
 
877
/* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":6
 
878
 * # TODO intro the version idea of peter's see email from him on Wednesday, 26 May 2010
 
879
 * 
 
880
 * def goertzel_inner(np.ndarray[np.float64_t, ndim=1] x, int N, int period):             # <<<<<<<<<<<<<<
 
881
 *     """returns the power from series x for period"""
 
882
 *     cdef int n
 
883
 */
 
884
 
 
885
static PyObject *__pyx_pf_6cogent_5maths_7_period_goertzel_inner(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
886
static char __pyx_doc_6cogent_5maths_7_period_goertzel_inner[] = "returns the power from series x for period";
 
887
static PyObject *__pyx_pf_6cogent_5maths_7_period_goertzel_inner(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
888
  PyArrayObject *__pyx_v_x = 0;
 
889
  int __pyx_v_N;
 
890
  int __pyx_v_period;
 
891
  int __pyx_v_n;
 
892
  __pyx_t_5numpy_float64_t __pyx_v_coeff;
 
893
  __pyx_t_5numpy_float64_t __pyx_v_s;
 
894
  __pyx_t_5numpy_float64_t __pyx_v_s_prev;
 
895
  __pyx_t_5numpy_float64_t __pyx_v_s_prev2;
 
896
  __pyx_t_5numpy_float64_t __pyx_v_power;
 
897
  Py_buffer __pyx_bstruct_x;
 
898
  Py_ssize_t __pyx_bstride_0_x = 0;
 
899
  Py_ssize_t __pyx_bshape_0_x = 0;
 
900
  PyObject *__pyx_r = NULL;
 
901
  PyObject *__pyx_t_1 = NULL;
 
902
  PyObject *__pyx_t_2 = NULL;
 
903
  PyObject *__pyx_t_3 = NULL;
 
904
  PyObject *__pyx_t_4 = NULL;
 
905
  PyObject *__pyx_t_5 = NULL;
 
906
  __pyx_t_5numpy_float64_t __pyx_t_6;
 
907
  int __pyx_t_7;
 
908
  int __pyx_t_8;
 
909
  int __pyx_t_9;
 
910
  int __pyx_t_10;
 
911
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__N,&__pyx_n_s__period,0};
 
912
  __Pyx_RefNannySetupContext("goertzel_inner");
 
913
  __pyx_self = __pyx_self;
 
914
  if (unlikely(__pyx_kwds)) {
 
915
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
916
    PyObject* values[3] = {0,0,0};
 
917
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
918
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
 
919
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
 
920
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
921
      case  0: break;
 
922
      default: goto __pyx_L5_argtuple_error;
 
923
    }
 
924
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
925
      case  0:
 
926
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
 
927
      if (likely(values[0])) kw_args--;
 
928
      else goto __pyx_L5_argtuple_error;
 
929
      case  1:
 
930
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__N);
 
931
      if (likely(values[1])) kw_args--;
 
932
      else {
 
933
        __Pyx_RaiseArgtupleInvalid("goertzel_inner", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
934
      }
 
935
      case  2:
 
936
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__period);
 
937
      if (likely(values[2])) kw_args--;
 
938
      else {
 
939
        __Pyx_RaiseArgtupleInvalid("goertzel_inner", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
940
      }
 
941
    }
 
942
    if (unlikely(kw_args > 0)) {
 
943
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "goertzel_inner") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
944
    }
 
945
    __pyx_v_x = ((PyArrayObject *)values[0]);
 
946
    __pyx_v_N = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
947
    __pyx_v_period = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_period == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
948
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
 
949
    goto __pyx_L5_argtuple_error;
 
950
  } else {
 
951
    __pyx_v_x = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
 
952
    __pyx_v_N = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
953
    __pyx_v_period = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_period == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
954
  }
 
955
  goto __pyx_L4_argument_unpacking_done;
 
956
  __pyx_L5_argtuple_error:;
 
957
  __Pyx_RaiseArgtupleInvalid("goertzel_inner", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
958
  __pyx_L3_error:;
 
959
  __Pyx_AddTraceback("cogent.maths._period.goertzel_inner");
 
960
  return NULL;
 
961
  __pyx_L4_argument_unpacking_done:;
 
962
  __Pyx_INCREF((PyObject *)__pyx_v_x);
 
963
  __pyx_bstruct_x.buf = NULL;
 
964
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
965
  {
 
966
    __Pyx_BufFmt_StackElem __pyx_stack[1];
 
967
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
968
  }
 
969
  __pyx_bstride_0_x = __pyx_bstruct_x.strides[0];
 
970
  __pyx_bshape_0_x = __pyx_bstruct_x.shape[0];
 
971
 
 
972
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":11
 
973
 *     cdef np.float64_t coeff, s, s_prev, s_prev2, power
 
974
 * 
 
975
 *     coeff = 2.0 * cos(2 * pi / period)             # <<<<<<<<<<<<<<
 
976
 *     s_prev = 0.0
 
977
 *     s_prev2 = 0.0
 
978
 */
 
979
  __pyx_t_1 = PyFloat_FromDouble(2.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
980
  __Pyx_GOTREF(__pyx_t_1);
 
981
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__cos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
982
  __Pyx_GOTREF(__pyx_t_2);
 
983
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__pi); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
984
  __Pyx_GOTREF(__pyx_t_3);
 
985
  __pyx_t_4 = PyNumber_Multiply(__pyx_int_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
986
  __Pyx_GOTREF(__pyx_t_4);
 
987
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
988
  __pyx_t_3 = PyInt_FromLong(__pyx_v_period); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
989
  __Pyx_GOTREF(__pyx_t_3);
 
990
  __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
991
  __Pyx_GOTREF(__pyx_t_5);
 
992
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
993
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
994
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
995
  __Pyx_GOTREF(__pyx_t_3);
 
996
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
 
997
  __Pyx_GIVEREF(__pyx_t_5);
 
998
  __pyx_t_5 = 0;
 
999
  __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1000
  __Pyx_GOTREF(__pyx_t_5);
 
1001
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
1002
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
1003
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1004
  __Pyx_GOTREF(__pyx_t_3);
 
1005
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
1006
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
1007
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1008
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
1009
  __pyx_v_coeff = __pyx_t_6;
 
1010
 
 
1011
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":12
 
1012
 * 
 
1013
 *     coeff = 2.0 * cos(2 * pi / period)
 
1014
 *     s_prev = 0.0             # <<<<<<<<<<<<<<
 
1015
 *     s_prev2 = 0.0
 
1016
 *     for n in range(N):
 
1017
 */
 
1018
  __pyx_v_s_prev = 0.0;
 
1019
 
 
1020
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":13
 
1021
 *     coeff = 2.0 * cos(2 * pi / period)
 
1022
 *     s_prev = 0.0
 
1023
 *     s_prev2 = 0.0             # <<<<<<<<<<<<<<
 
1024
 *     for n in range(N):
 
1025
 *         s = x[n] + coeff * s_prev - s_prev2
 
1026
 */
 
1027
  __pyx_v_s_prev2 = 0.0;
 
1028
 
 
1029
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":14
 
1030
 *     s_prev = 0.0
 
1031
 *     s_prev2 = 0.0
 
1032
 *     for n in range(N):             # <<<<<<<<<<<<<<
 
1033
 *         s = x[n] + coeff * s_prev - s_prev2
 
1034
 *         s_prev2 = s_prev
 
1035
 */
 
1036
  __pyx_t_7 = __pyx_v_N;
 
1037
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
 
1038
    __pyx_v_n = __pyx_t_8;
 
1039
 
 
1040
    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":15
 
1041
 *     s_prev2 = 0.0
 
1042
 *     for n in range(N):
 
1043
 *         s = x[n] + coeff * s_prev - s_prev2             # <<<<<<<<<<<<<<
 
1044
 *         s_prev2 = s_prev
 
1045
 *         s_prev = s
 
1046
 */
 
1047
    __pyx_t_9 = __pyx_v_n;
 
1048
    __pyx_t_10 = -1;
 
1049
    if (__pyx_t_9 < 0) {
 
1050
      __pyx_t_9 += __pyx_bshape_0_x;
 
1051
      if (unlikely(__pyx_t_9 < 0)) __pyx_t_10 = 0;
 
1052
    } else if (unlikely(__pyx_t_9 >= __pyx_bshape_0_x)) __pyx_t_10 = 0;
 
1053
    if (unlikely(__pyx_t_10 != -1)) {
 
1054
      __Pyx_RaiseBufferIndexError(__pyx_t_10);
 
1055
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1056
    }
 
1057
    __pyx_v_s = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x.buf, __pyx_t_9, __pyx_bstride_0_x)) + (__pyx_v_coeff * __pyx_v_s_prev)) - __pyx_v_s_prev2);
 
1058
 
 
1059
    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":16
 
1060
 *     for n in range(N):
 
1061
 *         s = x[n] + coeff * s_prev - s_prev2
 
1062
 *         s_prev2 = s_prev             # <<<<<<<<<<<<<<
 
1063
 *         s_prev = s
 
1064
 * 
 
1065
 */
 
1066
    __pyx_v_s_prev2 = __pyx_v_s_prev;
 
1067
 
 
1068
    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":17
 
1069
 *         s = x[n] + coeff * s_prev - s_prev2
 
1070
 *         s_prev2 = s_prev
 
1071
 *         s_prev = s             # <<<<<<<<<<<<<<
 
1072
 * 
 
1073
 *     power = sqrt(s_prev2**2 + s_prev**2 - coeff * s_prev2 * s_prev)
 
1074
 */
 
1075
    __pyx_v_s_prev = __pyx_v_s;
 
1076
  }
 
1077
 
 
1078
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":19
 
1079
 *         s_prev = s
 
1080
 * 
 
1081
 *     power = sqrt(s_prev2**2 + s_prev**2 - coeff * s_prev2 * s_prev)             # <<<<<<<<<<<<<<
 
1082
 *     return power
 
1083
 * 
 
1084
 */
 
1085
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sqrt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1086
  __Pyx_GOTREF(__pyx_t_3);
 
1087
  __pyx_t_5 = PyFloat_FromDouble(((pow(__pyx_v_s_prev2, 2) + pow(__pyx_v_s_prev, 2)) - ((__pyx_v_coeff * __pyx_v_s_prev2) * __pyx_v_s_prev))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1088
  __Pyx_GOTREF(__pyx_t_5);
 
1089
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1090
  __Pyx_GOTREF(__pyx_t_1);
 
1091
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
 
1092
  __Pyx_GIVEREF(__pyx_t_5);
 
1093
  __pyx_t_5 = 0;
 
1094
  __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1095
  __Pyx_GOTREF(__pyx_t_5);
 
1096
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
1097
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
1098
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_6 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1099
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
1100
  __pyx_v_power = __pyx_t_6;
 
1101
 
 
1102
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":20
 
1103
 * 
 
1104
 *     power = sqrt(s_prev2**2 + s_prev**2 - coeff * s_prev2 * s_prev)
 
1105
 *     return power             # <<<<<<<<<<<<<<
 
1106
 * 
 
1107
 * def ipdft_inner(np.ndarray[np.float64_t, ndim=1] x,
 
1108
 */
 
1109
  __Pyx_XDECREF(__pyx_r);
 
1110
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_power); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1111
  __Pyx_GOTREF(__pyx_t_5);
 
1112
  __pyx_r = __pyx_t_5;
 
1113
  __pyx_t_5 = 0;
 
1114
  goto __pyx_L0;
 
1115
 
 
1116
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
1117
  goto __pyx_L0;
 
1118
  __pyx_L1_error:;
 
1119
  __Pyx_XDECREF(__pyx_t_1);
 
1120
  __Pyx_XDECREF(__pyx_t_2);
 
1121
  __Pyx_XDECREF(__pyx_t_3);
 
1122
  __Pyx_XDECREF(__pyx_t_4);
 
1123
  __Pyx_XDECREF(__pyx_t_5);
 
1124
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
 
1125
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
 
1126
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x);
 
1127
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
 
1128
  __Pyx_AddTraceback("cogent.maths._period.goertzel_inner");
 
1129
  __pyx_r = NULL;
 
1130
  goto __pyx_L2;
 
1131
  __pyx_L0:;
 
1132
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x);
 
1133
  __pyx_L2:;
 
1134
  __Pyx_DECREF((PyObject *)__pyx_v_x);
 
1135
  __Pyx_XGIVEREF(__pyx_r);
 
1136
  __Pyx_RefNannyFinishContext();
 
1137
  return __pyx_r;
 
1138
}
 
1139
 
 
1140
/* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":22
 
1141
 *     return power
 
1142
 * 
 
1143
 * def ipdft_inner(np.ndarray[np.float64_t, ndim=1] x,             # <<<<<<<<<<<<<<
 
1144
 *                        np.ndarray[np.complex128_t, ndim=1] X,
 
1145
 *                        np.ndarray[np.complex128_t, ndim=1] W,
 
1146
 */
 
1147
 
 
1148
static PyObject *__pyx_pf_6cogent_5maths_7_period_ipdft_inner(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
1149
static char __pyx_doc_6cogent_5maths_7_period_ipdft_inner[] = "use this when repeated calls for window of same length are to be\n    made";
 
1150
static PyObject *__pyx_pf_6cogent_5maths_7_period_ipdft_inner(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
1151
  PyArrayObject *__pyx_v_x = 0;
 
1152
  PyArrayObject *__pyx_v_X = 0;
 
1153
  PyArrayObject *__pyx_v_W = 0;
 
1154
  int __pyx_v_ulim;
 
1155
  int __pyx_v_N;
 
1156
  int __pyx_v_n;
 
1157
  int __pyx_v_p;
 
1158
  __pyx_t_double_complex __pyx_v_w;
 
1159
  Py_buffer __pyx_bstruct_X;
 
1160
  Py_ssize_t __pyx_bstride_0_X = 0;
 
1161
  Py_ssize_t __pyx_bshape_0_X = 0;
 
1162
  Py_buffer __pyx_bstruct_W;
 
1163
  Py_ssize_t __pyx_bstride_0_W = 0;
 
1164
  Py_ssize_t __pyx_bshape_0_W = 0;
 
1165
  Py_buffer __pyx_bstruct_x;
 
1166
  Py_ssize_t __pyx_bstride_0_x = 0;
 
1167
  Py_ssize_t __pyx_bshape_0_x = 0;
 
1168
  PyObject *__pyx_r = NULL;
 
1169
  int __pyx_t_1;
 
1170
  int __pyx_t_2;
 
1171
  int __pyx_t_3;
 
1172
  int __pyx_t_4;
 
1173
  int __pyx_t_5;
 
1174
  int __pyx_t_6;
 
1175
  int __pyx_t_7;
 
1176
  int __pyx_t_8;
 
1177
  int __pyx_t_9;
 
1178
  __pyx_t_npy_float64_complex __pyx_t_10;
 
1179
  int __pyx_t_11;
 
1180
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__X,&__pyx_n_s__W,&__pyx_n_s__ulim,&__pyx_n_s__N,0};
 
1181
  __Pyx_RefNannySetupContext("ipdft_inner");
 
1182
  __pyx_self = __pyx_self;
 
1183
  if (unlikely(__pyx_kwds)) {
 
1184
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
1185
    PyObject* values[5] = {0,0,0,0,0};
 
1186
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
1187
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
 
1188
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
 
1189
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
 
1190
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
 
1191
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
1192
      case  0: break;
 
1193
      default: goto __pyx_L5_argtuple_error;
 
1194
    }
 
1195
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
1196
      case  0:
 
1197
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
 
1198
      if (likely(values[0])) kw_args--;
 
1199
      else goto __pyx_L5_argtuple_error;
 
1200
      case  1:
 
1201
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X);
 
1202
      if (likely(values[1])) kw_args--;
 
1203
      else {
 
1204
        __Pyx_RaiseArgtupleInvalid("ipdft_inner", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1205
      }
 
1206
      case  2:
 
1207
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__W);
 
1208
      if (likely(values[2])) kw_args--;
 
1209
      else {
 
1210
        __Pyx_RaiseArgtupleInvalid("ipdft_inner", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1211
      }
 
1212
      case  3:
 
1213
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ulim);
 
1214
      if (likely(values[3])) kw_args--;
 
1215
      else {
 
1216
        __Pyx_RaiseArgtupleInvalid("ipdft_inner", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1217
      }
 
1218
      case  4:
 
1219
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__N);
 
1220
      if (likely(values[4])) kw_args--;
 
1221
      else {
 
1222
        __Pyx_RaiseArgtupleInvalid("ipdft_inner", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1223
      }
 
1224
    }
 
1225
    if (unlikely(kw_args > 0)) {
 
1226
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "ipdft_inner") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1227
    }
 
1228
    __pyx_v_x = ((PyArrayObject *)values[0]);
 
1229
    __pyx_v_X = ((PyArrayObject *)values[1]);
 
1230
    __pyx_v_W = ((PyArrayObject *)values[2]);
 
1231
    __pyx_v_ulim = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_ulim == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1232
    __pyx_v_N = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1233
  } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
 
1234
    goto __pyx_L5_argtuple_error;
 
1235
  } else {
 
1236
    __pyx_v_x = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
 
1237
    __pyx_v_X = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
 
1238
    __pyx_v_W = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
 
1239
    __pyx_v_ulim = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_ulim == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1240
    __pyx_v_N = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1241
  }
 
1242
  goto __pyx_L4_argument_unpacking_done;
 
1243
  __pyx_L5_argtuple_error:;
 
1244
  __Pyx_RaiseArgtupleInvalid("ipdft_inner", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1245
  __pyx_L3_error:;
 
1246
  __Pyx_AddTraceback("cogent.maths._period.ipdft_inner");
 
1247
  return NULL;
 
1248
  __pyx_L4_argument_unpacking_done:;
 
1249
  __Pyx_INCREF((PyObject *)__pyx_v_x);
 
1250
  __Pyx_INCREF((PyObject *)__pyx_v_X);
 
1251
  __Pyx_INCREF((PyObject *)__pyx_v_W);
 
1252
  __pyx_bstruct_x.buf = NULL;
 
1253
  __pyx_bstruct_X.buf = NULL;
 
1254
  __pyx_bstruct_W.buf = NULL;
 
1255
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1256
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1257
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_W), __pyx_ptype_5numpy_ndarray, 1, "W", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1258
  {
 
1259
    __Pyx_BufFmt_StackElem __pyx_stack[1];
 
1260
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1261
  }
 
1262
  __pyx_bstride_0_x = __pyx_bstruct_x.strides[0];
 
1263
  __pyx_bshape_0_x = __pyx_bstruct_x.shape[0];
 
1264
  {
 
1265
    __Pyx_BufFmt_StackElem __pyx_stack[1];
 
1266
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_X, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1267
  }
 
1268
  __pyx_bstride_0_X = __pyx_bstruct_X.strides[0];
 
1269
  __pyx_bshape_0_X = __pyx_bstruct_X.shape[0];
 
1270
  {
 
1271
    __Pyx_BufFmt_StackElem __pyx_stack[1];
 
1272
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_W, (PyObject*)__pyx_v_W, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1273
  }
 
1274
  __pyx_bstride_0_W = __pyx_bstruct_W.strides[0];
 
1275
  __pyx_bshape_0_W = __pyx_bstruct_W.shape[0];
 
1276
 
 
1277
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":31
 
1278
 *     cdef np.complex128_t w
 
1279
 * 
 
1280
 *     for p in range(ulim):             # <<<<<<<<<<<<<<
 
1281
 *         w = 1.0
 
1282
 *         for n in range(N):
 
1283
 */
 
1284
  __pyx_t_1 = __pyx_v_ulim;
 
1285
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
 
1286
    __pyx_v_p = __pyx_t_2;
 
1287
 
 
1288
    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":32
 
1289
 * 
 
1290
 *     for p in range(ulim):
 
1291
 *         w = 1.0             # <<<<<<<<<<<<<<
 
1292
 *         for n in range(N):
 
1293
 *             if n != 0:
 
1294
 */
 
1295
    __pyx_v_w = __pyx_t_double_complex_from_parts(1.0, 0);
 
1296
 
 
1297
    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":33
 
1298
 *     for p in range(ulim):
 
1299
 *         w = 1.0
 
1300
 *         for n in range(N):             # <<<<<<<<<<<<<<
 
1301
 *             if n != 0:
 
1302
 *                 w = w * W[p]
 
1303
 */
 
1304
    __pyx_t_3 = __pyx_v_N;
 
1305
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
 
1306
      __pyx_v_n = __pyx_t_4;
 
1307
 
 
1308
      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":34
 
1309
 *         w = 1.0
 
1310
 *         for n in range(N):
 
1311
 *             if n != 0:             # <<<<<<<<<<<<<<
 
1312
 *                 w = w * W[p]
 
1313
 *             X[p] = X[p] + x[n]*w
 
1314
 */
 
1315
      __pyx_t_5 = (__pyx_v_n != 0);
 
1316
      if (__pyx_t_5) {
 
1317
 
 
1318
        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":35
 
1319
 *         for n in range(N):
 
1320
 *             if n != 0:
 
1321
 *                 w = w * W[p]             # <<<<<<<<<<<<<<
 
1322
 *             X[p] = X[p] + x[n]*w
 
1323
 *     return X
 
1324
 */
 
1325
        __pyx_t_6 = __pyx_v_p;
 
1326
        __pyx_t_7 = -1;
 
1327
        if (__pyx_t_6 < 0) {
 
1328
          __pyx_t_6 += __pyx_bshape_0_W;
 
1329
          if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 0;
 
1330
        } else if (unlikely(__pyx_t_6 >= __pyx_bshape_0_W)) __pyx_t_7 = 0;
 
1331
        if (unlikely(__pyx_t_7 != -1)) {
 
1332
          __Pyx_RaiseBufferIndexError(__pyx_t_7);
 
1333
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1334
        }
 
1335
        __pyx_v_w = __Pyx_c_prod(__pyx_v_w, (*__Pyx_BufPtrStrided1d(__pyx_t_double_complex *, __pyx_bstruct_W.buf, __pyx_t_6, __pyx_bstride_0_W)));
 
1336
        goto __pyx_L10;
 
1337
      }
 
1338
      __pyx_L10:;
 
1339
 
 
1340
      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":36
 
1341
 *             if n != 0:
 
1342
 *                 w = w * W[p]
 
1343
 *             X[p] = X[p] + x[n]*w             # <<<<<<<<<<<<<<
 
1344
 *     return X
 
1345
 * 
 
1346
 */
 
1347
      __pyx_t_7 = __pyx_v_p;
 
1348
      __pyx_t_8 = -1;
 
1349
      if (__pyx_t_7 < 0) {
 
1350
        __pyx_t_7 += __pyx_bshape_0_X;
 
1351
        if (unlikely(__pyx_t_7 < 0)) __pyx_t_8 = 0;
 
1352
      } else if (unlikely(__pyx_t_7 >= __pyx_bshape_0_X)) __pyx_t_8 = 0;
 
1353
      if (unlikely(__pyx_t_8 != -1)) {
 
1354
        __Pyx_RaiseBufferIndexError(__pyx_t_8);
 
1355
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1356
      }
 
1357
      __pyx_t_8 = __pyx_v_n;
 
1358
      __pyx_t_9 = -1;
 
1359
      if (__pyx_t_8 < 0) {
 
1360
        __pyx_t_8 += __pyx_bshape_0_x;
 
1361
        if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
 
1362
      } else if (unlikely(__pyx_t_8 >= __pyx_bshape_0_x)) __pyx_t_9 = 0;
 
1363
      if (unlikely(__pyx_t_9 != -1)) {
 
1364
        __Pyx_RaiseBufferIndexError(__pyx_t_9);
 
1365
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1366
      }
 
1367
      __pyx_t_10 = __Pyx_c_prod_npy_float64(__pyx_t_npy_float64_complex_from_parts((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x.buf, __pyx_t_8, __pyx_bstride_0_x)), 0), __pyx_t_npy_float64_complex_from_parts(__Pyx_CREAL(__pyx_v_w), __Pyx_CIMAG(__pyx_v_w)));
 
1368
      __pyx_t_9 = __pyx_v_p;
 
1369
      __pyx_t_11 = -1;
 
1370
      if (__pyx_t_9 < 0) {
 
1371
        __pyx_t_9 += __pyx_bshape_0_X;
 
1372
        if (unlikely(__pyx_t_9 < 0)) __pyx_t_11 = 0;
 
1373
      } else if (unlikely(__pyx_t_9 >= __pyx_bshape_0_X)) __pyx_t_11 = 0;
 
1374
      if (unlikely(__pyx_t_11 != -1)) {
 
1375
        __Pyx_RaiseBufferIndexError(__pyx_t_11);
 
1376
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1377
      }
 
1378
      *__Pyx_BufPtrStrided1d(__pyx_t_double_complex *, __pyx_bstruct_X.buf, __pyx_t_9, __pyx_bstride_0_X) = __Pyx_c_sum((*__Pyx_BufPtrStrided1d(__pyx_t_double_complex *, __pyx_bstruct_X.buf, __pyx_t_7, __pyx_bstride_0_X)), __pyx_t_double_complex_from_parts(__Pyx_CREAL(__pyx_t_10), __Pyx_CIMAG(__pyx_t_10)));
 
1379
    }
 
1380
  }
 
1381
 
 
1382
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":37
 
1383
 *                 w = w * W[p]
 
1384
 *             X[p] = X[p] + x[n]*w
 
1385
 *     return X             # <<<<<<<<<<<<<<
 
1386
 * 
 
1387
 * def autocorr_inner(np.ndarray[np.float64_t, ndim=1] x, np.ndarray[np.float64_t, ndim=1] xc, int N):
 
1388
 */
 
1389
  __Pyx_XDECREF(__pyx_r);
 
1390
  __Pyx_INCREF(((PyObject *)__pyx_v_X));
 
1391
  __pyx_r = ((PyObject *)__pyx_v_X);
 
1392
  goto __pyx_L0;
 
1393
 
 
1394
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
1395
  goto __pyx_L0;
 
1396
  __pyx_L1_error:;
 
1397
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
 
1398
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
 
1399
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X);
 
1400
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_W);
 
1401
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x);
 
1402
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
 
1403
  __Pyx_AddTraceback("cogent.maths._period.ipdft_inner");
 
1404
  __pyx_r = NULL;
 
1405
  goto __pyx_L2;
 
1406
  __pyx_L0:;
 
1407
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X);
 
1408
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_W);
 
1409
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x);
 
1410
  __pyx_L2:;
 
1411
  __Pyx_DECREF((PyObject *)__pyx_v_x);
 
1412
  __Pyx_DECREF((PyObject *)__pyx_v_X);
 
1413
  __Pyx_DECREF((PyObject *)__pyx_v_W);
 
1414
  __Pyx_XGIVEREF(__pyx_r);
 
1415
  __Pyx_RefNannyFinishContext();
 
1416
  return __pyx_r;
 
1417
}
 
1418
 
 
1419
/* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":39
 
1420
 *     return X
 
1421
 * 
 
1422
 * def autocorr_inner(np.ndarray[np.float64_t, ndim=1] x, np.ndarray[np.float64_t, ndim=1] xc, int N):             # <<<<<<<<<<<<<<
 
1423
 *     cdef int m, n
 
1424
 * 
 
1425
 */
 
1426
 
 
1427
static PyObject *__pyx_pf_6cogent_5maths_7_period_autocorr_inner(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
1428
static PyObject *__pyx_pf_6cogent_5maths_7_period_autocorr_inner(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
1429
  PyArrayObject *__pyx_v_x = 0;
 
1430
  PyArrayObject *__pyx_v_xc = 0;
 
1431
  int __pyx_v_N;
 
1432
  int __pyx_v_m;
 
1433
  int __pyx_v_n;
 
1434
  Py_buffer __pyx_bstruct_x;
 
1435
  Py_ssize_t __pyx_bstride_0_x = 0;
 
1436
  Py_ssize_t __pyx_bshape_0_x = 0;
 
1437
  Py_buffer __pyx_bstruct_xc;
 
1438
  Py_ssize_t __pyx_bstride_0_xc = 0;
 
1439
  Py_ssize_t __pyx_bshape_0_xc = 0;
 
1440
  PyObject *__pyx_r = NULL;
 
1441
  int __pyx_t_1;
 
1442
  int __pyx_t_2;
 
1443
  int __pyx_t_3;
 
1444
  int __pyx_t_4;
 
1445
  int __pyx_t_5;
 
1446
  int __pyx_t_6;
 
1447
  int __pyx_t_7;
 
1448
  int __pyx_t_8;
 
1449
  long __pyx_t_9;
 
1450
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__xc,&__pyx_n_s__N,0};
 
1451
  __Pyx_RefNannySetupContext("autocorr_inner");
 
1452
  __pyx_self = __pyx_self;
 
1453
  if (unlikely(__pyx_kwds)) {
 
1454
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
1455
    PyObject* values[3] = {0,0,0};
 
1456
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
1457
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
 
1458
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
 
1459
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
1460
      case  0: break;
 
1461
      default: goto __pyx_L5_argtuple_error;
 
1462
    }
 
1463
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
1464
      case  0:
 
1465
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
 
1466
      if (likely(values[0])) kw_args--;
 
1467
      else goto __pyx_L5_argtuple_error;
 
1468
      case  1:
 
1469
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__xc);
 
1470
      if (likely(values[1])) kw_args--;
 
1471
      else {
 
1472
        __Pyx_RaiseArgtupleInvalid("autocorr_inner", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1473
      }
 
1474
      case  2:
 
1475
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__N);
 
1476
      if (likely(values[2])) kw_args--;
 
1477
      else {
 
1478
        __Pyx_RaiseArgtupleInvalid("autocorr_inner", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1479
      }
 
1480
    }
 
1481
    if (unlikely(kw_args > 0)) {
 
1482
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "autocorr_inner") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1483
    }
 
1484
    __pyx_v_x = ((PyArrayObject *)values[0]);
 
1485
    __pyx_v_xc = ((PyArrayObject *)values[1]);
 
1486
    __pyx_v_N = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1487
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
 
1488
    goto __pyx_L5_argtuple_error;
 
1489
  } else {
 
1490
    __pyx_v_x = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
 
1491
    __pyx_v_xc = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
 
1492
    __pyx_v_N = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1493
  }
 
1494
  goto __pyx_L4_argument_unpacking_done;
 
1495
  __pyx_L5_argtuple_error:;
 
1496
  __Pyx_RaiseArgtupleInvalid("autocorr_inner", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1497
  __pyx_L3_error:;
 
1498
  __Pyx_AddTraceback("cogent.maths._period.autocorr_inner");
 
1499
  return NULL;
 
1500
  __pyx_L4_argument_unpacking_done:;
 
1501
  __Pyx_INCREF((PyObject *)__pyx_v_x);
 
1502
  __Pyx_INCREF((PyObject *)__pyx_v_xc);
 
1503
  __pyx_bstruct_x.buf = NULL;
 
1504
  __pyx_bstruct_xc.buf = NULL;
 
1505
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1506
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_xc), __pyx_ptype_5numpy_ndarray, 1, "xc", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1507
  {
 
1508
    __Pyx_BufFmt_StackElem __pyx_stack[1];
 
1509
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1510
  }
 
1511
  __pyx_bstride_0_x = __pyx_bstruct_x.strides[0];
 
1512
  __pyx_bshape_0_x = __pyx_bstruct_x.shape[0];
 
1513
  {
 
1514
    __Pyx_BufFmt_StackElem __pyx_stack[1];
 
1515
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_xc, (PyObject*)__pyx_v_xc, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1516
  }
 
1517
  __pyx_bstride_0_xc = __pyx_bstruct_xc.strides[0];
 
1518
  __pyx_bshape_0_xc = __pyx_bstruct_xc.shape[0];
 
1519
 
 
1520
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":42
 
1521
 *     cdef int m, n
 
1522
 * 
 
1523
 *     for m in range(-N+1, N):             # <<<<<<<<<<<<<<
 
1524
 *         for n in range(N):
 
1525
 *             if 0 <= n-m < N:
 
1526
 */
 
1527
  __pyx_t_1 = __pyx_v_N;
 
1528
  for (__pyx_t_2 = ((-__pyx_v_N) + 1); __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
 
1529
    __pyx_v_m = __pyx_t_2;
 
1530
 
 
1531
    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":43
 
1532
 * 
 
1533
 *     for m in range(-N+1, N):
 
1534
 *         for n in range(N):             # <<<<<<<<<<<<<<
 
1535
 *             if 0 <= n-m < N:
 
1536
 *                 xc[m+N-1] += (x[n]*x[n-m])
 
1537
 */
 
1538
    __pyx_t_3 = __pyx_v_N;
 
1539
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
 
1540
      __pyx_v_n = __pyx_t_4;
 
1541
 
 
1542
      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":44
 
1543
 *     for m in range(-N+1, N):
 
1544
 *         for n in range(N):
 
1545
 *             if 0 <= n-m < N:             # <<<<<<<<<<<<<<
 
1546
 *                 xc[m+N-1] += (x[n]*x[n-m])
 
1547
 * 
 
1548
 */
 
1549
      __pyx_t_5 = (__pyx_v_n - __pyx_v_m);
 
1550
      __pyx_t_6 = (0 <= __pyx_t_5);
 
1551
      if (__pyx_t_6) {
 
1552
        __pyx_t_6 = (__pyx_t_5 < __pyx_v_N);
 
1553
      }
 
1554
      if (__pyx_t_6) {
 
1555
 
 
1556
        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":45
 
1557
 *         for n in range(N):
 
1558
 *             if 0 <= n-m < N:
 
1559
 *                 xc[m+N-1] += (x[n]*x[n-m])             # <<<<<<<<<<<<<<
 
1560
 * 
 
1561
 * def seq_to_symbols(char* seq, list motifs, int motif_length,
 
1562
 */
 
1563
        __pyx_t_5 = __pyx_v_n;
 
1564
        __pyx_t_7 = -1;
 
1565
        if (__pyx_t_5 < 0) {
 
1566
          __pyx_t_5 += __pyx_bshape_0_x;
 
1567
          if (unlikely(__pyx_t_5 < 0)) __pyx_t_7 = 0;
 
1568
        } else if (unlikely(__pyx_t_5 >= __pyx_bshape_0_x)) __pyx_t_7 = 0;
 
1569
        if (unlikely(__pyx_t_7 != -1)) {
 
1570
          __Pyx_RaiseBufferIndexError(__pyx_t_7);
 
1571
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1572
        }
 
1573
        __pyx_t_7 = (__pyx_v_n - __pyx_v_m);
 
1574
        __pyx_t_8 = -1;
 
1575
        if (__pyx_t_7 < 0) {
 
1576
          __pyx_t_7 += __pyx_bshape_0_x;
 
1577
          if (unlikely(__pyx_t_7 < 0)) __pyx_t_8 = 0;
 
1578
        } else if (unlikely(__pyx_t_7 >= __pyx_bshape_0_x)) __pyx_t_8 = 0;
 
1579
        if (unlikely(__pyx_t_8 != -1)) {
 
1580
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
 
1581
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1582
        }
 
1583
        __pyx_t_9 = ((__pyx_v_m + __pyx_v_N) - 1);
 
1584
        __pyx_t_8 = -1;
 
1585
        if (__pyx_t_9 < 0) {
 
1586
          __pyx_t_9 += __pyx_bshape_0_xc;
 
1587
          if (unlikely(__pyx_t_9 < 0)) __pyx_t_8 = 0;
 
1588
        } else if (unlikely(__pyx_t_9 >= __pyx_bshape_0_xc)) __pyx_t_8 = 0;
 
1589
        if (unlikely(__pyx_t_8 != -1)) {
 
1590
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
 
1591
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1592
        }
 
1593
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_xc.buf, __pyx_t_9, __pyx_bstride_0_xc) += ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x.buf, __pyx_t_5, __pyx_bstride_0_x)) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x.buf, __pyx_t_7, __pyx_bstride_0_x)));
 
1594
        goto __pyx_L10;
 
1595
      }
 
1596
      __pyx_L10:;
 
1597
    }
 
1598
  }
 
1599
 
 
1600
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
1601
  goto __pyx_L0;
 
1602
  __pyx_L1_error:;
 
1603
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
 
1604
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
 
1605
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x);
 
1606
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_xc);
 
1607
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
 
1608
  __Pyx_AddTraceback("cogent.maths._period.autocorr_inner");
 
1609
  __pyx_r = NULL;
 
1610
  goto __pyx_L2;
 
1611
  __pyx_L0:;
 
1612
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x);
 
1613
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_xc);
 
1614
  __pyx_L2:;
 
1615
  __Pyx_DECREF((PyObject *)__pyx_v_x);
 
1616
  __Pyx_DECREF((PyObject *)__pyx_v_xc);
 
1617
  __Pyx_XGIVEREF(__pyx_r);
 
1618
  __Pyx_RefNannyFinishContext();
 
1619
  return __pyx_r;
 
1620
}
 
1621
 
 
1622
/* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":47
 
1623
 *                 xc[m+N-1] += (x[n]*x[n-m])
 
1624
 * 
 
1625
 * def seq_to_symbols(char* seq, list motifs, int motif_length,             # <<<<<<<<<<<<<<
 
1626
 *     np.ndarray[np.uint8_t, ndim=1] result):
 
1627
 *     cdef int i, j, N, num_motifs
 
1628
 */
 
1629
 
 
1630
static PyObject *__pyx_pf_6cogent_5maths_7_period_seq_to_symbols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
1631
static PyObject *__pyx_pf_6cogent_5maths_7_period_seq_to_symbols(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
1632
  char *__pyx_v_seq;
 
1633
  PyObject *__pyx_v_motifs = 0;
 
1634
  int __pyx_v_motif_length;
 
1635
  PyArrayObject *__pyx_v_result = 0;
 
1636
  int __pyx_v_i;
 
1637
  int __pyx_v_j;
 
1638
  int __pyx_v_N;
 
1639
  int __pyx_v_num_motifs;
 
1640
  PyObject *__pyx_v_got;
 
1641
  Py_buffer __pyx_bstruct_result;
 
1642
  Py_ssize_t __pyx_bstride_0_result = 0;
 
1643
  Py_ssize_t __pyx_bshape_0_result = 0;
 
1644
  PyObject *__pyx_r = NULL;
 
1645
  size_t __pyx_t_1;
 
1646
  Py_ssize_t __pyx_t_2;
 
1647
  PyObject *__pyx_t_3 = NULL;
 
1648
  long __pyx_t_4;
 
1649
  int __pyx_t_5;
 
1650
  int __pyx_t_6;
 
1651
  int __pyx_t_7;
 
1652
  PyObject *__pyx_t_8 = NULL;
 
1653
  int __pyx_t_9;
 
1654
  int __pyx_t_10;
 
1655
  int __pyx_t_11;
 
1656
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__seq,&__pyx_n_s__motifs,&__pyx_n_s__motif_length,&__pyx_n_s__result,0};
 
1657
  __Pyx_RefNannySetupContext("seq_to_symbols");
 
1658
  __pyx_self = __pyx_self;
 
1659
  if (unlikely(__pyx_kwds)) {
 
1660
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
 
1661
    PyObject* values[4] = {0,0,0,0};
 
1662
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
1663
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
 
1664
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
 
1665
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
 
1666
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
 
1667
      case  0: break;
 
1668
      default: goto __pyx_L5_argtuple_error;
 
1669
    }
 
1670
    switch (PyTuple_GET_SIZE(__pyx_args)) {
 
1671
      case  0:
 
1672
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seq);
 
1673
      if (likely(values[0])) kw_args--;
 
1674
      else goto __pyx_L5_argtuple_error;
 
1675
      case  1:
 
1676
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__motifs);
 
1677
      if (likely(values[1])) kw_args--;
 
1678
      else {
 
1679
        __Pyx_RaiseArgtupleInvalid("seq_to_symbols", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1680
      }
 
1681
      case  2:
 
1682
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__motif_length);
 
1683
      if (likely(values[2])) kw_args--;
 
1684
      else {
 
1685
        __Pyx_RaiseArgtupleInvalid("seq_to_symbols", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1686
      }
 
1687
      case  3:
 
1688
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__result);
 
1689
      if (likely(values[3])) kw_args--;
 
1690
      else {
 
1691
        __Pyx_RaiseArgtupleInvalid("seq_to_symbols", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1692
      }
 
1693
    }
 
1694
    if (unlikely(kw_args > 0)) {
 
1695
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "seq_to_symbols") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1696
    }
 
1697
    __pyx_v_seq = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_seq) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1698
    __pyx_v_motifs = ((PyObject *)values[1]);
 
1699
    __pyx_v_motif_length = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_motif_length == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1700
    __pyx_v_result = ((PyArrayObject *)values[3]);
 
1701
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
 
1702
    goto __pyx_L5_argtuple_error;
 
1703
  } else {
 
1704
    __pyx_v_seq = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_seq) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1705
    __pyx_v_motifs = ((PyObject *)PyTuple_GET_ITEM(__pyx_args, 1));
 
1706
    __pyx_v_motif_length = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_motif_length == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1707
    __pyx_v_result = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
 
1708
  }
 
1709
  goto __pyx_L4_argument_unpacking_done;
 
1710
  __pyx_L5_argtuple_error:;
 
1711
  __Pyx_RaiseArgtupleInvalid("seq_to_symbols", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
1712
  __pyx_L3_error:;
 
1713
  __Pyx_AddTraceback("cogent.maths._period.seq_to_symbols");
 
1714
  return NULL;
 
1715
  __pyx_L4_argument_unpacking_done:;
 
1716
  __Pyx_INCREF(__pyx_v_motifs);
 
1717
  __Pyx_INCREF((PyObject *)__pyx_v_result);
 
1718
  __pyx_v_got = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
 
1719
  __pyx_bstruct_result.buf = NULL;
 
1720
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_motifs), &PyList_Type, 1, "motifs", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1721
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_result), __pyx_ptype_5numpy_ndarray, 1, "result", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1722
  {
 
1723
    __Pyx_BufFmt_StackElem __pyx_stack[1];
 
1724
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_result, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1725
  }
 
1726
  __pyx_bstride_0_result = __pyx_bstruct_result.strides[0];
 
1727
  __pyx_bshape_0_result = __pyx_bstruct_result.shape[0];
 
1728
 
 
1729
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":52
 
1730
 *     cdef bytes got
 
1731
 * 
 
1732
 *     N = len(seq)             # <<<<<<<<<<<<<<
 
1733
 *     num_motifs = len(motifs)
 
1734
 *     motif_length = len(motifs[0])
 
1735
 */
 
1736
  __pyx_t_1 = strlen(__pyx_v_seq); 
 
1737
  __pyx_v_N = __pyx_t_1;
 
1738
 
 
1739
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":53
 
1740
 * 
 
1741
 *     N = len(seq)
 
1742
 *     num_motifs = len(motifs)             # <<<<<<<<<<<<<<
 
1743
 *     motif_length = len(motifs[0])
 
1744
 *     for i in range(N - motif_length + 1):
 
1745
 */
 
1746
  __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_motifs)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1747
  __pyx_v_num_motifs = __pyx_t_2;
 
1748
 
 
1749
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":54
 
1750
 *     N = len(seq)
 
1751
 *     num_motifs = len(motifs)
 
1752
 *     motif_length = len(motifs[0])             # <<<<<<<<<<<<<<
 
1753
 *     for i in range(N - motif_length + 1):
 
1754
 *         got = seq[i: i+motif_length]
 
1755
 */
 
1756
  __pyx_t_3 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_motifs), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1757
  __Pyx_GOTREF(__pyx_t_3);
 
1758
  __pyx_t_2 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1759
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
1760
  __pyx_v_motif_length = __pyx_t_2;
 
1761
 
 
1762
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":55
 
1763
 *     num_motifs = len(motifs)
 
1764
 *     motif_length = len(motifs[0])
 
1765
 *     for i in range(N - motif_length + 1):             # <<<<<<<<<<<<<<
 
1766
 *         got = seq[i: i+motif_length]
 
1767
 *         for j in range(num_motifs):
 
1768
 */
 
1769
  __pyx_t_4 = ((__pyx_v_N - __pyx_v_motif_length) + 1);
 
1770
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
 
1771
    __pyx_v_i = __pyx_t_5;
 
1772
 
 
1773
    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":56
 
1774
 *     motif_length = len(motifs[0])
 
1775
 *     for i in range(N - motif_length + 1):
 
1776
 *         got = seq[i: i+motif_length]             # <<<<<<<<<<<<<<
 
1777
 *         for j in range(num_motifs):
 
1778
 *             if got == motifs[j]:
 
1779
 */
 
1780
    __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_seq + __pyx_v_i, (__pyx_v_i + __pyx_v_motif_length) - __pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1781
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
 
1782
    __Pyx_DECREF(((PyObject *)__pyx_v_got));
 
1783
    __pyx_v_got = __pyx_t_3;
 
1784
    __pyx_t_3 = 0;
 
1785
 
 
1786
    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":57
 
1787
 *     for i in range(N - motif_length + 1):
 
1788
 *         got = seq[i: i+motif_length]
 
1789
 *         for j in range(num_motifs):             # <<<<<<<<<<<<<<
 
1790
 *             if got == motifs[j]:
 
1791
 *                 result[i] = 1
 
1792
 */
 
1793
    __pyx_t_6 = __pyx_v_num_motifs;
 
1794
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
 
1795
      __pyx_v_j = __pyx_t_7;
 
1796
 
 
1797
      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":58
 
1798
 *         got = seq[i: i+motif_length]
 
1799
 *         for j in range(num_motifs):
 
1800
 *             if got == motifs[j]:             # <<<<<<<<<<<<<<
 
1801
 *                 result[i] = 1
 
1802
 *     return result
 
1803
 */
 
1804
      __pyx_t_3 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_motifs), __pyx_v_j, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1805
      __Pyx_GOTREF(__pyx_t_3);
 
1806
      __pyx_t_8 = PyObject_RichCompare(((PyObject *)__pyx_v_got), __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1807
      __Pyx_GOTREF(__pyx_t_8);
 
1808
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
1809
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1810
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
1811
      if (__pyx_t_9) {
 
1812
 
 
1813
        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":59
 
1814
 *         for j in range(num_motifs):
 
1815
 *             if got == motifs[j]:
 
1816
 *                 result[i] = 1             # <<<<<<<<<<<<<<
 
1817
 *     return result
 
1818
 * 
 
1819
 */
 
1820
        __pyx_t_10 = __pyx_v_i;
 
1821
        __pyx_t_11 = -1;
 
1822
        if (__pyx_t_10 < 0) {
 
1823
          __pyx_t_10 += __pyx_bshape_0_result;
 
1824
          if (unlikely(__pyx_t_10 < 0)) __pyx_t_11 = 0;
 
1825
        } else if (unlikely(__pyx_t_10 >= __pyx_bshape_0_result)) __pyx_t_11 = 0;
 
1826
        if (unlikely(__pyx_t_11 != -1)) {
 
1827
          __Pyx_RaiseBufferIndexError(__pyx_t_11);
 
1828
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1829
        }
 
1830
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_uint8_t *, __pyx_bstruct_result.buf, __pyx_t_10, __pyx_bstride_0_result) = 1;
 
1831
        goto __pyx_L10;
 
1832
      }
 
1833
      __pyx_L10:;
 
1834
    }
 
1835
  }
 
1836
 
 
1837
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":60
 
1838
 *             if got == motifs[j]:
 
1839
 *                 result[i] = 1
 
1840
 *     return result             # <<<<<<<<<<<<<<
 
1841
 * 
 
1842
 */
 
1843
  __Pyx_XDECREF(__pyx_r);
 
1844
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
 
1845
  __pyx_r = ((PyObject *)__pyx_v_result);
 
1846
  goto __pyx_L0;
 
1847
 
 
1848
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
1849
  goto __pyx_L0;
 
1850
  __pyx_L1_error:;
 
1851
  __Pyx_XDECREF(__pyx_t_3);
 
1852
  __Pyx_XDECREF(__pyx_t_8);
 
1853
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
 
1854
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
 
1855
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_result);
 
1856
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
 
1857
  __Pyx_AddTraceback("cogent.maths._period.seq_to_symbols");
 
1858
  __pyx_r = NULL;
 
1859
  goto __pyx_L2;
 
1860
  __pyx_L0:;
 
1861
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_result);
 
1862
  __pyx_L2:;
 
1863
  __Pyx_DECREF(__pyx_v_got);
 
1864
  __Pyx_DECREF(__pyx_v_motifs);
 
1865
  __Pyx_DECREF((PyObject *)__pyx_v_result);
 
1866
  __Pyx_XGIVEREF(__pyx_r);
 
1867
  __Pyx_RefNannyFinishContext();
 
1868
  return __pyx_r;
 
1869
}
 
1870
 
 
1871
/* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":187
 
1872
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 
1873
 *         # -- the details of this may change.
 
1874
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 
1875
 *             # This implementation of getbuffer is geared towards Cython
 
1876
 *             # requirements, and does not yet fullfill the PEP.
 
1877
 */
 
1878
 
 
1879
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
 
1880
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
 
1881
  int __pyx_v_copy_shape;
 
1882
  int __pyx_v_i;
 
1883
  int __pyx_v_ndim;
 
1884
  int __pyx_v_endian_detector;
 
1885
  int __pyx_v_little_endian;
 
1886
  int __pyx_v_t;
 
1887
  char *__pyx_v_f;
 
1888
  PyArray_Descr *__pyx_v_descr = 0;
 
1889
  int __pyx_v_offset;
 
1890
  int __pyx_v_hasfields;
 
1891
  int __pyx_r;
 
1892
  int __pyx_t_1;
 
1893
  int __pyx_t_2;
 
1894
  int __pyx_t_3;
 
1895
  PyObject *__pyx_t_4 = NULL;
 
1896
  PyObject *__pyx_t_5 = NULL;
 
1897
  int __pyx_t_6;
 
1898
  int __pyx_t_7;
 
1899
  int __pyx_t_8;
 
1900
  char *__pyx_t_9;
 
1901
  __Pyx_RefNannySetupContext("__getbuffer__");
 
1902
  if (__pyx_v_info == NULL) return 0;
 
1903
  __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
 
1904
  __Pyx_GIVEREF(__pyx_v_info->obj);
 
1905
  __Pyx_INCREF((PyObject *)__pyx_v_self);
 
1906
 
 
1907
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":193
 
1908
 *             # of flags
 
1909
 *             cdef int copy_shape, i, ndim
 
1910
 *             cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 
1911
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 
1912
 * 
 
1913
 */
 
1914
  __pyx_v_endian_detector = 1;
 
1915
 
 
1916
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":194
 
1917
 *             cdef int copy_shape, i, ndim
 
1918
 *             cdef int endian_detector = 1
 
1919
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 
1920
 * 
 
1921
 *             ndim = PyArray_NDIM(self)
 
1922
 */
 
1923
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
 
1924
 
 
1925
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":196
 
1926
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 
1927
 * 
 
1928
 *             ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
 
1929
 * 
 
1930
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 
1931
 */
 
1932
  __pyx_v_ndim = PyArray_NDIM(((PyArrayObject *)__pyx_v_self));
 
1933
 
 
1934
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":198
 
1935
 *             ndim = PyArray_NDIM(self)
 
1936
 * 
 
1937
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 
1938
 *                 copy_shape = 1
 
1939
 *             else:
 
1940
 */
 
1941
  __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
 
1942
  if (__pyx_t_1) {
 
1943
 
 
1944
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":199
 
1945
 * 
 
1946
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 
1947
 *                 copy_shape = 1             # <<<<<<<<<<<<<<
 
1948
 *             else:
 
1949
 *                 copy_shape = 0
 
1950
 */
 
1951
    __pyx_v_copy_shape = 1;
 
1952
    goto __pyx_L5;
 
1953
  }
 
1954
  /*else*/ {
 
1955
 
 
1956
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":201
 
1957
 *                 copy_shape = 1
 
1958
 *             else:
 
1959
 *                 copy_shape = 0             # <<<<<<<<<<<<<<
 
1960
 * 
 
1961
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 
1962
 */
 
1963
    __pyx_v_copy_shape = 0;
 
1964
  }
 
1965
  __pyx_L5:;
 
1966
 
 
1967
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":203
 
1968
 *                 copy_shape = 0
 
1969
 * 
 
1970
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 
1971
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 
1972
 *                 raise ValueError(u"ndarray is not C contiguous")
 
1973
 */
 
1974
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS);
 
1975
  if (__pyx_t_1) {
 
1976
 
 
1977
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":204
 
1978
 * 
 
1979
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 
1980
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 
1981
 *                 raise ValueError(u"ndarray is not C contiguous")
 
1982
 * 
 
1983
 */
 
1984
    __pyx_t_2 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_C_CONTIGUOUS));
 
1985
    __pyx_t_3 = __pyx_t_2;
 
1986
  } else {
 
1987
    __pyx_t_3 = __pyx_t_1;
 
1988
  }
 
1989
  if (__pyx_t_3) {
 
1990
 
 
1991
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":205
 
1992
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 
1993
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 
1994
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 
1995
 * 
 
1996
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 
1997
 */
 
1998
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1999
    __Pyx_GOTREF(__pyx_t_4);
 
2000
    __Pyx_INCREF(((PyObject *)__pyx_kp_u_1));
 
2001
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_u_1));
 
2002
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_1));
 
2003
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2004
    __Pyx_GOTREF(__pyx_t_5);
 
2005
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
2006
    __Pyx_Raise(__pyx_t_5, 0, 0);
 
2007
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
2008
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2009
    goto __pyx_L6;
 
2010
  }
 
2011
  __pyx_L6:;
 
2012
 
 
2013
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":207
 
2014
 *                 raise ValueError(u"ndarray is not C contiguous")
 
2015
 * 
 
2016
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 
2017
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 
2018
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 
2019
 */
 
2020
  __pyx_t_3 = ((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS);
 
2021
  if (__pyx_t_3) {
 
2022
 
 
2023
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":208
 
2024
 * 
 
2025
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 
2026
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 
2027
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 
2028
 * 
 
2029
 */
 
2030
    __pyx_t_1 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_F_CONTIGUOUS));
 
2031
    __pyx_t_2 = __pyx_t_1;
 
2032
  } else {
 
2033
    __pyx_t_2 = __pyx_t_3;
 
2034
  }
 
2035
  if (__pyx_t_2) {
 
2036
 
 
2037
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":209
 
2038
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 
2039
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 
2040
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 
2041
 * 
 
2042
 *             info.buf = PyArray_DATA(self)
 
2043
 */
 
2044
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2045
    __Pyx_GOTREF(__pyx_t_5);
 
2046
    __Pyx_INCREF(((PyObject *)__pyx_kp_u_2));
 
2047
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_u_2));
 
2048
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_2));
 
2049
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2050
    __Pyx_GOTREF(__pyx_t_4);
 
2051
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
2052
    __Pyx_Raise(__pyx_t_4, 0, 0);
 
2053
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
2054
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2055
    goto __pyx_L7;
 
2056
  }
 
2057
  __pyx_L7:;
 
2058
 
 
2059
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":211
 
2060
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 
2061
 * 
 
2062
 *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
 
2063
 *             info.ndim = ndim
 
2064
 *             if copy_shape:
 
2065
 */
 
2066
  __pyx_v_info->buf = PyArray_DATA(((PyArrayObject *)__pyx_v_self));
 
2067
 
 
2068
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":212
 
2069
 * 
 
2070
 *             info.buf = PyArray_DATA(self)
 
2071
 *             info.ndim = ndim             # <<<<<<<<<<<<<<
 
2072
 *             if copy_shape:
 
2073
 *                 # Allocate new buffer for strides and shape info. This is allocated
 
2074
 */
 
2075
  __pyx_v_info->ndim = __pyx_v_ndim;
 
2076
 
 
2077
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":213
 
2078
 *             info.buf = PyArray_DATA(self)
 
2079
 *             info.ndim = ndim
 
2080
 *             if copy_shape:             # <<<<<<<<<<<<<<
 
2081
 *                 # Allocate new buffer for strides and shape info. This is allocated
 
2082
 *                 # as one block, strides first.
 
2083
 */
 
2084
  __pyx_t_6 = __pyx_v_copy_shape;
 
2085
  if (__pyx_t_6) {
 
2086
 
 
2087
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":216
 
2088
 *                 # Allocate new buffer for strides and shape info. This is allocated
 
2089
 *                 # as one block, strides first.
 
2090
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)             # <<<<<<<<<<<<<<
 
2091
 *                 info.shape = info.strides + ndim
 
2092
 *                 for i in range(ndim):
 
2093
 */
 
2094
    __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * __pyx_v_ndim) * 2)));
 
2095
 
 
2096
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":217
 
2097
 *                 # as one block, strides first.
 
2098
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)
 
2099
 *                 info.shape = info.strides + ndim             # <<<<<<<<<<<<<<
 
2100
 *                 for i in range(ndim):
 
2101
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 
2102
 */
 
2103
    __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);
 
2104
 
 
2105
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":218
 
2106
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)
 
2107
 *                 info.shape = info.strides + ndim
 
2108
 *                 for i in range(ndim):             # <<<<<<<<<<<<<<
 
2109
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 
2110
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 
2111
 */
 
2112
    __pyx_t_6 = __pyx_v_ndim;
 
2113
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
 
2114
      __pyx_v_i = __pyx_t_7;
 
2115
 
 
2116
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":219
 
2117
 *                 info.shape = info.strides + ndim
 
2118
 *                 for i in range(ndim):
 
2119
 *                     info.strides[i] = PyArray_STRIDES(self)[i]             # <<<<<<<<<<<<<<
 
2120
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 
2121
 *             else:
 
2122
 */
 
2123
      (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]);
 
2124
 
 
2125
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":220
 
2126
 *                 for i in range(ndim):
 
2127
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 
2128
 *                     info.shape[i] = PyArray_DIMS(self)[i]             # <<<<<<<<<<<<<<
 
2129
 *             else:
 
2130
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 
2131
 */
 
2132
      (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]);
 
2133
    }
 
2134
    goto __pyx_L8;
 
2135
  }
 
2136
  /*else*/ {
 
2137
 
 
2138
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":222
 
2139
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 
2140
 *             else:
 
2141
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
 
2142
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 
2143
 *             info.suboffsets = NULL
 
2144
 */
 
2145
    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_v_self)));
 
2146
 
 
2147
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":223
 
2148
 *             else:
 
2149
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 
2150
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)             # <<<<<<<<<<<<<<
 
2151
 *             info.suboffsets = NULL
 
2152
 *             info.itemsize = PyArray_ITEMSIZE(self)
 
2153
 */
 
2154
    __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(((PyArrayObject *)__pyx_v_self)));
 
2155
  }
 
2156
  __pyx_L8:;
 
2157
 
 
2158
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":224
 
2159
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 
2160
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 
2161
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 
2162
 *             info.itemsize = PyArray_ITEMSIZE(self)
 
2163
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 
2164
 */
 
2165
  __pyx_v_info->suboffsets = NULL;
 
2166
 
 
2167
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":225
 
2168
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 
2169
 *             info.suboffsets = NULL
 
2170
 *             info.itemsize = PyArray_ITEMSIZE(self)             # <<<<<<<<<<<<<<
 
2171
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 
2172
 * 
 
2173
 */
 
2174
  __pyx_v_info->itemsize = PyArray_ITEMSIZE(((PyArrayObject *)__pyx_v_self));
 
2175
 
 
2176
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":226
 
2177
 *             info.suboffsets = NULL
 
2178
 *             info.itemsize = PyArray_ITEMSIZE(self)
 
2179
 *             info.readonly = not PyArray_ISWRITEABLE(self)             # <<<<<<<<<<<<<<
 
2180
 * 
 
2181
 *             cdef int t
 
2182
 */
 
2183
  __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(((PyArrayObject *)__pyx_v_self)));
 
2184
 
 
2185
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":229
 
2186
 * 
 
2187
 *             cdef int t
 
2188
 *             cdef char* f = NULL             # <<<<<<<<<<<<<<
 
2189
 *             cdef dtype descr = self.descr
 
2190
 *             cdef list stack
 
2191
 */
 
2192
  __pyx_v_f = NULL;
 
2193
 
 
2194
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":230
 
2195
 *             cdef int t
 
2196
 *             cdef char* f = NULL
 
2197
 *             cdef dtype descr = self.descr             # <<<<<<<<<<<<<<
 
2198
 *             cdef list stack
 
2199
 *             cdef int offset
 
2200
 */
 
2201
  __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self)->descr));
 
2202
  __pyx_v_descr = ((PyArrayObject *)__pyx_v_self)->descr;
 
2203
 
 
2204
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":234
 
2205
 *             cdef int offset
 
2206
 * 
 
2207
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)             # <<<<<<<<<<<<<<
 
2208
 * 
 
2209
 *             if not hasfields and not copy_shape:
 
2210
 */
 
2211
  __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);
 
2212
 
 
2213
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":236
 
2214
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)
 
2215
 * 
 
2216
 *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
 
2217
 *                 # do not call releasebuffer
 
2218
 *                 info.obj = None
 
2219
 */
 
2220
  __pyx_t_2 = (!__pyx_v_hasfields);
 
2221
  if (__pyx_t_2) {
 
2222
    __pyx_t_3 = (!__pyx_v_copy_shape);
 
2223
    __pyx_t_1 = __pyx_t_3;
 
2224
  } else {
 
2225
    __pyx_t_1 = __pyx_t_2;
 
2226
  }
 
2227
  if (__pyx_t_1) {
 
2228
 
 
2229
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":238
 
2230
 *             if not hasfields and not copy_shape:
 
2231
 *                 # do not call releasebuffer
 
2232
 *                 info.obj = None             # <<<<<<<<<<<<<<
 
2233
 *             else:
 
2234
 *                 # need to call releasebuffer
 
2235
 */
 
2236
    __Pyx_INCREF(Py_None);
 
2237
    __Pyx_GIVEREF(Py_None);
 
2238
    __Pyx_GOTREF(__pyx_v_info->obj);
 
2239
    __Pyx_DECREF(__pyx_v_info->obj);
 
2240
    __pyx_v_info->obj = Py_None;
 
2241
    goto __pyx_L11;
 
2242
  }
 
2243
  /*else*/ {
 
2244
 
 
2245
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":241
 
2246
 *             else:
 
2247
 *                 # need to call releasebuffer
 
2248
 *                 info.obj = self             # <<<<<<<<<<<<<<
 
2249
 * 
 
2250
 *             if not hasfields:
 
2251
 */
 
2252
    __Pyx_INCREF(__pyx_v_self);
 
2253
    __Pyx_GIVEREF(__pyx_v_self);
 
2254
    __Pyx_GOTREF(__pyx_v_info->obj);
 
2255
    __Pyx_DECREF(__pyx_v_info->obj);
 
2256
    __pyx_v_info->obj = __pyx_v_self;
 
2257
  }
 
2258
  __pyx_L11:;
 
2259
 
 
2260
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":243
 
2261
 *                 info.obj = self
 
2262
 * 
 
2263
 *             if not hasfields:             # <<<<<<<<<<<<<<
 
2264
 *                 t = descr.type_num
 
2265
 *                 if ((descr.byteorder == '>' and little_endian) or
 
2266
 */
 
2267
  __pyx_t_1 = (!__pyx_v_hasfields);
 
2268
  if (__pyx_t_1) {
 
2269
 
 
2270
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":244
 
2271
 * 
 
2272
 *             if not hasfields:
 
2273
 *                 t = descr.type_num             # <<<<<<<<<<<<<<
 
2274
 *                 if ((descr.byteorder == '>' and little_endian) or
 
2275
 *                     (descr.byteorder == '<' and not little_endian)):
 
2276
 */
 
2277
    __pyx_v_t = __pyx_v_descr->type_num;
 
2278
 
 
2279
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":245
 
2280
 *             if not hasfields:
 
2281
 *                 t = descr.type_num
 
2282
 *                 if ((descr.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
 
2283
 *                     (descr.byteorder == '<' and not little_endian)):
 
2284
 *                     raise ValueError(u"Non-native byte order not supported")
 
2285
 */
 
2286
    __pyx_t_1 = (__pyx_v_descr->byteorder == '>');
 
2287
    if (__pyx_t_1) {
 
2288
      __pyx_t_2 = __pyx_v_little_endian;
 
2289
    } else {
 
2290
      __pyx_t_2 = __pyx_t_1;
 
2291
    }
 
2292
    if (!__pyx_t_2) {
 
2293
 
 
2294
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":246
 
2295
 *                 t = descr.type_num
 
2296
 *                 if ((descr.byteorder == '>' and little_endian) or
 
2297
 *                     (descr.byteorder == '<' and not little_endian)):             # <<<<<<<<<<<<<<
 
2298
 *                     raise ValueError(u"Non-native byte order not supported")
 
2299
 *                 if   t == NPY_BYTE:        f = "b"
 
2300
 */
 
2301
      __pyx_t_1 = (__pyx_v_descr->byteorder == '<');
 
2302
      if (__pyx_t_1) {
 
2303
        __pyx_t_3 = (!__pyx_v_little_endian);
 
2304
        __pyx_t_8 = __pyx_t_3;
 
2305
      } else {
 
2306
        __pyx_t_8 = __pyx_t_1;
 
2307
      }
 
2308
      __pyx_t_1 = __pyx_t_8;
 
2309
    } else {
 
2310
      __pyx_t_1 = __pyx_t_2;
 
2311
    }
 
2312
    if (__pyx_t_1) {
 
2313
 
 
2314
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":247
 
2315
 *                 if ((descr.byteorder == '>' and little_endian) or
 
2316
 *                     (descr.byteorder == '<' and not little_endian)):
 
2317
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 
2318
 *                 if   t == NPY_BYTE:        f = "b"
 
2319
 *                 elif t == NPY_UBYTE:       f = "B"
 
2320
 */
 
2321
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2322
      __Pyx_GOTREF(__pyx_t_4);
 
2323
      __Pyx_INCREF(((PyObject *)__pyx_kp_u_3));
 
2324
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_u_3));
 
2325
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_3));
 
2326
      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2327
      __Pyx_GOTREF(__pyx_t_5);
 
2328
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
2329
      __Pyx_Raise(__pyx_t_5, 0, 0);
 
2330
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
2331
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2332
      goto __pyx_L13;
 
2333
    }
 
2334
    __pyx_L13:;
 
2335
 
 
2336
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":248
 
2337
 *                     (descr.byteorder == '<' and not little_endian)):
 
2338
 *                     raise ValueError(u"Non-native byte order not supported")
 
2339
 *                 if   t == NPY_BYTE:        f = "b"             # <<<<<<<<<<<<<<
 
2340
 *                 elif t == NPY_UBYTE:       f = "B"
 
2341
 *                 elif t == NPY_SHORT:       f = "h"
 
2342
 */
 
2343
    __pyx_t_1 = (__pyx_v_t == NPY_BYTE);
 
2344
    if (__pyx_t_1) {
 
2345
      __pyx_v_f = __pyx_k__b;
 
2346
      goto __pyx_L14;
 
2347
    }
 
2348
 
 
2349
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":249
 
2350
 *                     raise ValueError(u"Non-native byte order not supported")
 
2351
 *                 if   t == NPY_BYTE:        f = "b"
 
2352
 *                 elif t == NPY_UBYTE:       f = "B"             # <<<<<<<<<<<<<<
 
2353
 *                 elif t == NPY_SHORT:       f = "h"
 
2354
 *                 elif t == NPY_USHORT:      f = "H"
 
2355
 */
 
2356
    __pyx_t_1 = (__pyx_v_t == NPY_UBYTE);
 
2357
    if (__pyx_t_1) {
 
2358
      __pyx_v_f = __pyx_k__B;
 
2359
      goto __pyx_L14;
 
2360
    }
 
2361
 
 
2362
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":250
 
2363
 *                 if   t == NPY_BYTE:        f = "b"
 
2364
 *                 elif t == NPY_UBYTE:       f = "B"
 
2365
 *                 elif t == NPY_SHORT:       f = "h"             # <<<<<<<<<<<<<<
 
2366
 *                 elif t == NPY_USHORT:      f = "H"
 
2367
 *                 elif t == NPY_INT:         f = "i"
 
2368
 */
 
2369
    __pyx_t_1 = (__pyx_v_t == NPY_SHORT);
 
2370
    if (__pyx_t_1) {
 
2371
      __pyx_v_f = __pyx_k__h;
 
2372
      goto __pyx_L14;
 
2373
    }
 
2374
 
 
2375
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":251
 
2376
 *                 elif t == NPY_UBYTE:       f = "B"
 
2377
 *                 elif t == NPY_SHORT:       f = "h"
 
2378
 *                 elif t == NPY_USHORT:      f = "H"             # <<<<<<<<<<<<<<
 
2379
 *                 elif t == NPY_INT:         f = "i"
 
2380
 *                 elif t == NPY_UINT:        f = "I"
 
2381
 */
 
2382
    __pyx_t_1 = (__pyx_v_t == NPY_USHORT);
 
2383
    if (__pyx_t_1) {
 
2384
      __pyx_v_f = __pyx_k__H;
 
2385
      goto __pyx_L14;
 
2386
    }
 
2387
 
 
2388
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":252
 
2389
 *                 elif t == NPY_SHORT:       f = "h"
 
2390
 *                 elif t == NPY_USHORT:      f = "H"
 
2391
 *                 elif t == NPY_INT:         f = "i"             # <<<<<<<<<<<<<<
 
2392
 *                 elif t == NPY_UINT:        f = "I"
 
2393
 *                 elif t == NPY_LONG:        f = "l"
 
2394
 */
 
2395
    __pyx_t_1 = (__pyx_v_t == NPY_INT);
 
2396
    if (__pyx_t_1) {
 
2397
      __pyx_v_f = __pyx_k__i;
 
2398
      goto __pyx_L14;
 
2399
    }
 
2400
 
 
2401
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":253
 
2402
 *                 elif t == NPY_USHORT:      f = "H"
 
2403
 *                 elif t == NPY_INT:         f = "i"
 
2404
 *                 elif t == NPY_UINT:        f = "I"             # <<<<<<<<<<<<<<
 
2405
 *                 elif t == NPY_LONG:        f = "l"
 
2406
 *                 elif t == NPY_ULONG:       f = "L"
 
2407
 */
 
2408
    __pyx_t_1 = (__pyx_v_t == NPY_UINT);
 
2409
    if (__pyx_t_1) {
 
2410
      __pyx_v_f = __pyx_k__I;
 
2411
      goto __pyx_L14;
 
2412
    }
 
2413
 
 
2414
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":254
 
2415
 *                 elif t == NPY_INT:         f = "i"
 
2416
 *                 elif t == NPY_UINT:        f = "I"
 
2417
 *                 elif t == NPY_LONG:        f = "l"             # <<<<<<<<<<<<<<
 
2418
 *                 elif t == NPY_ULONG:       f = "L"
 
2419
 *                 elif t == NPY_LONGLONG:    f = "q"
 
2420
 */
 
2421
    __pyx_t_1 = (__pyx_v_t == NPY_LONG);
 
2422
    if (__pyx_t_1) {
 
2423
      __pyx_v_f = __pyx_k__l;
 
2424
      goto __pyx_L14;
 
2425
    }
 
2426
 
 
2427
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":255
 
2428
 *                 elif t == NPY_UINT:        f = "I"
 
2429
 *                 elif t == NPY_LONG:        f = "l"
 
2430
 *                 elif t == NPY_ULONG:       f = "L"             # <<<<<<<<<<<<<<
 
2431
 *                 elif t == NPY_LONGLONG:    f = "q"
 
2432
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 
2433
 */
 
2434
    __pyx_t_1 = (__pyx_v_t == NPY_ULONG);
 
2435
    if (__pyx_t_1) {
 
2436
      __pyx_v_f = __pyx_k__L;
 
2437
      goto __pyx_L14;
 
2438
    }
 
2439
 
 
2440
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":256
 
2441
 *                 elif t == NPY_LONG:        f = "l"
 
2442
 *                 elif t == NPY_ULONG:       f = "L"
 
2443
 *                 elif t == NPY_LONGLONG:    f = "q"             # <<<<<<<<<<<<<<
 
2444
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 
2445
 *                 elif t == NPY_FLOAT:       f = "f"
 
2446
 */
 
2447
    __pyx_t_1 = (__pyx_v_t == NPY_LONGLONG);
 
2448
    if (__pyx_t_1) {
 
2449
      __pyx_v_f = __pyx_k__q;
 
2450
      goto __pyx_L14;
 
2451
    }
 
2452
 
 
2453
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":257
 
2454
 *                 elif t == NPY_ULONG:       f = "L"
 
2455
 *                 elif t == NPY_LONGLONG:    f = "q"
 
2456
 *                 elif t == NPY_ULONGLONG:   f = "Q"             # <<<<<<<<<<<<<<
 
2457
 *                 elif t == NPY_FLOAT:       f = "f"
 
2458
 *                 elif t == NPY_DOUBLE:      f = "d"
 
2459
 */
 
2460
    __pyx_t_1 = (__pyx_v_t == NPY_ULONGLONG);
 
2461
    if (__pyx_t_1) {
 
2462
      __pyx_v_f = __pyx_k__Q;
 
2463
      goto __pyx_L14;
 
2464
    }
 
2465
 
 
2466
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":258
 
2467
 *                 elif t == NPY_LONGLONG:    f = "q"
 
2468
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 
2469
 *                 elif t == NPY_FLOAT:       f = "f"             # <<<<<<<<<<<<<<
 
2470
 *                 elif t == NPY_DOUBLE:      f = "d"
 
2471
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 
2472
 */
 
2473
    __pyx_t_1 = (__pyx_v_t == NPY_FLOAT);
 
2474
    if (__pyx_t_1) {
 
2475
      __pyx_v_f = __pyx_k__f;
 
2476
      goto __pyx_L14;
 
2477
    }
 
2478
 
 
2479
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":259
 
2480
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 
2481
 *                 elif t == NPY_FLOAT:       f = "f"
 
2482
 *                 elif t == NPY_DOUBLE:      f = "d"             # <<<<<<<<<<<<<<
 
2483
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 
2484
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 
2485
 */
 
2486
    __pyx_t_1 = (__pyx_v_t == NPY_DOUBLE);
 
2487
    if (__pyx_t_1) {
 
2488
      __pyx_v_f = __pyx_k__d;
 
2489
      goto __pyx_L14;
 
2490
    }
 
2491
 
 
2492
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":260
 
2493
 *                 elif t == NPY_FLOAT:       f = "f"
 
2494
 *                 elif t == NPY_DOUBLE:      f = "d"
 
2495
 *                 elif t == NPY_LONGDOUBLE:  f = "g"             # <<<<<<<<<<<<<<
 
2496
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 
2497
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 
2498
 */
 
2499
    __pyx_t_1 = (__pyx_v_t == NPY_LONGDOUBLE);
 
2500
    if (__pyx_t_1) {
 
2501
      __pyx_v_f = __pyx_k__g;
 
2502
      goto __pyx_L14;
 
2503
    }
 
2504
 
 
2505
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":261
 
2506
 *                 elif t == NPY_DOUBLE:      f = "d"
 
2507
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 
2508
 *                 elif t == NPY_CFLOAT:      f = "Zf"             # <<<<<<<<<<<<<<
 
2509
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 
2510
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 
2511
 */
 
2512
    __pyx_t_1 = (__pyx_v_t == NPY_CFLOAT);
 
2513
    if (__pyx_t_1) {
 
2514
      __pyx_v_f = __pyx_k__Zf;
 
2515
      goto __pyx_L14;
 
2516
    }
 
2517
 
 
2518
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":262
 
2519
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 
2520
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 
2521
 *                 elif t == NPY_CDOUBLE:     f = "Zd"             # <<<<<<<<<<<<<<
 
2522
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 
2523
 *                 elif t == NPY_OBJECT:      f = "O"
 
2524
 */
 
2525
    __pyx_t_1 = (__pyx_v_t == NPY_CDOUBLE);
 
2526
    if (__pyx_t_1) {
 
2527
      __pyx_v_f = __pyx_k__Zd;
 
2528
      goto __pyx_L14;
 
2529
    }
 
2530
 
 
2531
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":263
 
2532
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 
2533
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 
2534
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"             # <<<<<<<<<<<<<<
 
2535
 *                 elif t == NPY_OBJECT:      f = "O"
 
2536
 *                 else:
 
2537
 */
 
2538
    __pyx_t_1 = (__pyx_v_t == NPY_CLONGDOUBLE);
 
2539
    if (__pyx_t_1) {
 
2540
      __pyx_v_f = __pyx_k__Zg;
 
2541
      goto __pyx_L14;
 
2542
    }
 
2543
 
 
2544
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":264
 
2545
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 
2546
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 
2547
 *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
 
2548
 *                 else:
 
2549
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 
2550
 */
 
2551
    __pyx_t_1 = (__pyx_v_t == NPY_OBJECT);
 
2552
    if (__pyx_t_1) {
 
2553
      __pyx_v_f = __pyx_k__O;
 
2554
      goto __pyx_L14;
 
2555
    }
 
2556
    /*else*/ {
 
2557
 
 
2558
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":266
 
2559
 *                 elif t == NPY_OBJECT:      f = "O"
 
2560
 *                 else:
 
2561
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 
2562
 *                 info.format = f
 
2563
 *                 return
 
2564
 */
 
2565
      __pyx_t_5 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2566
      __Pyx_GOTREF(__pyx_t_5);
 
2567
      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_4), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2568
      __Pyx_GOTREF(__pyx_t_4);
 
2569
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
2570
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2571
      __Pyx_GOTREF(__pyx_t_5);
 
2572
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
 
2573
      __Pyx_GIVEREF(__pyx_t_4);
 
2574
      __pyx_t_4 = 0;
 
2575
      __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2576
      __Pyx_GOTREF(__pyx_t_4);
 
2577
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
2578
      __Pyx_Raise(__pyx_t_4, 0, 0);
 
2579
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
2580
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2581
    }
 
2582
    __pyx_L14:;
 
2583
 
 
2584
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":267
 
2585
 *                 else:
 
2586
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 
2587
 *                 info.format = f             # <<<<<<<<<<<<<<
 
2588
 *                 return
 
2589
 *             else:
 
2590
 */
 
2591
    __pyx_v_info->format = __pyx_v_f;
 
2592
 
 
2593
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":268
 
2594
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 
2595
 *                 info.format = f
 
2596
 *                 return             # <<<<<<<<<<<<<<
 
2597
 *             else:
 
2598
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 
2599
 */
 
2600
    __pyx_r = 0;
 
2601
    goto __pyx_L0;
 
2602
    goto __pyx_L12;
 
2603
  }
 
2604
  /*else*/ {
 
2605
 
 
2606
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":270
 
2607
 *                 return
 
2608
 *             else:
 
2609
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)             # <<<<<<<<<<<<<<
 
2610
 *                 info.format[0] = '^' # Native data types, manual alignment
 
2611
 *                 offset = 0
 
2612
 */
 
2613
    __pyx_v_info->format = ((char *)malloc(255));
 
2614
 
 
2615
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":271
 
2616
 *             else:
 
2617
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 
2618
 *                 info.format[0] = '^' # Native data types, manual alignment             # <<<<<<<<<<<<<<
 
2619
 *                 offset = 0
 
2620
 *                 f = _util_dtypestring(descr, info.format + 1,
 
2621
 */
 
2622
    (__pyx_v_info->format[0]) = '^';
 
2623
 
 
2624
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":272
 
2625
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 
2626
 *                 info.format[0] = '^' # Native data types, manual alignment
 
2627
 *                 offset = 0             # <<<<<<<<<<<<<<
 
2628
 *                 f = _util_dtypestring(descr, info.format + 1,
 
2629
 *                                       info.format + _buffer_format_string_len,
 
2630
 */
 
2631
    __pyx_v_offset = 0;
 
2632
 
 
2633
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":275
 
2634
 *                 f = _util_dtypestring(descr, info.format + 1,
 
2635
 *                                       info.format + _buffer_format_string_len,
 
2636
 *                                       &offset)             # <<<<<<<<<<<<<<
 
2637
 *                 f[0] = 0 # Terminate format string
 
2638
 * 
 
2639
 */
 
2640
    __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2641
    __pyx_v_f = __pyx_t_9;
 
2642
 
 
2643
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":276
 
2644
 *                                       info.format + _buffer_format_string_len,
 
2645
 *                                       &offset)
 
2646
 *                 f[0] = 0 # Terminate format string             # <<<<<<<<<<<<<<
 
2647
 * 
 
2648
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 
2649
 */
 
2650
    (__pyx_v_f[0]) = 0;
 
2651
  }
 
2652
  __pyx_L12:;
 
2653
 
 
2654
  __pyx_r = 0;
 
2655
  goto __pyx_L0;
 
2656
  __pyx_L1_error:;
 
2657
  __Pyx_XDECREF(__pyx_t_4);
 
2658
  __Pyx_XDECREF(__pyx_t_5);
 
2659
  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__");
 
2660
  __pyx_r = -1;
 
2661
  __Pyx_GOTREF(__pyx_v_info->obj);
 
2662
  __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
 
2663
  goto __pyx_L2;
 
2664
  __pyx_L0:;
 
2665
  if (__pyx_v_info->obj == Py_None) {
 
2666
    __Pyx_GOTREF(Py_None);
 
2667
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
 
2668
  }
 
2669
  __pyx_L2:;
 
2670
  __Pyx_XDECREF((PyObject *)__pyx_v_descr);
 
2671
  __Pyx_DECREF((PyObject *)__pyx_v_self);
 
2672
  __Pyx_RefNannyFinishContext();
 
2673
  return __pyx_r;
 
2674
}
 
2675
 
 
2676
/* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":278
 
2677
 *                 f[0] = 0 # Terminate format string
 
2678
 * 
 
2679
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 
2680
 *             if PyArray_HASFIELDS(self):
 
2681
 *                 stdlib.free(info.format)
 
2682
 */
 
2683
 
 
2684
static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
 
2685
static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
 
2686
  int __pyx_t_1;
 
2687
  __Pyx_RefNannySetupContext("__releasebuffer__");
 
2688
  __Pyx_INCREF((PyObject *)__pyx_v_self);
 
2689
 
 
2690
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":279
 
2691
 * 
 
2692
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 
2693
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 
2694
 *                 stdlib.free(info.format)
 
2695
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 
2696
 */
 
2697
  __pyx_t_1 = PyArray_HASFIELDS(((PyArrayObject *)__pyx_v_self));
 
2698
  if (__pyx_t_1) {
 
2699
 
 
2700
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":280
 
2701
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 
2702
 *             if PyArray_HASFIELDS(self):
 
2703
 *                 stdlib.free(info.format)             # <<<<<<<<<<<<<<
 
2704
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 
2705
 *                 stdlib.free(info.strides)
 
2706
 */
 
2707
    free(__pyx_v_info->format);
 
2708
    goto __pyx_L5;
 
2709
  }
 
2710
  __pyx_L5:;
 
2711
 
 
2712
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":281
 
2713
 *             if PyArray_HASFIELDS(self):
 
2714
 *                 stdlib.free(info.format)
 
2715
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 
2716
 *                 stdlib.free(info.strides)
 
2717
 *                 # info.shape was stored after info.strides in the same block
 
2718
 */
 
2719
  __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
 
2720
  if (__pyx_t_1) {
 
2721
 
 
2722
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":282
 
2723
 *                 stdlib.free(info.format)
 
2724
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 
2725
 *                 stdlib.free(info.strides)             # <<<<<<<<<<<<<<
 
2726
 *                 # info.shape was stored after info.strides in the same block
 
2727
 * 
 
2728
 */
 
2729
    free(__pyx_v_info->strides);
 
2730
    goto __pyx_L6;
 
2731
  }
 
2732
  __pyx_L6:;
 
2733
 
 
2734
  __Pyx_DECREF((PyObject *)__pyx_v_self);
 
2735
  __Pyx_RefNannyFinishContext();
 
2736
}
 
2737
 
 
2738
/* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":755
 
2739
 * ctypedef npy_cdouble     complex_t
 
2740
 * 
 
2741
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 
2742
 *     return PyArray_MultiIterNew(1, <void*>a)
 
2743
 * 
 
2744
 */
 
2745
 
 
2746
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
 
2747
  PyObject *__pyx_r = NULL;
 
2748
  PyObject *__pyx_t_1 = NULL;
 
2749
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew1");
 
2750
 
 
2751
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":756
 
2752
 * 
 
2753
 * cdef inline object PyArray_MultiIterNew1(a):
 
2754
 *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
 
2755
 * 
 
2756
 * cdef inline object PyArray_MultiIterNew2(a, b):
 
2757
 */
 
2758
  __Pyx_XDECREF(__pyx_r);
 
2759
  __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2760
  __Pyx_GOTREF(__pyx_t_1);
 
2761
  __pyx_r = __pyx_t_1;
 
2762
  __pyx_t_1 = 0;
 
2763
  goto __pyx_L0;
 
2764
 
 
2765
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2766
  goto __pyx_L0;
 
2767
  __pyx_L1_error:;
 
2768
  __Pyx_XDECREF(__pyx_t_1);
 
2769
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1");
 
2770
  __pyx_r = 0;
 
2771
  __pyx_L0:;
 
2772
  __Pyx_XGIVEREF(__pyx_r);
 
2773
  __Pyx_RefNannyFinishContext();
 
2774
  return __pyx_r;
 
2775
}
 
2776
 
 
2777
/* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":758
 
2778
 *     return PyArray_MultiIterNew(1, <void*>a)
 
2779
 * 
 
2780
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 
2781
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 
2782
 * 
 
2783
 */
 
2784
 
 
2785
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
 
2786
  PyObject *__pyx_r = NULL;
 
2787
  PyObject *__pyx_t_1 = NULL;
 
2788
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew2");
 
2789
 
 
2790
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":759
 
2791
 * 
 
2792
 * cdef inline object PyArray_MultiIterNew2(a, b):
 
2793
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
 
2794
 * 
 
2795
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 
2796
 */
 
2797
  __Pyx_XDECREF(__pyx_r);
 
2798
  __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2799
  __Pyx_GOTREF(__pyx_t_1);
 
2800
  __pyx_r = __pyx_t_1;
 
2801
  __pyx_t_1 = 0;
 
2802
  goto __pyx_L0;
 
2803
 
 
2804
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2805
  goto __pyx_L0;
 
2806
  __pyx_L1_error:;
 
2807
  __Pyx_XDECREF(__pyx_t_1);
 
2808
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2");
 
2809
  __pyx_r = 0;
 
2810
  __pyx_L0:;
 
2811
  __Pyx_XGIVEREF(__pyx_r);
 
2812
  __Pyx_RefNannyFinishContext();
 
2813
  return __pyx_r;
 
2814
}
 
2815
 
 
2816
/* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":761
 
2817
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 
2818
 * 
 
2819
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 
2820
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 
2821
 * 
 
2822
 */
 
2823
 
 
2824
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
 
2825
  PyObject *__pyx_r = NULL;
 
2826
  PyObject *__pyx_t_1 = NULL;
 
2827
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew3");
 
2828
 
 
2829
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":762
 
2830
 * 
 
2831
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 
2832
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
 
2833
 * 
 
2834
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 
2835
 */
 
2836
  __Pyx_XDECREF(__pyx_r);
 
2837
  __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2838
  __Pyx_GOTREF(__pyx_t_1);
 
2839
  __pyx_r = __pyx_t_1;
 
2840
  __pyx_t_1 = 0;
 
2841
  goto __pyx_L0;
 
2842
 
 
2843
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2844
  goto __pyx_L0;
 
2845
  __pyx_L1_error:;
 
2846
  __Pyx_XDECREF(__pyx_t_1);
 
2847
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3");
 
2848
  __pyx_r = 0;
 
2849
  __pyx_L0:;
 
2850
  __Pyx_XGIVEREF(__pyx_r);
 
2851
  __Pyx_RefNannyFinishContext();
 
2852
  return __pyx_r;
 
2853
}
 
2854
 
 
2855
/* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":764
 
2856
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 
2857
 * 
 
2858
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 
2859
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 
2860
 * 
 
2861
 */
 
2862
 
 
2863
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
 
2864
  PyObject *__pyx_r = NULL;
 
2865
  PyObject *__pyx_t_1 = NULL;
 
2866
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew4");
 
2867
 
 
2868
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":765
 
2869
 * 
 
2870
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 
2871
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
 
2872
 * 
 
2873
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 
2874
 */
 
2875
  __Pyx_XDECREF(__pyx_r);
 
2876
  __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2877
  __Pyx_GOTREF(__pyx_t_1);
 
2878
  __pyx_r = __pyx_t_1;
 
2879
  __pyx_t_1 = 0;
 
2880
  goto __pyx_L0;
 
2881
 
 
2882
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2883
  goto __pyx_L0;
 
2884
  __pyx_L1_error:;
 
2885
  __Pyx_XDECREF(__pyx_t_1);
 
2886
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4");
 
2887
  __pyx_r = 0;
 
2888
  __pyx_L0:;
 
2889
  __Pyx_XGIVEREF(__pyx_r);
 
2890
  __Pyx_RefNannyFinishContext();
 
2891
  return __pyx_r;
 
2892
}
 
2893
 
 
2894
/* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":767
 
2895
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 
2896
 * 
 
2897
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 
2898
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 
2899
 * 
 
2900
 */
 
2901
 
 
2902
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
 
2903
  PyObject *__pyx_r = NULL;
 
2904
  PyObject *__pyx_t_1 = NULL;
 
2905
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew5");
 
2906
 
 
2907
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":768
 
2908
 * 
 
2909
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 
2910
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
 
2911
 * 
 
2912
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
 
2913
 */
 
2914
  __Pyx_XDECREF(__pyx_r);
 
2915
  __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2916
  __Pyx_GOTREF(__pyx_t_1);
 
2917
  __pyx_r = __pyx_t_1;
 
2918
  __pyx_t_1 = 0;
 
2919
  goto __pyx_L0;
 
2920
 
 
2921
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
2922
  goto __pyx_L0;
 
2923
  __pyx_L1_error:;
 
2924
  __Pyx_XDECREF(__pyx_t_1);
 
2925
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5");
 
2926
  __pyx_r = 0;
 
2927
  __pyx_L0:;
 
2928
  __Pyx_XGIVEREF(__pyx_r);
 
2929
  __Pyx_RefNannyFinishContext();
 
2930
  return __pyx_r;
 
2931
}
 
2932
 
 
2933
/* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":770
 
2934
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 
2935
 * 
 
2936
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 
2937
 *     # Recursive utility function used in __getbuffer__ to get format
 
2938
 *     # string. The new location in the format string is returned.
 
2939
 */
 
2940
 
 
2941
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
 
2942
  PyArray_Descr *__pyx_v_child;
 
2943
  int __pyx_v_endian_detector;
 
2944
  int __pyx_v_little_endian;
 
2945
  PyObject *__pyx_v_fields;
 
2946
  PyObject *__pyx_v_childname;
 
2947
  PyObject *__pyx_v_new_offset;
 
2948
  PyObject *__pyx_v_t;
 
2949
  char *__pyx_r;
 
2950
  Py_ssize_t __pyx_t_1;
 
2951
  PyObject *__pyx_t_2 = NULL;
 
2952
  PyObject *__pyx_t_3 = NULL;
 
2953
  PyObject *__pyx_t_4 = NULL;
 
2954
  PyObject *__pyx_t_5 = NULL;
 
2955
  int __pyx_t_6;
 
2956
  int __pyx_t_7;
 
2957
  int __pyx_t_8;
 
2958
  int __pyx_t_9;
 
2959
  char *__pyx_t_10;
 
2960
  __Pyx_RefNannySetupContext("_util_dtypestring");
 
2961
  __Pyx_INCREF((PyObject *)__pyx_v_descr);
 
2962
  __pyx_v_child = ((PyArray_Descr *)Py_None); __Pyx_INCREF(Py_None);
 
2963
  __pyx_v_fields = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
 
2964
  __pyx_v_childname = Py_None; __Pyx_INCREF(Py_None);
 
2965
  __pyx_v_new_offset = Py_None; __Pyx_INCREF(Py_None);
 
2966
  __pyx_v_t = Py_None; __Pyx_INCREF(Py_None);
 
2967
 
 
2968
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":777
 
2969
 *     cdef int delta_offset
 
2970
 *     cdef tuple i
 
2971
 *     cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 
2972
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 
2973
 *     cdef tuple fields
 
2974
 */
 
2975
  __pyx_v_endian_detector = 1;
 
2976
 
 
2977
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":778
 
2978
 *     cdef tuple i
 
2979
 *     cdef int endian_detector = 1
 
2980
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 
2981
 *     cdef tuple fields
 
2982
 * 
 
2983
 */
 
2984
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
 
2985
 
 
2986
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":781
 
2987
 *     cdef tuple fields
 
2988
 * 
 
2989
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 
2990
 *         fields = descr.fields[childname]
 
2991
 *         child, new_offset = fields
 
2992
 */
 
2993
  if (likely(((PyObject *)__pyx_v_descr->names) != Py_None)) {
 
2994
    __pyx_t_1 = 0; __pyx_t_2 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_2);
 
2995
  } else {
 
2996
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
2997
  }
 
2998
  for (;;) {
 
2999
    if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
 
3000
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
 
3001
    __Pyx_DECREF(__pyx_v_childname);
 
3002
    __pyx_v_childname = __pyx_t_3;
 
3003
    __pyx_t_3 = 0;
 
3004
 
 
3005
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":782
 
3006
 * 
 
3007
 *     for childname in descr.names:
 
3008
 *         fields = descr.fields[childname]             # <<<<<<<<<<<<<<
 
3009
 *         child, new_offset = fields
 
3010
 * 
 
3011
 */
 
3012
    __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3013
    __Pyx_GOTREF(__pyx_t_3);
 
3014
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3015
    __Pyx_DECREF(((PyObject *)__pyx_v_fields));
 
3016
    __pyx_v_fields = ((PyObject *)__pyx_t_3);
 
3017
    __pyx_t_3 = 0;
 
3018
 
 
3019
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":783
 
3020
 *     for childname in descr.names:
 
3021
 *         fields = descr.fields[childname]
 
3022
 *         child, new_offset = fields             # <<<<<<<<<<<<<<
 
3023
 * 
 
3024
 *         if (end - f) - (new_offset - offset[0]) < 15:
 
3025
 */
 
3026
    if (likely(((PyObject *)__pyx_v_fields) != Py_None) && likely(PyTuple_GET_SIZE(((PyObject *)__pyx_v_fields)) == 2)) {
 
3027
      PyObject* tuple = ((PyObject *)__pyx_v_fields);
 
3028
      __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3);
 
3029
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3030
      __pyx_t_4 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_4);
 
3031
      __Pyx_DECREF(((PyObject *)__pyx_v_child));
 
3032
      __pyx_v_child = ((PyArray_Descr *)__pyx_t_3);
 
3033
      __pyx_t_3 = 0;
 
3034
      __Pyx_DECREF(__pyx_v_new_offset);
 
3035
      __pyx_v_new_offset = __pyx_t_4;
 
3036
      __pyx_t_4 = 0;
 
3037
    } else {
 
3038
      __Pyx_UnpackTupleError(((PyObject *)__pyx_v_fields), 2);
 
3039
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3040
    }
 
3041
 
 
3042
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":785
 
3043
 *         child, new_offset = fields
 
3044
 * 
 
3045
 *         if (end - f) - (new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 
3046
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 
3047
 * 
 
3048
 */
 
3049
    __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3050
    __Pyx_GOTREF(__pyx_t_4);
 
3051
    __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3052
    __Pyx_GOTREF(__pyx_t_3);
 
3053
    __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3054
    __Pyx_GOTREF(__pyx_t_5);
 
3055
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3056
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3057
    __Pyx_GOTREF(__pyx_t_3);
 
3058
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
3059
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3060
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3061
    __Pyx_GOTREF(__pyx_t_5);
 
3062
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3063
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3064
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3065
    if (__pyx_t_6) {
 
3066
 
 
3067
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":786
 
3068
 * 
 
3069
 *         if (end - f) - (new_offset - offset[0]) < 15:
 
3070
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 
3071
 * 
 
3072
 *         if ((child.byteorder == '>' and little_endian) or
 
3073
 */
 
3074
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3075
      __Pyx_GOTREF(__pyx_t_5);
 
3076
      __Pyx_INCREF(((PyObject *)__pyx_kp_u_5));
 
3077
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_u_5));
 
3078
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_5));
 
3079
      __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3080
      __Pyx_GOTREF(__pyx_t_3);
 
3081
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3082
      __Pyx_Raise(__pyx_t_3, 0, 0);
 
3083
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3084
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3085
      goto __pyx_L5;
 
3086
    }
 
3087
    __pyx_L5:;
 
3088
 
 
3089
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":788
 
3090
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 
3091
 * 
 
3092
 *         if ((child.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
 
3093
 *             (child.byteorder == '<' and not little_endian)):
 
3094
 *             raise ValueError(u"Non-native byte order not supported")
 
3095
 */
 
3096
    __pyx_t_6 = (__pyx_v_child->byteorder == '>');
 
3097
    if (__pyx_t_6) {
 
3098
      __pyx_t_7 = __pyx_v_little_endian;
 
3099
    } else {
 
3100
      __pyx_t_7 = __pyx_t_6;
 
3101
    }
 
3102
    if (!__pyx_t_7) {
 
3103
 
 
3104
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":789
 
3105
 * 
 
3106
 *         if ((child.byteorder == '>' and little_endian) or
 
3107
 *             (child.byteorder == '<' and not little_endian)):             # <<<<<<<<<<<<<<
 
3108
 *             raise ValueError(u"Non-native byte order not supported")
 
3109
 *             # One could encode it in the format string and have Cython
 
3110
 */
 
3111
      __pyx_t_6 = (__pyx_v_child->byteorder == '<');
 
3112
      if (__pyx_t_6) {
 
3113
        __pyx_t_8 = (!__pyx_v_little_endian);
 
3114
        __pyx_t_9 = __pyx_t_8;
 
3115
      } else {
 
3116
        __pyx_t_9 = __pyx_t_6;
 
3117
      }
 
3118
      __pyx_t_6 = __pyx_t_9;
 
3119
    } else {
 
3120
      __pyx_t_6 = __pyx_t_7;
 
3121
    }
 
3122
    if (__pyx_t_6) {
 
3123
 
 
3124
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":790
 
3125
 *         if ((child.byteorder == '>' and little_endian) or
 
3126
 *             (child.byteorder == '<' and not little_endian)):
 
3127
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 
3128
 *             # One could encode it in the format string and have Cython
 
3129
 *             # complain instead, BUT: < and > in format strings also imply
 
3130
 */
 
3131
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3132
      __Pyx_GOTREF(__pyx_t_3);
 
3133
      __Pyx_INCREF(((PyObject *)__pyx_kp_u_3));
 
3134
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_u_3));
 
3135
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_3));
 
3136
      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3137
      __Pyx_GOTREF(__pyx_t_5);
 
3138
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3139
      __Pyx_Raise(__pyx_t_5, 0, 0);
 
3140
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3141
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3142
      goto __pyx_L6;
 
3143
    }
 
3144
    __pyx_L6:;
 
3145
 
 
3146
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":800
 
3147
 * 
 
3148
 *         # Output padding bytes
 
3149
 *         while offset[0] < new_offset:             # <<<<<<<<<<<<<<
 
3150
 *             f[0] = 120 # "x"; pad byte
 
3151
 *             f += 1
 
3152
 */
 
3153
    while (1) {
 
3154
      __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3155
      __Pyx_GOTREF(__pyx_t_5);
 
3156
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3157
      __Pyx_GOTREF(__pyx_t_3);
 
3158
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3159
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3160
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3161
      if (!__pyx_t_6) break;
 
3162
 
 
3163
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":801
 
3164
 *         # Output padding bytes
 
3165
 *         while offset[0] < new_offset:
 
3166
 *             f[0] = 120 # "x"; pad byte             # <<<<<<<<<<<<<<
 
3167
 *             f += 1
 
3168
 *             offset[0] += 1
 
3169
 */
 
3170
      (__pyx_v_f[0]) = 120;
 
3171
 
 
3172
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":802
 
3173
 *         while offset[0] < new_offset:
 
3174
 *             f[0] = 120 # "x"; pad byte
 
3175
 *             f += 1             # <<<<<<<<<<<<<<
 
3176
 *             offset[0] += 1
 
3177
 * 
 
3178
 */
 
3179
      __pyx_v_f += 1;
 
3180
 
 
3181
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":803
 
3182
 *             f[0] = 120 # "x"; pad byte
 
3183
 *             f += 1
 
3184
 *             offset[0] += 1             # <<<<<<<<<<<<<<
 
3185
 * 
 
3186
 *         offset[0] += child.itemsize
 
3187
 */
 
3188
      (__pyx_v_offset[0]) += 1;
 
3189
    }
 
3190
 
 
3191
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":805
 
3192
 *             offset[0] += 1
 
3193
 * 
 
3194
 *         offset[0] += child.itemsize             # <<<<<<<<<<<<<<
 
3195
 * 
 
3196
 *         if not PyDataType_HASFIELDS(child):
 
3197
 */
 
3198
    (__pyx_v_offset[0]) += __pyx_v_child->elsize;
 
3199
 
 
3200
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":807
 
3201
 *         offset[0] += child.itemsize
 
3202
 * 
 
3203
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 
3204
 *             t = child.type_num
 
3205
 *             if end - f < 5:
 
3206
 */
 
3207
    __pyx_t_6 = (!PyDataType_HASFIELDS(__pyx_v_child));
 
3208
    if (__pyx_t_6) {
 
3209
 
 
3210
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":808
 
3211
 * 
 
3212
 *         if not PyDataType_HASFIELDS(child):
 
3213
 *             t = child.type_num             # <<<<<<<<<<<<<<
 
3214
 *             if end - f < 5:
 
3215
 *                 raise RuntimeError(u"Format string allocated too short.")
 
3216
 */
 
3217
      __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3218
      __Pyx_GOTREF(__pyx_t_3);
 
3219
      __Pyx_DECREF(__pyx_v_t);
 
3220
      __pyx_v_t = __pyx_t_3;
 
3221
      __pyx_t_3 = 0;
 
3222
 
 
3223
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":809
 
3224
 *         if not PyDataType_HASFIELDS(child):
 
3225
 *             t = child.type_num
 
3226
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 
3227
 *                 raise RuntimeError(u"Format string allocated too short.")
 
3228
 * 
 
3229
 */
 
3230
      __pyx_t_6 = ((__pyx_v_end - __pyx_v_f) < 5);
 
3231
      if (__pyx_t_6) {
 
3232
 
 
3233
        /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":810
 
3234
 *             t = child.type_num
 
3235
 *             if end - f < 5:
 
3236
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 
3237
 * 
 
3238
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 
3239
 */
 
3240
        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3241
        __Pyx_GOTREF(__pyx_t_3);
 
3242
        __Pyx_INCREF(((PyObject *)__pyx_kp_u_6));
 
3243
        PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_u_6));
 
3244
        __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_6));
 
3245
        __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3246
        __Pyx_GOTREF(__pyx_t_5);
 
3247
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3248
        __Pyx_Raise(__pyx_t_5, 0, 0);
 
3249
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3250
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3251
        goto __pyx_L10;
 
3252
      }
 
3253
      __pyx_L10:;
 
3254
 
 
3255
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":813
 
3256
 * 
 
3257
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 
3258
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"             # <<<<<<<<<<<<<<
 
3259
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 
3260
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 
3261
 */
 
3262
      __pyx_t_5 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3263
      __Pyx_GOTREF(__pyx_t_5);
 
3264
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3265
      __Pyx_GOTREF(__pyx_t_3);
 
3266
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3267
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3268
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3269
      if (__pyx_t_6) {
 
3270
        (__pyx_v_f[0]) = 98;
 
3271
        goto __pyx_L11;
 
3272
      }
 
3273
 
 
3274
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":814
 
3275
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 
3276
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 
3277
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"             # <<<<<<<<<<<<<<
 
3278
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 
3279
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 
3280
 */
 
3281
      __pyx_t_3 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3282
      __Pyx_GOTREF(__pyx_t_3);
 
3283
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3284
      __Pyx_GOTREF(__pyx_t_5);
 
3285
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3286
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3287
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3288
      if (__pyx_t_6) {
 
3289
        (__pyx_v_f[0]) = 66;
 
3290
        goto __pyx_L11;
 
3291
      }
 
3292
 
 
3293
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":815
 
3294
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 
3295
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 
3296
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"             # <<<<<<<<<<<<<<
 
3297
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 
3298
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 
3299
 */
 
3300
      __pyx_t_5 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3301
      __Pyx_GOTREF(__pyx_t_5);
 
3302
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3303
      __Pyx_GOTREF(__pyx_t_3);
 
3304
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3305
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3306
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3307
      if (__pyx_t_6) {
 
3308
        (__pyx_v_f[0]) = 104;
 
3309
        goto __pyx_L11;
 
3310
      }
 
3311
 
 
3312
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":816
 
3313
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 
3314
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 
3315
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"             # <<<<<<<<<<<<<<
 
3316
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 
3317
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 
3318
 */
 
3319
      __pyx_t_3 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3320
      __Pyx_GOTREF(__pyx_t_3);
 
3321
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3322
      __Pyx_GOTREF(__pyx_t_5);
 
3323
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3324
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3325
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3326
      if (__pyx_t_6) {
 
3327
        (__pyx_v_f[0]) = 72;
 
3328
        goto __pyx_L11;
 
3329
      }
 
3330
 
 
3331
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":817
 
3332
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 
3333
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 
3334
 *             elif t == NPY_INT:         f[0] = 105 #"i"             # <<<<<<<<<<<<<<
 
3335
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 
3336
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 
3337
 */
 
3338
      __pyx_t_5 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3339
      __Pyx_GOTREF(__pyx_t_5);
 
3340
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3341
      __Pyx_GOTREF(__pyx_t_3);
 
3342
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3343
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3344
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3345
      if (__pyx_t_6) {
 
3346
        (__pyx_v_f[0]) = 105;
 
3347
        goto __pyx_L11;
 
3348
      }
 
3349
 
 
3350
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":818
 
3351
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 
3352
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 
3353
 *             elif t == NPY_UINT:        f[0] =  73 #"I"             # <<<<<<<<<<<<<<
 
3354
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 
3355
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 
3356
 */
 
3357
      __pyx_t_3 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3358
      __Pyx_GOTREF(__pyx_t_3);
 
3359
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3360
      __Pyx_GOTREF(__pyx_t_5);
 
3361
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3362
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3363
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3364
      if (__pyx_t_6) {
 
3365
        (__pyx_v_f[0]) = 73;
 
3366
        goto __pyx_L11;
 
3367
      }
 
3368
 
 
3369
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":819
 
3370
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 
3371
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 
3372
 *             elif t == NPY_LONG:        f[0] = 108 #"l"             # <<<<<<<<<<<<<<
 
3373
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 
3374
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 
3375
 */
 
3376
      __pyx_t_5 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3377
      __Pyx_GOTREF(__pyx_t_5);
 
3378
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3379
      __Pyx_GOTREF(__pyx_t_3);
 
3380
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3381
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3382
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3383
      if (__pyx_t_6) {
 
3384
        (__pyx_v_f[0]) = 108;
 
3385
        goto __pyx_L11;
 
3386
      }
 
3387
 
 
3388
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":820
 
3389
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 
3390
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 
3391
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"             # <<<<<<<<<<<<<<
 
3392
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 
3393
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 
3394
 */
 
3395
      __pyx_t_3 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3396
      __Pyx_GOTREF(__pyx_t_3);
 
3397
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3398
      __Pyx_GOTREF(__pyx_t_5);
 
3399
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3400
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3401
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3402
      if (__pyx_t_6) {
 
3403
        (__pyx_v_f[0]) = 76;
 
3404
        goto __pyx_L11;
 
3405
      }
 
3406
 
 
3407
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":821
 
3408
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 
3409
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 
3410
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"             # <<<<<<<<<<<<<<
 
3411
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 
3412
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 
3413
 */
 
3414
      __pyx_t_5 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3415
      __Pyx_GOTREF(__pyx_t_5);
 
3416
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3417
      __Pyx_GOTREF(__pyx_t_3);
 
3418
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3419
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3420
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3421
      if (__pyx_t_6) {
 
3422
        (__pyx_v_f[0]) = 113;
 
3423
        goto __pyx_L11;
 
3424
      }
 
3425
 
 
3426
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":822
 
3427
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 
3428
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 
3429
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"             # <<<<<<<<<<<<<<
 
3430
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 
3431
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 
3432
 */
 
3433
      __pyx_t_3 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3434
      __Pyx_GOTREF(__pyx_t_3);
 
3435
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3436
      __Pyx_GOTREF(__pyx_t_5);
 
3437
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3438
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3439
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3440
      if (__pyx_t_6) {
 
3441
        (__pyx_v_f[0]) = 81;
 
3442
        goto __pyx_L11;
 
3443
      }
 
3444
 
 
3445
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":823
 
3446
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 
3447
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 
3448
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"             # <<<<<<<<<<<<<<
 
3449
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 
3450
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 
3451
 */
 
3452
      __pyx_t_5 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3453
      __Pyx_GOTREF(__pyx_t_5);
 
3454
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3455
      __Pyx_GOTREF(__pyx_t_3);
 
3456
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3457
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3458
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3459
      if (__pyx_t_6) {
 
3460
        (__pyx_v_f[0]) = 102;
 
3461
        goto __pyx_L11;
 
3462
      }
 
3463
 
 
3464
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":824
 
3465
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 
3466
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 
3467
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"             # <<<<<<<<<<<<<<
 
3468
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 
3469
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 
3470
 */
 
3471
      __pyx_t_3 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3472
      __Pyx_GOTREF(__pyx_t_3);
 
3473
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3474
      __Pyx_GOTREF(__pyx_t_5);
 
3475
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3476
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3477
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3478
      if (__pyx_t_6) {
 
3479
        (__pyx_v_f[0]) = 100;
 
3480
        goto __pyx_L11;
 
3481
      }
 
3482
 
 
3483
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":825
 
3484
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 
3485
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 
3486
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"             # <<<<<<<<<<<<<<
 
3487
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 
3488
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 
3489
 */
 
3490
      __pyx_t_5 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3491
      __Pyx_GOTREF(__pyx_t_5);
 
3492
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3493
      __Pyx_GOTREF(__pyx_t_3);
 
3494
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3495
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3496
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3497
      if (__pyx_t_6) {
 
3498
        (__pyx_v_f[0]) = 103;
 
3499
        goto __pyx_L11;
 
3500
      }
 
3501
 
 
3502
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":826
 
3503
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 
3504
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 
3505
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf             # <<<<<<<<<<<<<<
 
3506
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 
3507
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 
3508
 */
 
3509
      __pyx_t_3 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3510
      __Pyx_GOTREF(__pyx_t_3);
 
3511
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3512
      __Pyx_GOTREF(__pyx_t_5);
 
3513
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3514
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3515
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3516
      if (__pyx_t_6) {
 
3517
        (__pyx_v_f[0]) = 90;
 
3518
        (__pyx_v_f[1]) = 102;
 
3519
        __pyx_v_f += 1;
 
3520
        goto __pyx_L11;
 
3521
      }
 
3522
 
 
3523
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":827
 
3524
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 
3525
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 
3526
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd             # <<<<<<<<<<<<<<
 
3527
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 
3528
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 
3529
 */
 
3530
      __pyx_t_5 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3531
      __Pyx_GOTREF(__pyx_t_5);
 
3532
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3533
      __Pyx_GOTREF(__pyx_t_3);
 
3534
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3535
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3536
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3537
      if (__pyx_t_6) {
 
3538
        (__pyx_v_f[0]) = 90;
 
3539
        (__pyx_v_f[1]) = 100;
 
3540
        __pyx_v_f += 1;
 
3541
        goto __pyx_L11;
 
3542
      }
 
3543
 
 
3544
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":828
 
3545
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 
3546
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 
3547
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg             # <<<<<<<<<<<<<<
 
3548
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 
3549
 *             else:
 
3550
 */
 
3551
      __pyx_t_3 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3552
      __Pyx_GOTREF(__pyx_t_3);
 
3553
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3554
      __Pyx_GOTREF(__pyx_t_5);
 
3555
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3556
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3557
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3558
      if (__pyx_t_6) {
 
3559
        (__pyx_v_f[0]) = 90;
 
3560
        (__pyx_v_f[1]) = 103;
 
3561
        __pyx_v_f += 1;
 
3562
        goto __pyx_L11;
 
3563
      }
 
3564
 
 
3565
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":829
 
3566
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 
3567
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 
3568
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"             # <<<<<<<<<<<<<<
 
3569
 *             else:
 
3570
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 
3571
 */
 
3572
      __pyx_t_5 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3573
      __Pyx_GOTREF(__pyx_t_5);
 
3574
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3575
      __Pyx_GOTREF(__pyx_t_3);
 
3576
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3577
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3578
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3579
      if (__pyx_t_6) {
 
3580
        (__pyx_v_f[0]) = 79;
 
3581
        goto __pyx_L11;
 
3582
      }
 
3583
      /*else*/ {
 
3584
 
 
3585
        /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":831
 
3586
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 
3587
 *             else:
 
3588
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 
3589
 *             f += 1
 
3590
 *         else:
 
3591
 */
 
3592
        __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_4), __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3593
        __Pyx_GOTREF(__pyx_t_3);
 
3594
        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3595
        __Pyx_GOTREF(__pyx_t_5);
 
3596
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
 
3597
        __Pyx_GIVEREF(__pyx_t_3);
 
3598
        __pyx_t_3 = 0;
 
3599
        __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3600
        __Pyx_GOTREF(__pyx_t_3);
 
3601
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
3602
        __Pyx_Raise(__pyx_t_3, 0, 0);
 
3603
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
3604
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3605
      }
 
3606
      __pyx_L11:;
 
3607
 
 
3608
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":832
 
3609
 *             else:
 
3610
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 
3611
 *             f += 1             # <<<<<<<<<<<<<<
 
3612
 *         else:
 
3613
 *             # Cython ignores struct boundary information ("T{...}"),
 
3614
 */
 
3615
      __pyx_v_f += 1;
 
3616
      goto __pyx_L9;
 
3617
    }
 
3618
    /*else*/ {
 
3619
 
 
3620
      /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":836
 
3621
 *             # Cython ignores struct boundary information ("T{...}"),
 
3622
 *             # so don't output it
 
3623
 *             f = _util_dtypestring(child, f, end, offset)             # <<<<<<<<<<<<<<
 
3624
 *     return f
 
3625
 * 
 
3626
 */
 
3627
      __pyx_t_10 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3628
      __pyx_v_f = __pyx_t_10;
 
3629
    }
 
3630
    __pyx_L9:;
 
3631
  }
 
3632
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
3633
 
 
3634
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":837
 
3635
 *             # so don't output it
 
3636
 *             f = _util_dtypestring(child, f, end, offset)
 
3637
 *     return f             # <<<<<<<<<<<<<<
 
3638
 * 
 
3639
 * 
 
3640
 */
 
3641
  __pyx_r = __pyx_v_f;
 
3642
  goto __pyx_L0;
 
3643
 
 
3644
  __pyx_r = 0;
 
3645
  goto __pyx_L0;
 
3646
  __pyx_L1_error:;
 
3647
  __Pyx_XDECREF(__pyx_t_2);
 
3648
  __Pyx_XDECREF(__pyx_t_3);
 
3649
  __Pyx_XDECREF(__pyx_t_4);
 
3650
  __Pyx_XDECREF(__pyx_t_5);
 
3651
  __Pyx_AddTraceback("numpy._util_dtypestring");
 
3652
  __pyx_r = NULL;
 
3653
  __pyx_L0:;
 
3654
  __Pyx_DECREF((PyObject *)__pyx_v_child);
 
3655
  __Pyx_DECREF(__pyx_v_fields);
 
3656
  __Pyx_DECREF(__pyx_v_childname);
 
3657
  __Pyx_DECREF(__pyx_v_new_offset);
 
3658
  __Pyx_DECREF(__pyx_v_t);
 
3659
  __Pyx_DECREF((PyObject *)__pyx_v_descr);
 
3660
  __Pyx_RefNannyFinishContext();
 
3661
  return __pyx_r;
 
3662
}
 
3663
 
 
3664
/* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":952
 
3665
 * 
 
3666
 * 
 
3667
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 
3668
 *      cdef PyObject* baseptr
 
3669
 *      if base is None:
 
3670
 */
 
3671
 
 
3672
static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
 
3673
  PyObject *__pyx_v_baseptr;
 
3674
  int __pyx_t_1;
 
3675
  __Pyx_RefNannySetupContext("set_array_base");
 
3676
  __Pyx_INCREF((PyObject *)__pyx_v_arr);
 
3677
  __Pyx_INCREF(__pyx_v_base);
 
3678
 
 
3679
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":954
 
3680
 * cdef inline void set_array_base(ndarray arr, object base):
 
3681
 *      cdef PyObject* baseptr
 
3682
 *      if base is None:             # <<<<<<<<<<<<<<
 
3683
 *          baseptr = NULL
 
3684
 *      else:
 
3685
 */
 
3686
  __pyx_t_1 = (__pyx_v_base == Py_None);
 
3687
  if (__pyx_t_1) {
 
3688
 
 
3689
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":955
 
3690
 *      cdef PyObject* baseptr
 
3691
 *      if base is None:
 
3692
 *          baseptr = NULL             # <<<<<<<<<<<<<<
 
3693
 *      else:
 
3694
 *          Py_INCREF(base) # important to do this before decref below!
 
3695
 */
 
3696
    __pyx_v_baseptr = NULL;
 
3697
    goto __pyx_L3;
 
3698
  }
 
3699
  /*else*/ {
 
3700
 
 
3701
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":957
 
3702
 *          baseptr = NULL
 
3703
 *      else:
 
3704
 *          Py_INCREF(base) # important to do this before decref below!             # <<<<<<<<<<<<<<
 
3705
 *          baseptr = <PyObject*>base
 
3706
 *      Py_XDECREF(arr.base)
 
3707
 */
 
3708
    Py_INCREF(__pyx_v_base);
 
3709
 
 
3710
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":958
 
3711
 *      else:
 
3712
 *          Py_INCREF(base) # important to do this before decref below!
 
3713
 *          baseptr = <PyObject*>base             # <<<<<<<<<<<<<<
 
3714
 *      Py_XDECREF(arr.base)
 
3715
 *      arr.base = baseptr
 
3716
 */
 
3717
    __pyx_v_baseptr = ((PyObject *)__pyx_v_base);
 
3718
  }
 
3719
  __pyx_L3:;
 
3720
 
 
3721
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":959
 
3722
 *          Py_INCREF(base) # important to do this before decref below!
 
3723
 *          baseptr = <PyObject*>base
 
3724
 *      Py_XDECREF(arr.base)             # <<<<<<<<<<<<<<
 
3725
 *      arr.base = baseptr
 
3726
 * 
 
3727
 */
 
3728
  Py_XDECREF(__pyx_v_arr->base);
 
3729
 
 
3730
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":960
 
3731
 *          baseptr = <PyObject*>base
 
3732
 *      Py_XDECREF(arr.base)
 
3733
 *      arr.base = baseptr             # <<<<<<<<<<<<<<
 
3734
 * 
 
3735
 * cdef inline object get_array_base(ndarray arr):
 
3736
 */
 
3737
  __pyx_v_arr->base = __pyx_v_baseptr;
 
3738
 
 
3739
  __Pyx_DECREF((PyObject *)__pyx_v_arr);
 
3740
  __Pyx_DECREF(__pyx_v_base);
 
3741
  __Pyx_RefNannyFinishContext();
 
3742
}
 
3743
 
 
3744
/* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":962
 
3745
 *      arr.base = baseptr
 
3746
 * 
 
3747
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 
3748
 *     if arr.base is NULL:
 
3749
 *         return None
 
3750
 */
 
3751
 
 
3752
static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
 
3753
  PyObject *__pyx_r = NULL;
 
3754
  int __pyx_t_1;
 
3755
  __Pyx_RefNannySetupContext("get_array_base");
 
3756
  __Pyx_INCREF((PyObject *)__pyx_v_arr);
 
3757
 
 
3758
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":963
 
3759
 * 
 
3760
 * cdef inline object get_array_base(ndarray arr):
 
3761
 *     if arr.base is NULL:             # <<<<<<<<<<<<<<
 
3762
 *         return None
 
3763
 *     else:
 
3764
 */
 
3765
  __pyx_t_1 = (__pyx_v_arr->base == NULL);
 
3766
  if (__pyx_t_1) {
 
3767
 
 
3768
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":964
 
3769
 * cdef inline object get_array_base(ndarray arr):
 
3770
 *     if arr.base is NULL:
 
3771
 *         return None             # <<<<<<<<<<<<<<
 
3772
 *     else:
 
3773
 *         return <object>arr.base
 
3774
 */
 
3775
    __Pyx_XDECREF(__pyx_r);
 
3776
    __Pyx_INCREF(Py_None);
 
3777
    __pyx_r = Py_None;
 
3778
    goto __pyx_L0;
 
3779
    goto __pyx_L3;
 
3780
  }
 
3781
  /*else*/ {
 
3782
 
 
3783
    /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/numpy.pxd":966
 
3784
 *         return None
 
3785
 *     else:
 
3786
 *         return <object>arr.base             # <<<<<<<<<<<<<<
 
3787
 */
 
3788
    __Pyx_XDECREF(__pyx_r);
 
3789
    __Pyx_INCREF(((PyObject *)__pyx_v_arr->base));
 
3790
    __pyx_r = ((PyObject *)__pyx_v_arr->base);
 
3791
    goto __pyx_L0;
 
3792
  }
 
3793
  __pyx_L3:;
 
3794
 
 
3795
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
 
3796
  __pyx_L0:;
 
3797
  __Pyx_DECREF((PyObject *)__pyx_v_arr);
 
3798
  __Pyx_XGIVEREF(__pyx_r);
 
3799
  __Pyx_RefNannyFinishContext();
 
3800
  return __pyx_r;
 
3801
}
 
3802
 
 
3803
static struct PyMethodDef __pyx_methods[] = {
 
3804
  {__Pyx_NAMESTR("goertzel_inner"), (PyCFunction)__pyx_pf_6cogent_5maths_7_period_goertzel_inner, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6cogent_5maths_7_period_goertzel_inner)},
 
3805
  {__Pyx_NAMESTR("ipdft_inner"), (PyCFunction)__pyx_pf_6cogent_5maths_7_period_ipdft_inner, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6cogent_5maths_7_period_ipdft_inner)},
 
3806
  {__Pyx_NAMESTR("autocorr_inner"), (PyCFunction)__pyx_pf_6cogent_5maths_7_period_autocorr_inner, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
 
3807
  {__Pyx_NAMESTR("seq_to_symbols"), (PyCFunction)__pyx_pf_6cogent_5maths_7_period_seq_to_symbols, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
 
3808
  {0, 0, 0, 0}
 
3809
};
 
3810
 
 
3811
static void __pyx_init_filenames(void); /*proto*/
 
3812
 
 
3813
#if PY_MAJOR_VERSION >= 3
 
3814
static struct PyModuleDef __pyx_moduledef = {
 
3815
    PyModuleDef_HEAD_INIT,
 
3816
    __Pyx_NAMESTR("_period"),
 
3817
    0, /* m_doc */
 
3818
    -1, /* m_size */
 
3819
    __pyx_methods /* m_methods */,
 
3820
    NULL, /* m_reload */
 
3821
    NULL, /* m_traverse */
 
3822
    NULL, /* m_clear */
 
3823
    NULL /* m_free */
 
3824
};
 
3825
#endif
 
3826
 
 
3827
static __Pyx_StringTabEntry __pyx_string_tab[] = {
 
3828
  {&__pyx_kp_u_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 1, 0, 0},
 
3829
  {&__pyx_kp_u_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 1, 0, 0},
 
3830
  {&__pyx_kp_u_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 1, 0, 0},
 
3831
  {&__pyx_kp_u_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 1, 0, 0},
 
3832
  {&__pyx_kp_u_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 1, 0, 0},
 
3833
  {&__pyx_kp_u_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 1, 0, 0},
 
3834
  {&__pyx_kp_u_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 1, 0, 0},
 
3835
  {&__pyx_kp_u_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 1, 0, 0},
 
3836
  {&__pyx_n_s__N, __pyx_k__N, sizeof(__pyx_k__N), 0, 0, 1, 1},
 
3837
  {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
 
3838
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
 
3839
  {&__pyx_n_s__W, __pyx_k__W, sizeof(__pyx_k__W), 0, 0, 1, 1},
 
3840
  {&__pyx_n_s__X, __pyx_k__X, sizeof(__pyx_k__X), 0, 0, 1, 1},
 
3841
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
 
3842
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
 
3843
  {&__pyx_n_s__base, __pyx_k__base, sizeof(__pyx_k__base), 0, 0, 1, 1},
 
3844
  {&__pyx_n_s__buf, __pyx_k__buf, sizeof(__pyx_k__buf), 0, 0, 1, 1},
 
3845
  {&__pyx_n_s__byteorder, __pyx_k__byteorder, sizeof(__pyx_k__byteorder), 0, 0, 1, 1},
 
3846
  {&__pyx_n_s__cos, __pyx_k__cos, sizeof(__pyx_k__cos), 0, 0, 1, 1},
 
3847
  {&__pyx_n_s__descr, __pyx_k__descr, sizeof(__pyx_k__descr), 0, 0, 1, 1},
 
3848
  {&__pyx_n_s__exp, __pyx_k__exp, sizeof(__pyx_k__exp), 0, 0, 1, 1},
 
3849
  {&__pyx_n_s__fields, __pyx_k__fields, sizeof(__pyx_k__fields), 0, 0, 1, 1},
 
3850
  {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
 
3851
  {&__pyx_n_s__goertzel_inner, __pyx_k__goertzel_inner, sizeof(__pyx_k__goertzel_inner), 0, 0, 1, 1},
 
3852
  {&__pyx_n_s__ipdft_inner, __pyx_k__ipdft_inner, sizeof(__pyx_k__ipdft_inner), 0, 0, 1, 1},
 
3853
  {&__pyx_n_s__itemsize, __pyx_k__itemsize, sizeof(__pyx_k__itemsize), 0, 0, 1, 1},
 
3854
  {&__pyx_n_s__motif_length, __pyx_k__motif_length, sizeof(__pyx_k__motif_length), 0, 0, 1, 1},
 
3855
  {&__pyx_n_s__motifs, __pyx_k__motifs, sizeof(__pyx_k__motifs), 0, 0, 1, 1},
 
3856
  {&__pyx_n_s__names, __pyx_k__names, sizeof(__pyx_k__names), 0, 0, 1, 1},
 
3857
  {&__pyx_n_s__ndim, __pyx_k__ndim, sizeof(__pyx_k__ndim), 0, 0, 1, 1},
 
3858
  {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1},
 
3859
  {&__pyx_n_s__obj, __pyx_k__obj, sizeof(__pyx_k__obj), 0, 0, 1, 1},
 
3860
  {&__pyx_n_s__period, __pyx_k__period, sizeof(__pyx_k__period), 0, 0, 1, 1},
 
3861
  {&__pyx_n_s__pi, __pyx_k__pi, sizeof(__pyx_k__pi), 0, 0, 1, 1},
 
3862
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
 
3863
  {&__pyx_n_s__readonly, __pyx_k__readonly, sizeof(__pyx_k__readonly), 0, 0, 1, 1},
 
3864
  {&__pyx_n_s__result, __pyx_k__result, sizeof(__pyx_k__result), 0, 0, 1, 1},
 
3865
  {&__pyx_n_s__seq, __pyx_k__seq, sizeof(__pyx_k__seq), 0, 0, 1, 1},
 
3866
  {&__pyx_n_s__shape, __pyx_k__shape, sizeof(__pyx_k__shape), 0, 0, 1, 1},
 
3867
  {&__pyx_n_s__sqrt, __pyx_k__sqrt, sizeof(__pyx_k__sqrt), 0, 0, 1, 1},
 
3868
  {&__pyx_n_s__strides, __pyx_k__strides, sizeof(__pyx_k__strides), 0, 0, 1, 1},
 
3869
  {&__pyx_n_s__suboffsets, __pyx_k__suboffsets, sizeof(__pyx_k__suboffsets), 0, 0, 1, 1},
 
3870
  {&__pyx_n_s__type_num, __pyx_k__type_num, sizeof(__pyx_k__type_num), 0, 0, 1, 1},
 
3871
  {&__pyx_n_s__ulim, __pyx_k__ulim, sizeof(__pyx_k__ulim), 0, 0, 1, 1},
 
3872
  {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1},
 
3873
  {&__pyx_n_s__xc, __pyx_k__xc, sizeof(__pyx_k__xc), 0, 0, 1, 1},
 
3874
  {0, 0, 0, 0, 0, 0, 0}
 
3875
};
 
3876
static int __Pyx_InitCachedBuiltins(void) {
 
3877
  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3878
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3879
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3880
  return 0;
 
3881
  __pyx_L1_error:;
 
3882
  return -1;
 
3883
}
 
3884
 
 
3885
static int __Pyx_InitGlobals(void) {
 
3886
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
3887
  __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;};
 
3888
  __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
3889
  return 0;
 
3890
  __pyx_L1_error:;
 
3891
  return -1;
 
3892
}
 
3893
 
 
3894
#if PY_MAJOR_VERSION < 3
 
3895
PyMODINIT_FUNC init_period(void); /*proto*/
 
3896
PyMODINIT_FUNC init_period(void)
 
3897
#else
 
3898
PyMODINIT_FUNC PyInit__period(void); /*proto*/
 
3899
PyMODINIT_FUNC PyInit__period(void)
 
3900
#endif
 
3901
{
 
3902
  PyObject *__pyx_t_1 = NULL;
 
3903
  PyObject *__pyx_t_2 = NULL;
 
3904
  PyObject *__pyx_t_3 = NULL;
 
3905
  #if CYTHON_REFNANNY
 
3906
  void* __pyx_refnanny = NULL;
 
3907
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
 
3908
  if (!__Pyx_RefNanny) {
 
3909
      PyErr_Clear();
 
3910
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
 
3911
      if (!__Pyx_RefNanny)
 
3912
          Py_FatalError("failed to import 'refnanny' module");
 
3913
  }
 
3914
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit__period(void)", __LINE__, __FILE__);
 
3915
  #endif
 
3916
  __pyx_init_filenames();
 
3917
  __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;}
 
3918
  #if PY_MAJOR_VERSION < 3
 
3919
  __pyx_empty_bytes = PyString_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3920
  #else
 
3921
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3922
  #endif
 
3923
  /*--- Library function declarations ---*/
 
3924
  /*--- Threads initialization code ---*/
 
3925
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
 
3926
  #ifdef WITH_THREAD /* Python build with threading support? */
 
3927
  PyEval_InitThreads();
 
3928
  #endif
 
3929
  #endif
 
3930
  /*--- Module creation code ---*/
 
3931
  #if PY_MAJOR_VERSION < 3
 
3932
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_period"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
 
3933
  #else
 
3934
  __pyx_m = PyModule_Create(&__pyx_moduledef);
 
3935
  #endif
 
3936
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
3937
  #if PY_MAJOR_VERSION < 3
 
3938
  Py_INCREF(__pyx_m);
 
3939
  #endif
 
3940
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
 
3941
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
3942
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
3943
  /*--- Initialize various global constants etc. ---*/
 
3944
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3945
  if (__pyx_module_is_main_cogent__maths___period) {
 
3946
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
3947
  }
 
3948
  /*--- Builtin init code ---*/
 
3949
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3950
  /*--- Global init code ---*/
 
3951
  /*--- Function export code ---*/
 
3952
  /*--- Type init code ---*/
 
3953
  /*--- Type import code ---*/
 
3954
  __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3955
  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3956
  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3957
  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3958
  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3959
  /*--- Function import code ---*/
 
3960
  /*--- Execution code ---*/
 
3961
 
 
3962
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":1
 
3963
 * from numpy import pi, exp, sqrt, cos             # <<<<<<<<<<<<<<
 
3964
 * cimport numpy as np
 
3965
 * 
 
3966
 */
 
3967
  __pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3968
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
3969
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pi));
 
3970
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__pi));
 
3971
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pi));
 
3972
  __Pyx_INCREF(((PyObject *)__pyx_n_s__exp));
 
3973
  PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__exp));
 
3974
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__exp));
 
3975
  __Pyx_INCREF(((PyObject *)__pyx_n_s__sqrt));
 
3976
  PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__sqrt));
 
3977
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sqrt));
 
3978
  __Pyx_INCREF(((PyObject *)__pyx_n_s__cos));
 
3979
  PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__cos));
 
3980
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__cos));
 
3981
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3982
  __Pyx_GOTREF(__pyx_t_2);
 
3983
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
3984
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__pi); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3985
  __Pyx_GOTREF(__pyx_t_1);
 
3986
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__pi, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3987
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3988
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3989
  __Pyx_GOTREF(__pyx_t_1);
 
3990
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__exp, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3991
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3992
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__sqrt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3993
  __Pyx_GOTREF(__pyx_t_1);
 
3994
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sqrt, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3995
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
3996
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__cos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3997
  __Pyx_GOTREF(__pyx_t_1);
 
3998
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__cos, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
3999
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
4000
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
4001
 
 
4002
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":47
 
4003
 *                 xc[m+N-1] += (x[n]*x[n-m])
 
4004
 * 
 
4005
 * def seq_to_symbols(char* seq, list motifs, int motif_length,             # <<<<<<<<<<<<<<
 
4006
 *     np.ndarray[np.uint8_t, ndim=1] result):
 
4007
 *     cdef int i, j, N, num_motifs
 
4008
 */
 
4009
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4010
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
4011
 
 
4012
  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/maths/_period.pyx":1
 
4013
 * from numpy import pi, exp, sqrt, cos             # <<<<<<<<<<<<<<
 
4014
 * cimport numpy as np
 
4015
 * 
 
4016
 */
 
4017
  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__goertzel_inner); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4018
  __Pyx_GOTREF(__pyx_t_1);
 
4019
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_1, "__doc__");
 
4020
  __Pyx_GOTREF(__pyx_t_3);
 
4021
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
4022
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_7), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4023
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
4024
  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__ipdft_inner); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4025
  __Pyx_GOTREF(__pyx_t_3);
 
4026
  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
 
4027
  __Pyx_GOTREF(__pyx_t_1);
 
4028
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
4029
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_8), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4030
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
4031
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
4032
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
4033
 
 
4034
  /* "/Users/gavin/DevSandbox/trunk/lib/python2.6/site-packages/Cython-0.12.1-py2.6-macosx-10.6-universal.egg/Cython/Includes/stdlib.pxd":2
 
4035
 * 
 
4036
 * cdef extern from "stdlib.h" nogil:             # <<<<<<<<<<<<<<
 
4037
 *     void free(void *ptr)
 
4038
 *     void *malloc(size_t size)
 
4039
 */
 
4040
  goto __pyx_L0;
 
4041
  __pyx_L1_error:;
 
4042
  __Pyx_XDECREF(__pyx_t_1);
 
4043
  __Pyx_XDECREF(__pyx_t_2);
 
4044
  __Pyx_XDECREF(__pyx_t_3);
 
4045
  if (__pyx_m) {
 
4046
    __Pyx_AddTraceback("init cogent.maths._period");
 
4047
    Py_DECREF(__pyx_m); __pyx_m = 0;
 
4048
  } else if (!PyErr_Occurred()) {
 
4049
    PyErr_SetString(PyExc_ImportError, "init cogent.maths._period");
 
4050
  }
 
4051
  __pyx_L0:;
 
4052
  __Pyx_RefNannyFinishContext();
 
4053
  #if PY_MAJOR_VERSION < 3
 
4054
  return;
 
4055
  #else
 
4056
  return __pyx_m;
 
4057
  #endif
 
4058
}
 
4059
 
 
4060
static const char *__pyx_filenames[] = {
 
4061
  "_period.pyx",
 
4062
  "numpy.pxd",
 
4063
};
 
4064
 
 
4065
/* Runtime support code */
 
4066
 
 
4067
static void __pyx_init_filenames(void) {
 
4068
  __pyx_f = __pyx_filenames;
 
4069
}
 
4070
 
 
4071
static void __Pyx_RaiseDoubleKeywordsError(
 
4072
    const char* func_name,
 
4073
    PyObject* kw_name)
 
4074
{
 
4075
    PyErr_Format(PyExc_TypeError,
 
4076
        #if PY_MAJOR_VERSION >= 3
 
4077
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
 
4078
        #else
 
4079
        "%s() got multiple values for keyword argument '%s'", func_name,
 
4080
        PyString_AS_STRING(kw_name));
 
4081
        #endif
 
4082
}
 
4083
 
 
4084
static void __Pyx_RaiseArgtupleInvalid(
 
4085
    const char* func_name,
 
4086
    int exact,
 
4087
    Py_ssize_t num_min,
 
4088
    Py_ssize_t num_max,
 
4089
    Py_ssize_t num_found)
 
4090
{
 
4091
    Py_ssize_t num_expected;
 
4092
    const char *number, *more_or_less;
 
4093
 
 
4094
    if (num_found < num_min) {
 
4095
        num_expected = num_min;
 
4096
        more_or_less = "at least";
 
4097
    } else {
 
4098
        num_expected = num_max;
 
4099
        more_or_less = "at most";
 
4100
    }
 
4101
    if (exact) {
 
4102
        more_or_less = "exactly";
 
4103
    }
 
4104
    number = (num_expected == 1) ? "" : "s";
 
4105
    PyErr_Format(PyExc_TypeError,
 
4106
        #if PY_VERSION_HEX < 0x02050000
 
4107
            "%s() takes %s %d positional argument%s (%d given)",
 
4108
        #else
 
4109
            "%s() takes %s %zd positional argument%s (%zd given)",
 
4110
        #endif
 
4111
        func_name, more_or_less, num_expected, number, num_found);
 
4112
}
 
4113
 
 
4114
static int __Pyx_ParseOptionalKeywords(
 
4115
    PyObject *kwds,
 
4116
    PyObject **argnames[],
 
4117
    PyObject *kwds2,
 
4118
    PyObject *values[],
 
4119
    Py_ssize_t num_pos_args,
 
4120
    const char* function_name)
 
4121
{
 
4122
    PyObject *key = 0, *value = 0;
 
4123
    Py_ssize_t pos = 0;
 
4124
    PyObject*** name;
 
4125
    PyObject*** first_kw_arg = argnames + num_pos_args;
 
4126
 
 
4127
    while (PyDict_Next(kwds, &pos, &key, &value)) {
 
4128
        name = first_kw_arg;
 
4129
        while (*name && (**name != key)) name++;
 
4130
        if (*name) {
 
4131
            values[name-argnames] = value;
 
4132
        } else {
 
4133
            #if PY_MAJOR_VERSION < 3
 
4134
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
 
4135
            #else
 
4136
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
 
4137
            #endif
 
4138
                goto invalid_keyword_type;
 
4139
            } else {
 
4140
                for (name = first_kw_arg; *name; name++) {
 
4141
                    #if PY_MAJOR_VERSION >= 3
 
4142
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
 
4143
                        PyUnicode_Compare(**name, key) == 0) break;
 
4144
                    #else
 
4145
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
 
4146
                        _PyString_Eq(**name, key)) break;
 
4147
                    #endif
 
4148
                }
 
4149
                if (*name) {
 
4150
                    values[name-argnames] = value;
 
4151
                } else {
 
4152
                    /* unexpected keyword found */
 
4153
                    for (name=argnames; name != first_kw_arg; name++) {
 
4154
                        if (**name == key) goto arg_passed_twice;
 
4155
                        #if PY_MAJOR_VERSION >= 3
 
4156
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
 
4157
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
 
4158
                        #else
 
4159
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
 
4160
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
 
4161
                        #endif
 
4162
                    }
 
4163
                    if (kwds2) {
 
4164
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
 
4165
                    } else {
 
4166
                        goto invalid_keyword;
 
4167
                    }
 
4168
                }
 
4169
            }
 
4170
        }
 
4171
    }
 
4172
    return 0;
 
4173
arg_passed_twice:
 
4174
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
 
4175
    goto bad;
 
4176
invalid_keyword_type:
 
4177
    PyErr_Format(PyExc_TypeError,
 
4178
        "%s() keywords must be strings", function_name);
 
4179
    goto bad;
 
4180
invalid_keyword:
 
4181
    PyErr_Format(PyExc_TypeError,
 
4182
    #if PY_MAJOR_VERSION < 3
 
4183
        "%s() got an unexpected keyword argument '%s'",
 
4184
        function_name, PyString_AsString(key));
 
4185
    #else
 
4186
        "%s() got an unexpected keyword argument '%U'",
 
4187
        function_name, key);
 
4188
    #endif
 
4189
bad:
 
4190
    return -1;
 
4191
}
 
4192
 
 
4193
static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
 
4194
  unsigned int n = 1;
 
4195
  return *(unsigned char*)(&n) != 0;
 
4196
}
 
4197
 
 
4198
typedef struct {
 
4199
  __Pyx_StructField root;
 
4200
  __Pyx_BufFmt_StackElem* head;
 
4201
  size_t fmt_offset;
 
4202
  int new_count, enc_count;
 
4203
  int is_complex;
 
4204
  char enc_type;
 
4205
  char packmode;
 
4206
} __Pyx_BufFmt_Context;
 
4207
 
 
4208
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
 
4209
                              __Pyx_BufFmt_StackElem* stack,
 
4210
                              __Pyx_TypeInfo* type) {
 
4211
  stack[0].field = &ctx->root;
 
4212
  stack[0].parent_offset = 0;
 
4213
  ctx->root.type = type;
 
4214
  ctx->root.name = "buffer dtype";
 
4215
  ctx->root.offset = 0;
 
4216
  ctx->head = stack;
 
4217
  ctx->head->field = &ctx->root;
 
4218
  ctx->fmt_offset = 0;
 
4219
  ctx->head->parent_offset = 0;
 
4220
  ctx->packmode = '@';
 
4221
  ctx->new_count = 1;
 
4222
  ctx->enc_count = 0;
 
4223
  ctx->enc_type = 0;
 
4224
  ctx->is_complex = 0;
 
4225
  while (type->typegroup == 'S') {
 
4226
    ++ctx->head;
 
4227
    ctx->head->field = type->fields;
 
4228
    ctx->head->parent_offset = 0;
 
4229
    type = type->fields->type;
 
4230
  }
 
4231
}
 
4232
 
 
4233
static int __Pyx_BufFmt_ParseNumber(const char** ts) {
 
4234
    int count;
 
4235
    const char* t = *ts;
 
4236
    if (*t < '0' || *t > '9') {
 
4237
      return -1;
 
4238
    } else {
 
4239
        count = *t++ - '0';
 
4240
        while (*t >= '0' && *t < '9') {
 
4241
            count *= 10;
 
4242
            count += *t++ - '0';
 
4243
        }
 
4244
    }
 
4245
    *ts = t;
 
4246
    return count;
 
4247
}
 
4248
 
 
4249
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
 
4250
  char msg[] = {ch, 0};
 
4251
  PyErr_Format(PyExc_ValueError, "Unexpected format string character: '%s'", msg);
 
4252
}
 
4253
 
 
4254
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
 
4255
  switch (ch) {
 
4256
    case 'b': return "'char'";
 
4257
    case 'B': return "'unsigned char'";
 
4258
    case 'h': return "'short'";
 
4259
    case 'H': return "'unsigned short'";
 
4260
    case 'i': return "'int'";
 
4261
    case 'I': return "'unsigned int'";
 
4262
    case 'l': return "'long'";
 
4263
    case 'L': return "'unsigned long'";
 
4264
    case 'q': return "'long long'";
 
4265
    case 'Q': return "'unsigned long long'";
 
4266
    case 'f': return (is_complex ? "'complex float'" : "'float'");
 
4267
    case 'd': return (is_complex ? "'complex double'" : "'double'");
 
4268
    case 'g': return (is_complex ? "'complex long double'" : "'long double'");
 
4269
    case 'T': return "a struct";
 
4270
    case 'O': return "Python object";
 
4271
    case 'P': return "a pointer";
 
4272
    case 0: return "end";
 
4273
    default: return "unparseable format string";
 
4274
  }
 
4275
}
 
4276
 
 
4277
static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
 
4278
  switch (ch) {
 
4279
    case '?': case 'c': case 'b': case 'B': return 1;
 
4280
    case 'h': case 'H': return 2;
 
4281
    case 'i': case 'I': case 'l': case 'L': return 4;
 
4282
    case 'q': case 'Q': return 8;
 
4283
    case 'f': return (is_complex ? 8 : 4);
 
4284
    case 'd': return (is_complex ? 16 : 8);
 
4285
    case 'g': {
 
4286
      PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
 
4287
      return 0;
 
4288
    }
 
4289
    case 'O': case 'P': return sizeof(void*);
 
4290
    default:
 
4291
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
 
4292
      return 0;
 
4293
    }
 
4294
}
 
4295
 
 
4296
static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
 
4297
  switch (ch) {
 
4298
    case 'c': case 'b': case 'B': return 1;
 
4299
    case 'h': case 'H': return sizeof(short);
 
4300
    case 'i': case 'I': return sizeof(int);
 
4301
    case 'l': case 'L': return sizeof(long);
 
4302
    #ifdef HAVE_LONG_LONG
 
4303
    case 'q': case 'Q': return sizeof(PY_LONG_LONG);
 
4304
    #endif
 
4305
    case 'f': return sizeof(float) * (is_complex ? 2 : 1);
 
4306
    case 'd': return sizeof(double) * (is_complex ? 2 : 1);
 
4307
    case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
 
4308
    case 'O': case 'P': return sizeof(void*);
 
4309
    default: {
 
4310
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
 
4311
      return 0;
 
4312
    }    
 
4313
  }
 
4314
}
 
4315
 
 
4316
typedef struct { char c; short x; } __Pyx_st_short;
 
4317
typedef struct { char c; int x; } __Pyx_st_int;
 
4318
typedef struct { char c; long x; } __Pyx_st_long;
 
4319
typedef struct { char c; float x; } __Pyx_st_float;
 
4320
typedef struct { char c; double x; } __Pyx_st_double;
 
4321
typedef struct { char c; long double x; } __Pyx_st_longdouble;
 
4322
typedef struct { char c; void *x; } __Pyx_st_void_p;
 
4323
#ifdef HAVE_LONG_LONG
 
4324
typedef struct { char c; PY_LONG_LONG x; } __Pyx_s_long_long;
 
4325
#endif
 
4326
 
 
4327
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, int is_complex) {
 
4328
  switch (ch) {
 
4329
    case '?': case 'c': case 'b': case 'B': return 1;
 
4330
    case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
 
4331
    case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
 
4332
    case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
 
4333
#ifdef HAVE_LONG_LONG
 
4334
    case 'q': case 'Q': return sizeof(__Pyx_s_long_long) - sizeof(PY_LONG_LONG);
 
4335
#endif
 
4336
    case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
 
4337
    case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
 
4338
    case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
 
4339
    case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
 
4340
    default:
 
4341
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
 
4342
      return 0;
 
4343
    }
 
4344
}
 
4345
 
 
4346
static size_t __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
 
4347
  switch (ch) {
 
4348
    case 'c': case 'b': case 'h': case 'i': case 'l': case 'q': return 'I';
 
4349
    case 'B': case 'H': case 'I': case 'L': case 'Q': return 'U';
 
4350
    case 'f': case 'd': case 'g': return (is_complex ? 'C' : 'R');
 
4351
    case 'O': return 'O';
 
4352
    case 'P': return 'P';
 
4353
    default: {
 
4354
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
 
4355
      return 0;
 
4356
    }    
 
4357
  }
 
4358
}
 
4359
 
 
4360
static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
 
4361
  if (ctx->head == NULL || ctx->head->field == &ctx->root) {
 
4362
    const char* expected;
 
4363
    const char* quote;
 
4364
    if (ctx->head == NULL) {
 
4365
      expected = "end";
 
4366
      quote = "";
 
4367
    } else {
 
4368
      expected = ctx->head->field->type->name;
 
4369
      quote = "'";
 
4370
    }
 
4371
    PyErr_Format(PyExc_ValueError,
 
4372
                 "Buffer dtype mismatch, expected %s%s%s but got %s",
 
4373
                 quote, expected, quote,
 
4374
                 __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
 
4375
  } else {
 
4376
    __Pyx_StructField* field = ctx->head->field;
 
4377
    __Pyx_StructField* parent = (ctx->head - 1)->field;
 
4378
    PyErr_Format(PyExc_ValueError,
 
4379
                 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
 
4380
                 field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
 
4381
                 parent->type->name, field->name);
 
4382
  }
 
4383
}
 
4384
 
 
4385
static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
 
4386
  char group;
 
4387
  size_t size, offset;
 
4388
  if (ctx->enc_type == 0) return 0;
 
4389
  group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
 
4390
  do {
 
4391
    __Pyx_StructField* field = ctx->head->field;
 
4392
    __Pyx_TypeInfo* type = field->type;
 
4393
  
 
4394
    if (ctx->packmode == '@' || ctx->packmode == '^') {
 
4395
      size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
 
4396
    } else {
 
4397
      size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
 
4398
    }
 
4399
    if (ctx->packmode == '@') {
 
4400
      int align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
 
4401
      int align_mod_offset;
 
4402
      if (align_at == 0) return -1;
 
4403
      align_mod_offset = ctx->fmt_offset % align_at;
 
4404
      if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
 
4405
    }
 
4406
 
 
4407
    if (type->size != size || type->typegroup != group) {
 
4408
      if (type->typegroup == 'C' && type->fields != NULL) {
 
4409
        /* special case -- treat as struct rather than complex number */
 
4410
        size_t parent_offset = ctx->head->parent_offset + field->offset;
 
4411
        ++ctx->head;
 
4412
        ctx->head->field = type->fields;
 
4413
        ctx->head->parent_offset = parent_offset;
 
4414
        continue;
 
4415
      }
 
4416
    
 
4417
      __Pyx_BufFmt_RaiseExpected(ctx);
 
4418
      return -1;
 
4419
    }
 
4420
 
 
4421
    offset = ctx->head->parent_offset + field->offset;
 
4422
    if (ctx->fmt_offset != offset) {
 
4423
      PyErr_Format(PyExc_ValueError,
 
4424
                   "Buffer dtype mismatch; next field is at offset %"PY_FORMAT_SIZE_T"d "
 
4425
                   "but %"PY_FORMAT_SIZE_T"d expected", ctx->fmt_offset, offset);
 
4426
      return -1;
 
4427
    }
 
4428
 
 
4429
    ctx->fmt_offset += size;
 
4430
  
 
4431
    --ctx->enc_count; /* Consume from buffer string */
 
4432
 
 
4433
    /* Done checking, move to next field, pushing or popping struct stack if needed */
 
4434
    while (1) {
 
4435
      if (field == &ctx->root) {
 
4436
        ctx->head = NULL;
 
4437
        if (ctx->enc_count != 0) {
 
4438
          __Pyx_BufFmt_RaiseExpected(ctx);
 
4439
          return -1;
 
4440
        }
 
4441
        break; /* breaks both loops as ctx->enc_count == 0 */
 
4442
      }
 
4443
      ctx->head->field = ++field;
 
4444
      if (field->type == NULL) {
 
4445
        --ctx->head;
 
4446
        field = ctx->head->field;
 
4447
        continue;
 
4448
      } else if (field->type->typegroup == 'S') {
 
4449
        size_t parent_offset = ctx->head->parent_offset + field->offset;
 
4450
        if (field->type->fields->type == NULL) continue; /* empty struct */
 
4451
        field = field->type->fields;
 
4452
        ++ctx->head;
 
4453
        ctx->head->field = field;
 
4454
        ctx->head->parent_offset = parent_offset;
 
4455
        break;
 
4456
      } else {
 
4457
        break;
 
4458
      }
 
4459
    }
 
4460
  } while (ctx->enc_count);
 
4461
  ctx->enc_type = 0;
 
4462
  ctx->is_complex = 0;
 
4463
  return 0;    
 
4464
}
 
4465
 
 
4466
static int __Pyx_BufFmt_FirstPack(__Pyx_BufFmt_Context* ctx) {
 
4467
  if (ctx->enc_type != 0 || ctx->packmode != '@') {
 
4468
    PyErr_SetString(PyExc_ValueError, "Buffer packing mode currently only allowed at beginning of format string (this is a defect)");
 
4469
    return -1;
 
4470
  }
 
4471
  return 0;
 
4472
}
 
4473
 
 
4474
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
 
4475
  int got_Z = 0;
 
4476
  while (1) {
 
4477
    switch(*ts) {
 
4478
      case 0:
 
4479
        if (ctx->enc_type != 0 && ctx->head == NULL) {
 
4480
          __Pyx_BufFmt_RaiseExpected(ctx);
 
4481
          return NULL;
 
4482
        }
 
4483
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
 
4484
        if (ctx->head != NULL) {
 
4485
          __Pyx_BufFmt_RaiseExpected(ctx);
 
4486
          return NULL;
 
4487
        }
 
4488
        return ts;
 
4489
      case ' ':
 
4490
      case 10:
 
4491
      case 13:
 
4492
        ++ts;
 
4493
        break;
 
4494
      case '<':
 
4495
        if (!__Pyx_IsLittleEndian()) {
 
4496
          PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
 
4497
          return NULL;
 
4498
        }
 
4499
        if (__Pyx_BufFmt_FirstPack(ctx) == -1) return NULL;
 
4500
        ctx->packmode = '=';
 
4501
        ++ts;
 
4502
        break;
 
4503
      case '>':
 
4504
      case '!':
 
4505
        if (__Pyx_IsLittleEndian()) {
 
4506
          PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
 
4507
          return NULL;
 
4508
        }
 
4509
        if (__Pyx_BufFmt_FirstPack(ctx) == -1) return NULL;
 
4510
        ctx->packmode = '=';
 
4511
        ++ts;
 
4512
        break;
 
4513
      case '=':
 
4514
      case '@':
 
4515
      case '^':
 
4516
        if (__Pyx_BufFmt_FirstPack(ctx) == -1) return NULL;
 
4517
        ctx->packmode = *ts++;
 
4518
        break;
 
4519
      case 'T': /* substruct */
 
4520
        {
 
4521
          int i;
 
4522
          const char* ts_after_sub;
 
4523
          int struct_count = ctx->new_count;
 
4524
          ctx->new_count = 1;
 
4525
          ++ts;
 
4526
          if (*ts != '{') {
 
4527
            PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
 
4528
            return NULL;
 
4529
          }
 
4530
          ++ts;
 
4531
          ts_after_sub = ts;
 
4532
          for (i = 0; i != struct_count; ++i) {
 
4533
            ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
 
4534
            if (!ts_after_sub) return NULL;
 
4535
          }
 
4536
          ts = ts_after_sub;
 
4537
        }
 
4538
        break;
 
4539
      case '}': /* end of substruct; either repeat or move on */
 
4540
        ++ts;
 
4541
        return ts;
 
4542
      case 'x':
 
4543
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
 
4544
        ctx->fmt_offset += ctx->new_count;
 
4545
        ctx->new_count = 1;
 
4546
        ctx->enc_count = 0;
 
4547
        ctx->enc_type = 0;
 
4548
        ++ts;
 
4549
        break;
 
4550
      case 'Z':
 
4551
        got_Z = 1;
 
4552
        ++ts;
 
4553
        if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
 
4554
          __Pyx_BufFmt_RaiseUnexpectedChar('Z');
 
4555
          return NULL;
 
4556
        }        /* fall through */
 
4557
      case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
 
4558
      case 'l': case 'L': case 'q': case 'Q':
 
4559
      case 'f': case 'd': case 'g':
 
4560
      case 'O':
 
4561
        if (ctx->enc_type == *ts && got_Z == ctx->is_complex) {
 
4562
          /* Continue pooling same type */
 
4563
          ctx->enc_count += ctx->new_count;
 
4564
        } else {
 
4565
          /* New type */
 
4566
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
 
4567
          ctx->enc_count = ctx->new_count;
 
4568
          ctx->enc_type = *ts;
 
4569
          ctx->is_complex = got_Z;
 
4570
        }
 
4571
        ++ts;
 
4572
        ctx->new_count = 1;
 
4573
        got_Z = 0;
 
4574
        break;
 
4575
      default:
 
4576
        {
 
4577
          ctx->new_count = __Pyx_BufFmt_ParseNumber(&ts);
 
4578
          if (ctx->new_count == -1) { /* First char was not a digit */
 
4579
            char msg[2] = { *ts, 0 };
 
4580
            PyErr_Format(PyExc_ValueError,
 
4581
                         "Does not understand character buffer dtype format string ('%s')", msg);
 
4582
            return NULL;
 
4583
          }
 
4584
        }
 
4585
      
 
4586
    }
 
4587
  }
 
4588
}
 
4589
 
 
4590
static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
 
4591
  buf->buf = NULL;
 
4592
  buf->obj = NULL;
 
4593
  buf->strides = __Pyx_zeros;
 
4594
  buf->shape = __Pyx_zeros;
 
4595
  buf->suboffsets = __Pyx_minusones;
 
4596
}
 
4597
 
 
4598
static int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack) {
 
4599
  if (obj == Py_None) {
 
4600
    __Pyx_ZeroBuffer(buf);
 
4601
    return 0;
 
4602
  }
 
4603
  buf->buf = NULL;
 
4604
  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
 
4605
  if (buf->ndim != nd) {
 
4606
    PyErr_Format(PyExc_ValueError,
 
4607
                 "Buffer has wrong number of dimensions (expected %d, got %d)",
 
4608
                 nd, buf->ndim);
 
4609
    goto fail;
 
4610
  }
 
4611
  if (!cast) {
 
4612
    __Pyx_BufFmt_Context ctx;
 
4613
    __Pyx_BufFmt_Init(&ctx, stack, dtype);
 
4614
    if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
 
4615
  }
 
4616
  if ((unsigned)buf->itemsize != dtype->size) {
 
4617
    PyErr_Format(PyExc_ValueError,
 
4618
      "Item size of buffer (%"PY_FORMAT_SIZE_T"d byte%s) does not match size of '%s' (%"PY_FORMAT_SIZE_T"d byte%s)",
 
4619
      buf->itemsize, (buf->itemsize > 1) ? "s" : "",
 
4620
      dtype->name,
 
4621
      dtype->size, (dtype->size > 1) ? "s" : "");
 
4622
    goto fail;
 
4623
  }
 
4624
  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
 
4625
  return 0;
 
4626
fail:;
 
4627
  __Pyx_ZeroBuffer(buf);
 
4628
  return -1;
 
4629
}
 
4630
 
 
4631
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
 
4632
  if (info->buf == NULL) return;
 
4633
  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
 
4634
  __Pyx_ReleaseBuffer(info);
 
4635
}
 
4636
static void __Pyx_RaiseBufferIndexError(int axis) {
 
4637
  PyErr_Format(PyExc_IndexError,
 
4638
     "Out of bounds on buffer access (axis %d)", axis);
 
4639
}
 
4640
 
 
4641
 
 
4642
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
 
4643
    PyObject *tmp_type, *tmp_value, *tmp_tb;
 
4644
    PyThreadState *tstate = PyThreadState_GET();
 
4645
 
 
4646
    tmp_type = tstate->curexc_type;
 
4647
    tmp_value = tstate->curexc_value;
 
4648
    tmp_tb = tstate->curexc_traceback;
 
4649
    tstate->curexc_type = type;
 
4650
    tstate->curexc_value = value;
 
4651
    tstate->curexc_traceback = tb;
 
4652
    Py_XDECREF(tmp_type);
 
4653
    Py_XDECREF(tmp_value);
 
4654
    Py_XDECREF(tmp_tb);
 
4655
}
 
4656
 
 
4657
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
 
4658
    PyThreadState *tstate = PyThreadState_GET();
 
4659
    *type = tstate->curexc_type;
 
4660
    *value = tstate->curexc_value;
 
4661
    *tb = tstate->curexc_traceback;
 
4662
 
 
4663
    tstate->curexc_type = 0;
 
4664
    tstate->curexc_value = 0;
 
4665
    tstate->curexc_traceback = 0;
 
4666
}
 
4667
 
 
4668
 
 
4669
 
 
4670
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
 
4671
    PyErr_Format(PyExc_ValueError,
 
4672
        #if PY_VERSION_HEX < 0x02050000
 
4673
                 "need more than %d value%s to unpack", (int)index,
 
4674
        #else
 
4675
                 "need more than %zd value%s to unpack", index,
 
4676
        #endif
 
4677
                 (index == 1) ? "" : "s");
 
4678
}
 
4679
 
 
4680
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void) {
 
4681
    PyErr_SetString(PyExc_ValueError, "too many values to unpack");
 
4682
}
 
4683
 
 
4684
static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
 
4685
    PyObject *item;
 
4686
    if (!(item = PyIter_Next(iter))) {
 
4687
        if (!PyErr_Occurred()) {
 
4688
            __Pyx_RaiseNeedMoreValuesError(index);
 
4689
        }
 
4690
    }
 
4691
    return item;
 
4692
}
 
4693
 
 
4694
static int __Pyx_EndUnpack(PyObject *iter) {
 
4695
    PyObject *item;
 
4696
    if ((item = PyIter_Next(iter))) {
 
4697
        Py_DECREF(item);
 
4698
        __Pyx_RaiseTooManyValuesError();
 
4699
        return -1;
 
4700
    }
 
4701
    else if (!PyErr_Occurred())
 
4702
        return 0;
 
4703
    else
 
4704
        return -1;
 
4705
}
 
4706
 
 
4707
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
 
4708
    if (unlikely(!type)) {
 
4709
        PyErr_Format(PyExc_SystemError, "Missing type object");
 
4710
        return 0;
 
4711
    }
 
4712
    if (likely(PyObject_TypeCheck(obj, type)))
 
4713
        return 1;
 
4714
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
 
4715
                 Py_TYPE(obj)->tp_name, type->tp_name);
 
4716
    return 0;
 
4717
}
 
4718
 
 
4719
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
 
4720
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
 
4721
}
 
4722
 
 
4723
static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
 
4724
    if (t == Py_None) {
 
4725
      __Pyx_RaiseNoneNotIterableError();
 
4726
    } else if (PyTuple_GET_SIZE(t) < index) {
 
4727
      __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
 
4728
    } else {
 
4729
      __Pyx_RaiseTooManyValuesError();
 
4730
    }
 
4731
}
 
4732
 
 
4733
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
 
4734
    const char *name, int exact)
 
4735
{
 
4736
    if (!type) {
 
4737
        PyErr_Format(PyExc_SystemError, "Missing type object");
 
4738
        return 0;
 
4739
    }
 
4740
    if (none_allowed && obj == Py_None) return 1;
 
4741
    else if (exact) {
 
4742
        if (Py_TYPE(obj) == type) return 1;
 
4743
    }
 
4744
    else {
 
4745
        if (PyObject_TypeCheck(obj, type)) return 1;
 
4746
    }
 
4747
    PyErr_Format(PyExc_TypeError,
 
4748
        "Argument '%s' has incorrect type (expected %s, got %s)",
 
4749
        name, type->tp_name, Py_TYPE(obj)->tp_name);
 
4750
    return 0;
 
4751
}
 
4752
 
 
4753
#if PY_MAJOR_VERSION < 3
 
4754
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
 
4755
  #if PY_VERSION_HEX >= 0x02060000
 
4756
  if (Py_TYPE(obj)->tp_flags & Py_TPFLAGS_HAVE_NEWBUFFER)
 
4757
      return PyObject_GetBuffer(obj, view, flags);
 
4758
  #endif
 
4759
  if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pf_5numpy_7ndarray___getbuffer__(obj, view, flags);
 
4760
  else {
 
4761
  PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
 
4762
  return -1;
 
4763
    }
 
4764
}
 
4765
 
 
4766
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
 
4767
  PyObject* obj = view->obj;
 
4768
  if (obj) {
 
4769
if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pf_5numpy_7ndarray___releasebuffer__(obj, view);
 
4770
    Py_DECREF(obj);
 
4771
    view->obj = NULL;
 
4772
  }
 
4773
}
 
4774
 
 
4775
#endif
 
4776
 
 
4777
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
 
4778
    PyObject *__import__ = 0;
 
4779
    PyObject *empty_list = 0;
 
4780
    PyObject *module = 0;
 
4781
    PyObject *global_dict = 0;
 
4782
    PyObject *empty_dict = 0;
 
4783
    PyObject *list;
 
4784
    __import__ = __Pyx_GetAttrString(__pyx_b, "__import__");
 
4785
    if (!__import__)
 
4786
        goto bad;
 
4787
    if (from_list)
 
4788
        list = from_list;
 
4789
    else {
 
4790
        empty_list = PyList_New(0);
 
4791
        if (!empty_list)
 
4792
            goto bad;
 
4793
        list = empty_list;
 
4794
    }
 
4795
    global_dict = PyModule_GetDict(__pyx_m);
 
4796
    if (!global_dict)
 
4797
        goto bad;
 
4798
    empty_dict = PyDict_New();
 
4799
    if (!empty_dict)
 
4800
        goto bad;
 
4801
    module = PyObject_CallFunctionObjArgs(__import__,
 
4802
        name, global_dict, empty_dict, list, NULL);
 
4803
bad:
 
4804
    Py_XDECREF(empty_list);
 
4805
    Py_XDECREF(__import__);
 
4806
    Py_XDECREF(empty_dict);
 
4807
    return module;
 
4808
}
 
4809
 
 
4810
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
 
4811
    PyObject *result;
 
4812
    result = PyObject_GetAttr(dict, name);
 
4813
    if (!result)
 
4814
        PyErr_SetObject(PyExc_NameError, name);
 
4815
    return result;
 
4816
}
 
4817
 
 
4818
#if CYTHON_CCOMPLEX
 
4819
  #ifdef __cplusplus
 
4820
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
 
4821
      return ::std::complex< double >(x, y);
 
4822
    }
 
4823
  #else
 
4824
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
 
4825
      return x + y*(__pyx_t_double_complex)_Complex_I;
 
4826
    }
 
4827
  #endif
 
4828
#else
 
4829
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
 
4830
      __pyx_t_double_complex z;
 
4831
      z.real = x;
 
4832
      z.imag = y;
 
4833
      return z;
 
4834
    }
 
4835
#endif
 
4836
 
 
4837
#if CYTHON_CCOMPLEX
 
4838
#else
 
4839
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) {
 
4840
       return (a.real == b.real) && (a.imag == b.imag);
 
4841
    }
 
4842
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) {
 
4843
        __pyx_t_double_complex z;
 
4844
        z.real = a.real + b.real;
 
4845
        z.imag = a.imag + b.imag;
 
4846
        return z;
 
4847
    }
 
4848
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) {
 
4849
        __pyx_t_double_complex z;
 
4850
        z.real = a.real - b.real;
 
4851
        z.imag = a.imag - b.imag;
 
4852
        return z;
 
4853
    }
 
4854
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) {
 
4855
        __pyx_t_double_complex z;
 
4856
        z.real = a.real * b.real - a.imag * b.imag;
 
4857
        z.imag = a.real * b.imag + a.imag * b.real;
 
4858
        return z;
 
4859
    }
 
4860
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) {
 
4861
        __pyx_t_double_complex z;
 
4862
        double denom = b.real * b.real + b.imag * b.imag;
 
4863
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
 
4864
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
 
4865
        return z;
 
4866
    }
 
4867
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) {
 
4868
        __pyx_t_double_complex z;
 
4869
        z.real = -a.real;
 
4870
        z.imag = -a.imag;
 
4871
        return z;
 
4872
    }
 
4873
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) {
 
4874
       return (a.real == 0) && (a.imag == 0);
 
4875
    }
 
4876
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) {
 
4877
        __pyx_t_double_complex z;
 
4878
        z.real =  a.real;
 
4879
        z.imag = -a.imag;
 
4880
        return z;
 
4881
    }
 
4882
/*
 
4883
    static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) {
 
4884
#if HAVE_HYPOT
 
4885
        return hypot(z.real, z.imag);
 
4886
#else
 
4887
        return sqrt(z.real*z.real + z.imag*z.imag);
 
4888
#endif
 
4889
    }
 
4890
*/
 
4891
#endif
 
4892
 
 
4893
#if CYTHON_CCOMPLEX
 
4894
  #ifdef __cplusplus
 
4895
    static CYTHON_INLINE __pyx_t_npy_float64_complex __pyx_t_npy_float64_complex_from_parts(npy_float64 x, npy_float64 y) {
 
4896
      return ::std::complex< npy_float64 >(x, y);
 
4897
    }
 
4898
  #else
 
4899
    static CYTHON_INLINE __pyx_t_npy_float64_complex __pyx_t_npy_float64_complex_from_parts(npy_float64 x, npy_float64 y) {
 
4900
      return x + y*(__pyx_t_npy_float64_complex)_Complex_I;
 
4901
    }
 
4902
  #endif
 
4903
#else
 
4904
    static CYTHON_INLINE __pyx_t_npy_float64_complex __pyx_t_npy_float64_complex_from_parts(npy_float64 x, npy_float64 y) {
 
4905
      __pyx_t_npy_float64_complex z;
 
4906
      z.real = x;
 
4907
      z.imag = y;
 
4908
      return z;
 
4909
    }
 
4910
#endif
 
4911
 
 
4912
#if CYTHON_CCOMPLEX
 
4913
#else
 
4914
    static CYTHON_INLINE int __Pyx_c_eq_npy_float64(__pyx_t_npy_float64_complex a, __pyx_t_npy_float64_complex b) {
 
4915
       return (a.real == b.real) && (a.imag == b.imag);
 
4916
    }
 
4917
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_sum_npy_float64(__pyx_t_npy_float64_complex a, __pyx_t_npy_float64_complex b) {
 
4918
        __pyx_t_npy_float64_complex z;
 
4919
        z.real = a.real + b.real;
 
4920
        z.imag = a.imag + b.imag;
 
4921
        return z;
 
4922
    }
 
4923
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_diff_npy_float64(__pyx_t_npy_float64_complex a, __pyx_t_npy_float64_complex b) {
 
4924
        __pyx_t_npy_float64_complex z;
 
4925
        z.real = a.real - b.real;
 
4926
        z.imag = a.imag - b.imag;
 
4927
        return z;
 
4928
    }
 
4929
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_prod_npy_float64(__pyx_t_npy_float64_complex a, __pyx_t_npy_float64_complex b) {
 
4930
        __pyx_t_npy_float64_complex z;
 
4931
        z.real = a.real * b.real - a.imag * b.imag;
 
4932
        z.imag = a.real * b.imag + a.imag * b.real;
 
4933
        return z;
 
4934
    }
 
4935
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_quot_npy_float64(__pyx_t_npy_float64_complex a, __pyx_t_npy_float64_complex b) {
 
4936
        __pyx_t_npy_float64_complex z;
 
4937
        npy_float64 denom = b.real * b.real + b.imag * b.imag;
 
4938
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
 
4939
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
 
4940
        return z;
 
4941
    }
 
4942
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_neg_npy_float64(__pyx_t_npy_float64_complex a) {
 
4943
        __pyx_t_npy_float64_complex z;
 
4944
        z.real = -a.real;
 
4945
        z.imag = -a.imag;
 
4946
        return z;
 
4947
    }
 
4948
    static CYTHON_INLINE int __Pyx_c_is_zero_npy_float64(__pyx_t_npy_float64_complex a) {
 
4949
       return (a.real == 0) && (a.imag == 0);
 
4950
    }
 
4951
    static CYTHON_INLINE __pyx_t_npy_float64_complex __Pyx_c_conj_npy_float64(__pyx_t_npy_float64_complex a) {
 
4952
        __pyx_t_npy_float64_complex z;
 
4953
        z.real =  a.real;
 
4954
        z.imag = -a.imag;
 
4955
        return z;
 
4956
    }
 
4957
/*
 
4958
    static CYTHON_INLINE npy_float64 __Pyx_c_abs_npy_float64(__pyx_t_npy_float64_complex z) {
 
4959
#if HAVE_HYPOT
 
4960
        return hypot_npy_float64(z.real, z.imag);
 
4961
#else
 
4962
        return sqrt_npy_float64(z.real*z.real + z.imag*z.imag);
 
4963
#endif
 
4964
    }
 
4965
*/
 
4966
#endif
 
4967
 
 
4968
#if CYTHON_CCOMPLEX
 
4969
  #ifdef __cplusplus
 
4970
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
 
4971
      return ::std::complex< float >(x, y);
 
4972
    }
 
4973
  #else
 
4974
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
 
4975
      return x + y*(__pyx_t_float_complex)_Complex_I;
 
4976
    }
 
4977
  #endif
 
4978
#else
 
4979
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
 
4980
      __pyx_t_float_complex z;
 
4981
      z.real = x;
 
4982
      z.imag = y;
 
4983
      return z;
 
4984
    }
 
4985
#endif
 
4986
 
 
4987
#if CYTHON_CCOMPLEX
 
4988
#else
 
4989
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
 
4990
       return (a.real == b.real) && (a.imag == b.imag);
 
4991
    }
 
4992
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
 
4993
        __pyx_t_float_complex z;
 
4994
        z.real = a.real + b.real;
 
4995
        z.imag = a.imag + b.imag;
 
4996
        return z;
 
4997
    }
 
4998
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) {
 
4999
        __pyx_t_float_complex z;
 
5000
        z.real = a.real - b.real;
 
5001
        z.imag = a.imag - b.imag;
 
5002
        return z;
 
5003
    }
 
5004
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
 
5005
        __pyx_t_float_complex z;
 
5006
        z.real = a.real * b.real - a.imag * b.imag;
 
5007
        z.imag = a.real * b.imag + a.imag * b.real;
 
5008
        return z;
 
5009
    }
 
5010
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
 
5011
        __pyx_t_float_complex z;
 
5012
        float denom = b.real * b.real + b.imag * b.imag;
 
5013
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
 
5014
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
 
5015
        return z;
 
5016
    }
 
5017
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) {
 
5018
        __pyx_t_float_complex z;
 
5019
        z.real = -a.real;
 
5020
        z.imag = -a.imag;
 
5021
        return z;
 
5022
    }
 
5023
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) {
 
5024
       return (a.real == 0) && (a.imag == 0);
 
5025
    }
 
5026
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) {
 
5027
        __pyx_t_float_complex z;
 
5028
        z.real =  a.real;
 
5029
        z.imag = -a.imag;
 
5030
        return z;
 
5031
    }
 
5032
/*
 
5033
    static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) {
 
5034
#if HAVE_HYPOT
 
5035
        return hypotf(z.real, z.imag);
 
5036
#else
 
5037
        return sqrtf(z.real*z.real + z.imag*z.imag);
 
5038
#endif
 
5039
    }
 
5040
*/
 
5041
#endif
 
5042
 
 
5043
#if PY_MAJOR_VERSION < 3
 
5044
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
 
5045
    Py_XINCREF(type);
 
5046
    Py_XINCREF(value);
 
5047
    Py_XINCREF(tb);
 
5048
    /* First, check the traceback argument, replacing None with NULL. */
 
5049
    if (tb == Py_None) {
 
5050
        Py_DECREF(tb);
 
5051
        tb = 0;
 
5052
    }
 
5053
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
 
5054
        PyErr_SetString(PyExc_TypeError,
 
5055
            "raise: arg 3 must be a traceback or None");
 
5056
        goto raise_error;
 
5057
    }
 
5058
    /* Next, replace a missing value with None */
 
5059
    if (value == NULL) {
 
5060
        value = Py_None;
 
5061
        Py_INCREF(value);
 
5062
    }
 
5063
    #if PY_VERSION_HEX < 0x02050000
 
5064
    if (!PyClass_Check(type))
 
5065
    #else
 
5066
    if (!PyType_Check(type))
 
5067
    #endif
 
5068
    {
 
5069
        /* Raising an instance.  The value should be a dummy. */
 
5070
        if (value != Py_None) {
 
5071
            PyErr_SetString(PyExc_TypeError,
 
5072
                "instance exception may not have a separate value");
 
5073
            goto raise_error;
 
5074
        }
 
5075
        /* Normalize to raise <class>, <instance> */
 
5076
        Py_DECREF(value);
 
5077
        value = type;
 
5078
        #if PY_VERSION_HEX < 0x02050000
 
5079
            if (PyInstance_Check(type)) {
 
5080
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
 
5081
                Py_INCREF(type);
 
5082
            }
 
5083
            else {
 
5084
                type = 0;
 
5085
                PyErr_SetString(PyExc_TypeError,
 
5086
                    "raise: exception must be an old-style class or instance");
 
5087
                goto raise_error;
 
5088
            }
 
5089
        #else
 
5090
            type = (PyObject*) Py_TYPE(type);
 
5091
            Py_INCREF(type);
 
5092
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
 
5093
                PyErr_SetString(PyExc_TypeError,
 
5094
                    "raise: exception class must be a subclass of BaseException");
 
5095
                goto raise_error;
 
5096
            }
 
5097
        #endif
 
5098
    }
 
5099
 
 
5100
    __Pyx_ErrRestore(type, value, tb);
 
5101
    return;
 
5102
raise_error:
 
5103
    Py_XDECREF(value);
 
5104
    Py_XDECREF(type);
 
5105
    Py_XDECREF(tb);
 
5106
    return;
 
5107
}
 
5108
 
 
5109
#else /* Python 3+ */
 
5110
 
 
5111
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
 
5112
    if (tb == Py_None) {
 
5113
        tb = 0;
 
5114
    } else if (tb && !PyTraceBack_Check(tb)) {
 
5115
        PyErr_SetString(PyExc_TypeError,
 
5116
            "raise: arg 3 must be a traceback or None");
 
5117
        goto bad;
 
5118
    }
 
5119
    if (value == Py_None)
 
5120
        value = 0;
 
5121
 
 
5122
    if (PyExceptionInstance_Check(type)) {
 
5123
        if (value) {
 
5124
            PyErr_SetString(PyExc_TypeError,
 
5125
                "instance exception may not have a separate value");
 
5126
            goto bad;
 
5127
        }
 
5128
        value = type;
 
5129
        type = (PyObject*) Py_TYPE(value);
 
5130
    } else if (!PyExceptionClass_Check(type)) {
 
5131
        PyErr_SetString(PyExc_TypeError,
 
5132
            "raise: exception class must be a subclass of BaseException");
 
5133
        goto bad;
 
5134
    }
 
5135
 
 
5136
    PyErr_SetObject(type, value);
 
5137
 
 
5138
    if (tb) {
 
5139
        PyThreadState *tstate = PyThreadState_GET();
 
5140
        PyObject* tmp_tb = tstate->curexc_traceback;
 
5141
        if (tb != tmp_tb) {
 
5142
            Py_INCREF(tb);
 
5143
            tstate->curexc_traceback = tb;
 
5144
            Py_XDECREF(tmp_tb);
 
5145
        }
 
5146
    }
 
5147
 
 
5148
bad:
 
5149
    return;
 
5150
}
 
5151
#endif
 
5152
 
 
5153
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
 
5154
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
 
5155
    const int is_unsigned = neg_one > const_zero;
 
5156
    if (sizeof(unsigned char) < sizeof(long)) {
 
5157
        long val = __Pyx_PyInt_AsLong(x);
 
5158
        if (unlikely(val != (long)(unsigned char)val)) {
 
5159
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
5160
                PyErr_SetString(PyExc_OverflowError,
 
5161
                    (is_unsigned && unlikely(val < 0)) ?
 
5162
                    "can't convert negative value to unsigned char" :
 
5163
                    "value too large to convert to unsigned char");
 
5164
            }
 
5165
            return (unsigned char)-1;
 
5166
        }
 
5167
        return (unsigned char)val;
 
5168
    }
 
5169
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
 
5170
}
 
5171
 
 
5172
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
 
5173
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
 
5174
    const int is_unsigned = neg_one > const_zero;
 
5175
    if (sizeof(unsigned short) < sizeof(long)) {
 
5176
        long val = __Pyx_PyInt_AsLong(x);
 
5177
        if (unlikely(val != (long)(unsigned short)val)) {
 
5178
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
5179
                PyErr_SetString(PyExc_OverflowError,
 
5180
                    (is_unsigned && unlikely(val < 0)) ?
 
5181
                    "can't convert negative value to unsigned short" :
 
5182
                    "value too large to convert to unsigned short");
 
5183
            }
 
5184
            return (unsigned short)-1;
 
5185
        }
 
5186
        return (unsigned short)val;
 
5187
    }
 
5188
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
 
5189
}
 
5190
 
 
5191
static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
 
5192
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
 
5193
    const int is_unsigned = neg_one > const_zero;
 
5194
    if (sizeof(unsigned int) < sizeof(long)) {
 
5195
        long val = __Pyx_PyInt_AsLong(x);
 
5196
        if (unlikely(val != (long)(unsigned int)val)) {
 
5197
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
5198
                PyErr_SetString(PyExc_OverflowError,
 
5199
                    (is_unsigned && unlikely(val < 0)) ?
 
5200
                    "can't convert negative value to unsigned int" :
 
5201
                    "value too large to convert to unsigned int");
 
5202
            }
 
5203
            return (unsigned int)-1;
 
5204
        }
 
5205
        return (unsigned int)val;
 
5206
    }
 
5207
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
 
5208
}
 
5209
 
 
5210
static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
 
5211
    const char neg_one = (char)-1, const_zero = 0;
 
5212
    const int is_unsigned = neg_one > const_zero;
 
5213
    if (sizeof(char) < sizeof(long)) {
 
5214
        long val = __Pyx_PyInt_AsLong(x);
 
5215
        if (unlikely(val != (long)(char)val)) {
 
5216
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
5217
                PyErr_SetString(PyExc_OverflowError,
 
5218
                    (is_unsigned && unlikely(val < 0)) ?
 
5219
                    "can't convert negative value to char" :
 
5220
                    "value too large to convert to char");
 
5221
            }
 
5222
            return (char)-1;
 
5223
        }
 
5224
        return (char)val;
 
5225
    }
 
5226
    return (char)__Pyx_PyInt_AsLong(x);
 
5227
}
 
5228
 
 
5229
static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
 
5230
    const short neg_one = (short)-1, const_zero = 0;
 
5231
    const int is_unsigned = neg_one > const_zero;
 
5232
    if (sizeof(short) < sizeof(long)) {
 
5233
        long val = __Pyx_PyInt_AsLong(x);
 
5234
        if (unlikely(val != (long)(short)val)) {
 
5235
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
5236
                PyErr_SetString(PyExc_OverflowError,
 
5237
                    (is_unsigned && unlikely(val < 0)) ?
 
5238
                    "can't convert negative value to short" :
 
5239
                    "value too large to convert to short");
 
5240
            }
 
5241
            return (short)-1;
 
5242
        }
 
5243
        return (short)val;
 
5244
    }
 
5245
    return (short)__Pyx_PyInt_AsLong(x);
 
5246
}
 
5247
 
 
5248
static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
 
5249
    const int neg_one = (int)-1, const_zero = 0;
 
5250
    const int is_unsigned = neg_one > const_zero;
 
5251
    if (sizeof(int) < sizeof(long)) {
 
5252
        long val = __Pyx_PyInt_AsLong(x);
 
5253
        if (unlikely(val != (long)(int)val)) {
 
5254
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
5255
                PyErr_SetString(PyExc_OverflowError,
 
5256
                    (is_unsigned && unlikely(val < 0)) ?
 
5257
                    "can't convert negative value to int" :
 
5258
                    "value too large to convert to int");
 
5259
            }
 
5260
            return (int)-1;
 
5261
        }
 
5262
        return (int)val;
 
5263
    }
 
5264
    return (int)__Pyx_PyInt_AsLong(x);
 
5265
}
 
5266
 
 
5267
static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
 
5268
    const signed char neg_one = (signed char)-1, const_zero = 0;
 
5269
    const int is_unsigned = neg_one > const_zero;
 
5270
    if (sizeof(signed char) < sizeof(long)) {
 
5271
        long val = __Pyx_PyInt_AsLong(x);
 
5272
        if (unlikely(val != (long)(signed char)val)) {
 
5273
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
5274
                PyErr_SetString(PyExc_OverflowError,
 
5275
                    (is_unsigned && unlikely(val < 0)) ?
 
5276
                    "can't convert negative value to signed char" :
 
5277
                    "value too large to convert to signed char");
 
5278
            }
 
5279
            return (signed char)-1;
 
5280
        }
 
5281
        return (signed char)val;
 
5282
    }
 
5283
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
 
5284
}
 
5285
 
 
5286
static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
 
5287
    const signed short neg_one = (signed short)-1, const_zero = 0;
 
5288
    const int is_unsigned = neg_one > const_zero;
 
5289
    if (sizeof(signed short) < sizeof(long)) {
 
5290
        long val = __Pyx_PyInt_AsLong(x);
 
5291
        if (unlikely(val != (long)(signed short)val)) {
 
5292
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
5293
                PyErr_SetString(PyExc_OverflowError,
 
5294
                    (is_unsigned && unlikely(val < 0)) ?
 
5295
                    "can't convert negative value to signed short" :
 
5296
                    "value too large to convert to signed short");
 
5297
            }
 
5298
            return (signed short)-1;
 
5299
        }
 
5300
        return (signed short)val;
 
5301
    }
 
5302
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
 
5303
}
 
5304
 
 
5305
static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
 
5306
    const signed int neg_one = (signed int)-1, const_zero = 0;
 
5307
    const int is_unsigned = neg_one > const_zero;
 
5308
    if (sizeof(signed int) < sizeof(long)) {
 
5309
        long val = __Pyx_PyInt_AsLong(x);
 
5310
        if (unlikely(val != (long)(signed int)val)) {
 
5311
            if (!unlikely(val == -1 && PyErr_Occurred())) {
 
5312
                PyErr_SetString(PyExc_OverflowError,
 
5313
                    (is_unsigned && unlikely(val < 0)) ?
 
5314
                    "can't convert negative value to signed int" :
 
5315
                    "value too large to convert to signed int");
 
5316
            }
 
5317
            return (signed int)-1;
 
5318
        }
 
5319
        return (signed int)val;
 
5320
    }
 
5321
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
 
5322
}
 
5323
 
 
5324
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
 
5325
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
 
5326
    const int is_unsigned = neg_one > const_zero;
 
5327
#if PY_VERSION_HEX < 0x03000000
 
5328
    if (likely(PyInt_Check(x))) {
 
5329
        long val = PyInt_AS_LONG(x);
 
5330
        if (is_unsigned && unlikely(val < 0)) {
 
5331
            PyErr_SetString(PyExc_OverflowError,
 
5332
                            "can't convert negative value to unsigned long");
 
5333
            return (unsigned long)-1;
 
5334
        }
 
5335
        return (unsigned long)val;
 
5336
    } else
 
5337
#endif
 
5338
    if (likely(PyLong_Check(x))) {
 
5339
        if (is_unsigned) {
 
5340
            if (unlikely(Py_SIZE(x) < 0)) {
 
5341
                PyErr_SetString(PyExc_OverflowError,
 
5342
                                "can't convert negative value to unsigned long");
 
5343
                return (unsigned long)-1;
 
5344
            }
 
5345
            return PyLong_AsUnsignedLong(x);
 
5346
        } else {
 
5347
            return PyLong_AsLong(x);
 
5348
        }
 
5349
    } else {
 
5350
        unsigned long val;
 
5351
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
5352
        if (!tmp) return (unsigned long)-1;
 
5353
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
 
5354
        Py_DECREF(tmp);
 
5355
        return val;
 
5356
    }
 
5357
}
 
5358
 
 
5359
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
 
5360
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
 
5361
    const int is_unsigned = neg_one > const_zero;
 
5362
#if PY_VERSION_HEX < 0x03000000
 
5363
    if (likely(PyInt_Check(x))) {
 
5364
        long val = PyInt_AS_LONG(x);
 
5365
        if (is_unsigned && unlikely(val < 0)) {
 
5366
            PyErr_SetString(PyExc_OverflowError,
 
5367
                            "can't convert negative value to unsigned PY_LONG_LONG");
 
5368
            return (unsigned PY_LONG_LONG)-1;
 
5369
        }
 
5370
        return (unsigned PY_LONG_LONG)val;
 
5371
    } else
 
5372
#endif
 
5373
    if (likely(PyLong_Check(x))) {
 
5374
        if (is_unsigned) {
 
5375
            if (unlikely(Py_SIZE(x) < 0)) {
 
5376
                PyErr_SetString(PyExc_OverflowError,
 
5377
                                "can't convert negative value to unsigned PY_LONG_LONG");
 
5378
                return (unsigned PY_LONG_LONG)-1;
 
5379
            }
 
5380
            return PyLong_AsUnsignedLongLong(x);
 
5381
        } else {
 
5382
            return PyLong_AsLongLong(x);
 
5383
        }
 
5384
    } else {
 
5385
        unsigned PY_LONG_LONG val;
 
5386
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
5387
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
 
5388
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
 
5389
        Py_DECREF(tmp);
 
5390
        return val;
 
5391
    }
 
5392
}
 
5393
 
 
5394
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
 
5395
    const long neg_one = (long)-1, const_zero = 0;
 
5396
    const int is_unsigned = neg_one > const_zero;
 
5397
#if PY_VERSION_HEX < 0x03000000
 
5398
    if (likely(PyInt_Check(x))) {
 
5399
        long val = PyInt_AS_LONG(x);
 
5400
        if (is_unsigned && unlikely(val < 0)) {
 
5401
            PyErr_SetString(PyExc_OverflowError,
 
5402
                            "can't convert negative value to long");
 
5403
            return (long)-1;
 
5404
        }
 
5405
        return (long)val;
 
5406
    } else
 
5407
#endif
 
5408
    if (likely(PyLong_Check(x))) {
 
5409
        if (is_unsigned) {
 
5410
            if (unlikely(Py_SIZE(x) < 0)) {
 
5411
                PyErr_SetString(PyExc_OverflowError,
 
5412
                                "can't convert negative value to long");
 
5413
                return (long)-1;
 
5414
            }
 
5415
            return PyLong_AsUnsignedLong(x);
 
5416
        } else {
 
5417
            return PyLong_AsLong(x);
 
5418
        }
 
5419
    } else {
 
5420
        long val;
 
5421
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
5422
        if (!tmp) return (long)-1;
 
5423
        val = __Pyx_PyInt_AsLong(tmp);
 
5424
        Py_DECREF(tmp);
 
5425
        return val;
 
5426
    }
 
5427
}
 
5428
 
 
5429
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
 
5430
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
 
5431
    const int is_unsigned = neg_one > const_zero;
 
5432
#if PY_VERSION_HEX < 0x03000000
 
5433
    if (likely(PyInt_Check(x))) {
 
5434
        long val = PyInt_AS_LONG(x);
 
5435
        if (is_unsigned && unlikely(val < 0)) {
 
5436
            PyErr_SetString(PyExc_OverflowError,
 
5437
                            "can't convert negative value to PY_LONG_LONG");
 
5438
            return (PY_LONG_LONG)-1;
 
5439
        }
 
5440
        return (PY_LONG_LONG)val;
 
5441
    } else
 
5442
#endif
 
5443
    if (likely(PyLong_Check(x))) {
 
5444
        if (is_unsigned) {
 
5445
            if (unlikely(Py_SIZE(x) < 0)) {
 
5446
                PyErr_SetString(PyExc_OverflowError,
 
5447
                                "can't convert negative value to PY_LONG_LONG");
 
5448
                return (PY_LONG_LONG)-1;
 
5449
            }
 
5450
            return PyLong_AsUnsignedLongLong(x);
 
5451
        } else {
 
5452
            return PyLong_AsLongLong(x);
 
5453
        }
 
5454
    } else {
 
5455
        PY_LONG_LONG val;
 
5456
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
5457
        if (!tmp) return (PY_LONG_LONG)-1;
 
5458
        val = __Pyx_PyInt_AsLongLong(tmp);
 
5459
        Py_DECREF(tmp);
 
5460
        return val;
 
5461
    }
 
5462
}
 
5463
 
 
5464
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
 
5465
    const signed long neg_one = (signed long)-1, const_zero = 0;
 
5466
    const int is_unsigned = neg_one > const_zero;
 
5467
#if PY_VERSION_HEX < 0x03000000
 
5468
    if (likely(PyInt_Check(x))) {
 
5469
        long val = PyInt_AS_LONG(x);
 
5470
        if (is_unsigned && unlikely(val < 0)) {
 
5471
            PyErr_SetString(PyExc_OverflowError,
 
5472
                            "can't convert negative value to signed long");
 
5473
            return (signed long)-1;
 
5474
        }
 
5475
        return (signed long)val;
 
5476
    } else
 
5477
#endif
 
5478
    if (likely(PyLong_Check(x))) {
 
5479
        if (is_unsigned) {
 
5480
            if (unlikely(Py_SIZE(x) < 0)) {
 
5481
                PyErr_SetString(PyExc_OverflowError,
 
5482
                                "can't convert negative value to signed long");
 
5483
                return (signed long)-1;
 
5484
            }
 
5485
            return PyLong_AsUnsignedLong(x);
 
5486
        } else {
 
5487
            return PyLong_AsLong(x);
 
5488
        }
 
5489
    } else {
 
5490
        signed long val;
 
5491
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
5492
        if (!tmp) return (signed long)-1;
 
5493
        val = __Pyx_PyInt_AsSignedLong(tmp);
 
5494
        Py_DECREF(tmp);
 
5495
        return val;
 
5496
    }
 
5497
}
 
5498
 
 
5499
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
 
5500
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
 
5501
    const int is_unsigned = neg_one > const_zero;
 
5502
#if PY_VERSION_HEX < 0x03000000
 
5503
    if (likely(PyInt_Check(x))) {
 
5504
        long val = PyInt_AS_LONG(x);
 
5505
        if (is_unsigned && unlikely(val < 0)) {
 
5506
            PyErr_SetString(PyExc_OverflowError,
 
5507
                            "can't convert negative value to signed PY_LONG_LONG");
 
5508
            return (signed PY_LONG_LONG)-1;
 
5509
        }
 
5510
        return (signed PY_LONG_LONG)val;
 
5511
    } else
 
5512
#endif
 
5513
    if (likely(PyLong_Check(x))) {
 
5514
        if (is_unsigned) {
 
5515
            if (unlikely(Py_SIZE(x) < 0)) {
 
5516
                PyErr_SetString(PyExc_OverflowError,
 
5517
                                "can't convert negative value to signed PY_LONG_LONG");
 
5518
                return (signed PY_LONG_LONG)-1;
 
5519
            }
 
5520
            return PyLong_AsUnsignedLongLong(x);
 
5521
        } else {
 
5522
            return PyLong_AsLongLong(x);
 
5523
        }
 
5524
    } else {
 
5525
        signed PY_LONG_LONG val;
 
5526
        PyObject *tmp = __Pyx_PyNumber_Int(x);
 
5527
        if (!tmp) return (signed PY_LONG_LONG)-1;
 
5528
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
 
5529
        Py_DECREF(tmp);
 
5530
        return val;
 
5531
    }
 
5532
}
 
5533
 
 
5534
#ifndef __PYX_HAVE_RT_ImportType
 
5535
#define __PYX_HAVE_RT_ImportType
 
5536
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
 
5537
    long size, int strict)
 
5538
{
 
5539
    PyObject *py_module = 0;
 
5540
    PyObject *result = 0;
 
5541
    PyObject *py_name = 0;
 
5542
    char warning[200];
 
5543
 
 
5544
    py_module = __Pyx_ImportModule(module_name);
 
5545
    if (!py_module)
 
5546
        goto bad;
 
5547
    #if PY_MAJOR_VERSION < 3
 
5548
    py_name = PyString_FromString(class_name);
 
5549
    #else
 
5550
    py_name = PyUnicode_FromString(class_name);
 
5551
    #endif
 
5552
    if (!py_name)
 
5553
        goto bad;
 
5554
    result = PyObject_GetAttr(py_module, py_name);
 
5555
    Py_DECREF(py_name);
 
5556
    py_name = 0;
 
5557
    Py_DECREF(py_module);
 
5558
    py_module = 0;
 
5559
    if (!result)
 
5560
        goto bad;
 
5561
    if (!PyType_Check(result)) {
 
5562
        PyErr_Format(PyExc_TypeError, 
 
5563
            "%s.%s is not a type object",
 
5564
            module_name, class_name);
 
5565
        goto bad;
 
5566
    }
 
5567
    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
 
5568
        PyOS_snprintf(warning, sizeof(warning), 
 
5569
            "%s.%s size changed, may indicate binary incompatibility",
 
5570
            module_name, class_name);
 
5571
        PyErr_WarnEx(NULL, warning, 0);
 
5572
    }
 
5573
    else if (((PyTypeObject *)result)->tp_basicsize != size) {
 
5574
        PyErr_Format(PyExc_ValueError, 
 
5575
            "%s.%s has the wrong size, try recompiling",
 
5576
            module_name, class_name);
 
5577
        goto bad;
 
5578
    }
 
5579
    return (PyTypeObject *)result;
 
5580
bad:
 
5581
    Py_XDECREF(py_module);
 
5582
    Py_XDECREF(result);
 
5583
    return 0;
 
5584
}
 
5585
#endif
 
5586
 
 
5587
#ifndef __PYX_HAVE_RT_ImportModule
 
5588
#define __PYX_HAVE_RT_ImportModule
 
5589
static PyObject *__Pyx_ImportModule(const char *name) {
 
5590
    PyObject *py_name = 0;
 
5591
    PyObject *py_module = 0;
 
5592
 
 
5593
    #if PY_MAJOR_VERSION < 3
 
5594
    py_name = PyString_FromString(name);
 
5595
    #else
 
5596
    py_name = PyUnicode_FromString(name);
 
5597
    #endif
 
5598
    if (!py_name)
 
5599
        goto bad;
 
5600
    py_module = PyImport_Import(py_name);
 
5601
    Py_DECREF(py_name);
 
5602
    return py_module;
 
5603
bad:
 
5604
    Py_XDECREF(py_name);
 
5605
    return 0;
 
5606
}
 
5607
#endif
 
5608
 
 
5609
#include "compile.h"
 
5610
#include "frameobject.h"
 
5611
#include "traceback.h"
 
5612
 
 
5613
static void __Pyx_AddTraceback(const char *funcname) {
 
5614
    PyObject *py_srcfile = 0;
 
5615
    PyObject *py_funcname = 0;
 
5616
    PyObject *py_globals = 0;
 
5617
    PyCodeObject *py_code = 0;
 
5618
    PyFrameObject *py_frame = 0;
 
5619
 
 
5620
    #if PY_MAJOR_VERSION < 3
 
5621
    py_srcfile = PyString_FromString(__pyx_filename);
 
5622
    #else
 
5623
    py_srcfile = PyUnicode_FromString(__pyx_filename);
 
5624
    #endif
 
5625
    if (!py_srcfile) goto bad;
 
5626
    if (__pyx_clineno) {
 
5627
        #if PY_MAJOR_VERSION < 3
 
5628
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
 
5629
        #else
 
5630
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
 
5631
        #endif
 
5632
    }
 
5633
    else {
 
5634
        #if PY_MAJOR_VERSION < 3
 
5635
        py_funcname = PyString_FromString(funcname);
 
5636
        #else
 
5637
        py_funcname = PyUnicode_FromString(funcname);
 
5638
        #endif
 
5639
    }
 
5640
    if (!py_funcname) goto bad;
 
5641
    py_globals = PyModule_GetDict(__pyx_m);
 
5642
    if (!py_globals) goto bad;
 
5643
    py_code = PyCode_New(
 
5644
        0,            /*int argcount,*/
 
5645
        #if PY_MAJOR_VERSION >= 3
 
5646
        0,            /*int kwonlyargcount,*/
 
5647
        #endif
 
5648
        0,            /*int nlocals,*/
 
5649
        0,            /*int stacksize,*/
 
5650
        0,            /*int flags,*/
 
5651
        __pyx_empty_bytes, /*PyObject *code,*/
 
5652
        __pyx_empty_tuple,  /*PyObject *consts,*/
 
5653
        __pyx_empty_tuple,  /*PyObject *names,*/
 
5654
        __pyx_empty_tuple,  /*PyObject *varnames,*/
 
5655
        __pyx_empty_tuple,  /*PyObject *freevars,*/
 
5656
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
 
5657
        py_srcfile,   /*PyObject *filename,*/
 
5658
        py_funcname,  /*PyObject *name,*/
 
5659
        __pyx_lineno,   /*int firstlineno,*/
 
5660
        __pyx_empty_bytes  /*PyObject *lnotab*/
 
5661
    );
 
5662
    if (!py_code) goto bad;
 
5663
    py_frame = PyFrame_New(
 
5664
        PyThreadState_GET(), /*PyThreadState *tstate,*/
 
5665
        py_code,             /*PyCodeObject *code,*/
 
5666
        py_globals,          /*PyObject *globals,*/
 
5667
        0                    /*PyObject *locals*/
 
5668
    );
 
5669
    if (!py_frame) goto bad;
 
5670
    py_frame->f_lineno = __pyx_lineno;
 
5671
    PyTraceBack_Here(py_frame);
 
5672
bad:
 
5673
    Py_XDECREF(py_srcfile);
 
5674
    Py_XDECREF(py_funcname);
 
5675
    Py_XDECREF(py_code);
 
5676
    Py_XDECREF(py_frame);
 
5677
}
 
5678
 
 
5679
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
 
5680
    while (t->p) {
 
5681
        #if PY_MAJOR_VERSION < 3
 
5682
        if (t->is_unicode) {
 
5683
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
 
5684
        } else if (t->intern) {
 
5685
            *t->p = PyString_InternFromString(t->s);
 
5686
        } else {
 
5687
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
 
5688
        }
 
5689
        #else  /* Python 3+ has unicode identifiers */
 
5690
        if (t->is_unicode | t->is_str) {
 
5691
            if (t->intern) {
 
5692
                *t->p = PyUnicode_InternFromString(t->s);
 
5693
            } else if (t->encoding) {
 
5694
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
 
5695
            } else {
 
5696
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
 
5697
            }
 
5698
        } else {
 
5699
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
 
5700
        }
 
5701
        #endif
 
5702
        if (!*t->p)
 
5703
            return -1;
 
5704
        ++t;
 
5705
    }
 
5706
    return 0;
 
5707
}
 
5708
 
 
5709
/* Type Conversion Functions */
 
5710
 
 
5711
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
 
5712
   if (x == Py_True) return 1;
 
5713
   else if ((x == Py_False) | (x == Py_None)) return 0;
 
5714
   else return PyObject_IsTrue(x);
 
5715
}
 
5716
 
 
5717
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
 
5718
  PyNumberMethods *m;
 
5719
  const char *name = NULL;
 
5720
  PyObject *res = NULL;
 
5721
#if PY_VERSION_HEX < 0x03000000
 
5722
  if (PyInt_Check(x) || PyLong_Check(x))
 
5723
#else
 
5724
  if (PyLong_Check(x))
 
5725
#endif
 
5726
    return Py_INCREF(x), x;
 
5727
  m = Py_TYPE(x)->tp_as_number;
 
5728
#if PY_VERSION_HEX < 0x03000000
 
5729
  if (m && m->nb_int) {
 
5730
    name = "int";
 
5731
    res = PyNumber_Int(x);
 
5732
  }
 
5733
  else if (m && m->nb_long) {
 
5734
    name = "long";
 
5735
    res = PyNumber_Long(x);
 
5736
  }
 
5737
#else
 
5738
  if (m && m->nb_int) {
 
5739
    name = "int";
 
5740
    res = PyNumber_Long(x);
 
5741
  }
 
5742
#endif
 
5743
  if (res) {
 
5744
#if PY_VERSION_HEX < 0x03000000
 
5745
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
 
5746
#else
 
5747
    if (!PyLong_Check(res)) {
 
5748
#endif
 
5749
      PyErr_Format(PyExc_TypeError,
 
5750
                   "__%s__ returned non-%s (type %.200s)",
 
5751
                   name, name, Py_TYPE(res)->tp_name);
 
5752
      Py_DECREF(res);
 
5753
      return NULL;
 
5754
    }
 
5755
  }
 
5756
  else if (!PyErr_Occurred()) {
 
5757
    PyErr_SetString(PyExc_TypeError,
 
5758
                    "an integer is required");
 
5759
  }
 
5760
  return res;
 
5761
}
 
5762
 
 
5763
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
 
5764
  Py_ssize_t ival;
 
5765
  PyObject* x = PyNumber_Index(b);
 
5766
  if (!x) return -1;
 
5767
  ival = PyInt_AsSsize_t(x);
 
5768
  Py_DECREF(x);
 
5769
  return ival;
 
5770
}
 
5771
 
 
5772
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
 
5773
#if PY_VERSION_HEX < 0x02050000
 
5774
   if (ival <= LONG_MAX)
 
5775
       return PyInt_FromLong((long)ival);
 
5776
   else {
 
5777
       unsigned char *bytes = (unsigned char *) &ival;
 
5778
       int one = 1; int little = (int)*(unsigned char*)&one;
 
5779
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
 
5780
   }
 
5781
#else
 
5782
   return PyInt_FromSize_t(ival);
 
5783
#endif
 
5784
}
 
5785
 
 
5786
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
 
5787
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
 
5788
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
 
5789
       return (size_t)-1;
 
5790
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
 
5791
       PyErr_SetString(PyExc_OverflowError,
 
5792
                       "value too large to convert to size_t");
 
5793
       return (size_t)-1;
 
5794
   }
 
5795
   return (size_t)val;
 
5796
}
 
5797
 
 
5798
 
 
5799
#endif /* Py_PYTHON_H */