Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241818 views
1
/* Generated by Cython 0.25.2 */
2
3
#define PY_SSIZE_T_CLEAN
4
#include "Python.h"
5
#ifndef Py_PYTHON_H
6
#error Python headers needed to compile C extensions, please install development version of Python.
7
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
8
#error Cython requires Python 2.6+ or Python 3.2+.
9
#else
10
#define CYTHON_ABI "0_25_2"
11
#include <stddef.h>
12
#ifndef offsetof
13
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
14
#endif
15
#if !defined(WIN32) && !defined(MS_WINDOWS)
16
#ifndef __stdcall
17
#define __stdcall
18
#endif
19
#ifndef __cdecl
20
#define __cdecl
21
#endif
22
#ifndef __fastcall
23
#define __fastcall
24
#endif
25
#endif
26
#ifndef DL_IMPORT
27
#define DL_IMPORT(t) t
28
#endif
29
#ifndef DL_EXPORT
30
#define DL_EXPORT(t) t
31
#endif
32
#ifndef HAVE_LONG_LONG
33
#if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
34
#define HAVE_LONG_LONG
35
#endif
36
#endif
37
#ifndef PY_LONG_LONG
38
#define PY_LONG_LONG LONG_LONG
39
#endif
40
#ifndef Py_HUGE_VAL
41
#define Py_HUGE_VAL HUGE_VAL
42
#endif
43
#ifdef PYPY_VERSION
44
#define CYTHON_COMPILING_IN_PYPY 1
45
#define CYTHON_COMPILING_IN_PYSTON 0
46
#define CYTHON_COMPILING_IN_CPYTHON 0
47
#undef CYTHON_USE_TYPE_SLOTS
48
#define CYTHON_USE_TYPE_SLOTS 0
49
#undef CYTHON_USE_ASYNC_SLOTS
50
#define CYTHON_USE_ASYNC_SLOTS 0
51
#undef CYTHON_USE_PYLIST_INTERNALS
52
#define CYTHON_USE_PYLIST_INTERNALS 0
53
#undef CYTHON_USE_UNICODE_INTERNALS
54
#define CYTHON_USE_UNICODE_INTERNALS 0
55
#undef CYTHON_USE_UNICODE_WRITER
56
#define CYTHON_USE_UNICODE_WRITER 0
57
#undef CYTHON_USE_PYLONG_INTERNALS
58
#define CYTHON_USE_PYLONG_INTERNALS 0
59
#undef CYTHON_AVOID_BORROWED_REFS
60
#define CYTHON_AVOID_BORROWED_REFS 1
61
#undef CYTHON_ASSUME_SAFE_MACROS
62
#define CYTHON_ASSUME_SAFE_MACROS 0
63
#undef CYTHON_UNPACK_METHODS
64
#define CYTHON_UNPACK_METHODS 0
65
#undef CYTHON_FAST_THREAD_STATE
66
#define CYTHON_FAST_THREAD_STATE 0
67
#undef CYTHON_FAST_PYCALL
68
#define CYTHON_FAST_PYCALL 0
69
#elif defined(PYSTON_VERSION)
70
#define CYTHON_COMPILING_IN_PYPY 0
71
#define CYTHON_COMPILING_IN_PYSTON 1
72
#define CYTHON_COMPILING_IN_CPYTHON 0
73
#ifndef CYTHON_USE_TYPE_SLOTS
74
#define CYTHON_USE_TYPE_SLOTS 1
75
#endif
76
#undef CYTHON_USE_ASYNC_SLOTS
77
#define CYTHON_USE_ASYNC_SLOTS 0
78
#undef CYTHON_USE_PYLIST_INTERNALS
79
#define CYTHON_USE_PYLIST_INTERNALS 0
80
#ifndef CYTHON_USE_UNICODE_INTERNALS
81
#define CYTHON_USE_UNICODE_INTERNALS 1
82
#endif
83
#undef CYTHON_USE_UNICODE_WRITER
84
#define CYTHON_USE_UNICODE_WRITER 0
85
#undef CYTHON_USE_PYLONG_INTERNALS
86
#define CYTHON_USE_PYLONG_INTERNALS 0
87
#ifndef CYTHON_AVOID_BORROWED_REFS
88
#define CYTHON_AVOID_BORROWED_REFS 0
89
#endif
90
#ifndef CYTHON_ASSUME_SAFE_MACROS
91
#define CYTHON_ASSUME_SAFE_MACROS 1
92
#endif
93
#ifndef CYTHON_UNPACK_METHODS
94
#define CYTHON_UNPACK_METHODS 1
95
#endif
96
#undef CYTHON_FAST_THREAD_STATE
97
#define CYTHON_FAST_THREAD_STATE 0
98
#undef CYTHON_FAST_PYCALL
99
#define CYTHON_FAST_PYCALL 0
100
#else
101
#define CYTHON_COMPILING_IN_PYPY 0
102
#define CYTHON_COMPILING_IN_PYSTON 0
103
#define CYTHON_COMPILING_IN_CPYTHON 1
104
#ifndef CYTHON_USE_TYPE_SLOTS
105
#define CYTHON_USE_TYPE_SLOTS 1
106
#endif
107
#if PY_MAJOR_VERSION < 3
108
#undef CYTHON_USE_ASYNC_SLOTS
109
#define CYTHON_USE_ASYNC_SLOTS 0
110
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
111
#define CYTHON_USE_ASYNC_SLOTS 1
112
#endif
113
#if PY_VERSION_HEX < 0x02070000
114
#undef CYTHON_USE_PYLONG_INTERNALS
115
#define CYTHON_USE_PYLONG_INTERNALS 0
116
#elif !defined(CYTHON_USE_PYLONG_INTERNALS)
117
#define CYTHON_USE_PYLONG_INTERNALS 1
118
#endif
119
#ifndef CYTHON_USE_PYLIST_INTERNALS
120
#define CYTHON_USE_PYLIST_INTERNALS 1
121
#endif
122
#ifndef CYTHON_USE_UNICODE_INTERNALS
123
#define CYTHON_USE_UNICODE_INTERNALS 1
124
#endif
125
#if PY_VERSION_HEX < 0x030300F0
126
#undef CYTHON_USE_UNICODE_WRITER
127
#define CYTHON_USE_UNICODE_WRITER 0
128
#elif !defined(CYTHON_USE_UNICODE_WRITER)
129
#define CYTHON_USE_UNICODE_WRITER 1
130
#endif
131
#ifndef CYTHON_AVOID_BORROWED_REFS
132
#define CYTHON_AVOID_BORROWED_REFS 0
133
#endif
134
#ifndef CYTHON_ASSUME_SAFE_MACROS
135
#define CYTHON_ASSUME_SAFE_MACROS 1
136
#endif
137
#ifndef CYTHON_UNPACK_METHODS
138
#define CYTHON_UNPACK_METHODS 1
139
#endif
140
#ifndef CYTHON_FAST_THREAD_STATE
141
#define CYTHON_FAST_THREAD_STATE 1
142
#endif
143
#ifndef CYTHON_FAST_PYCALL
144
#define CYTHON_FAST_PYCALL 1
145
#endif
146
#endif
147
#if !defined(CYTHON_FAST_PYCCALL)
148
#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
149
#endif
150
#if CYTHON_USE_PYLONG_INTERNALS
151
#include "longintrepr.h"
152
#undef SHIFT
153
#undef BASE
154
#undef MASK
155
#endif
156
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
157
#define Py_OptimizeFlag 0
158
#endif
159
#define __PYX_BUILD_PY_SSIZE_T "n"
160
#define CYTHON_FORMAT_SSIZE_T "z"
161
#if PY_MAJOR_VERSION < 3
162
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
163
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
164
PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
165
#define __Pyx_DefaultClassType PyClass_Type
166
#else
167
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
168
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
169
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
170
#define __Pyx_DefaultClassType PyType_Type
171
#endif
172
#ifndef Py_TPFLAGS_CHECKTYPES
173
#define Py_TPFLAGS_CHECKTYPES 0
174
#endif
175
#ifndef Py_TPFLAGS_HAVE_INDEX
176
#define Py_TPFLAGS_HAVE_INDEX 0
177
#endif
178
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
179
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
180
#endif
181
#ifndef Py_TPFLAGS_HAVE_FINALIZE
182
#define Py_TPFLAGS_HAVE_FINALIZE 0
183
#endif
184
#ifndef METH_FASTCALL
185
#define METH_FASTCALL 0x80
186
typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args,
187
Py_ssize_t nargs, PyObject *kwnames);
188
#else
189
#define __Pyx_PyCFunctionFast _PyCFunctionFast
190
#endif
191
#if CYTHON_FAST_PYCCALL
192
#define __Pyx_PyFastCFunction_Check(func)\
193
((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))))
194
#else
195
#define __Pyx_PyFastCFunction_Check(func) 0
196
#endif
197
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
198
#define CYTHON_PEP393_ENABLED 1
199
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
200
0 : _PyUnicode_Ready((PyObject *)(op)))
201
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
202
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
203
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
204
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
205
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
206
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
207
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
208
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
209
#else
210
#define CYTHON_PEP393_ENABLED 0
211
#define PyUnicode_1BYTE_KIND 1
212
#define PyUnicode_2BYTE_KIND 2
213
#define PyUnicode_4BYTE_KIND 4
214
#define __Pyx_PyUnicode_READY(op) (0)
215
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
216
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
217
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
218
#define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
219
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
220
#define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
221
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
222
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
223
#endif
224
#if CYTHON_COMPILING_IN_PYPY
225
#define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
226
#define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
227
#else
228
#define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
229
#define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
230
PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
231
#endif
232
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
233
#define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
234
#endif
235
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
236
#define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
237
#endif
238
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
239
#define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
240
#endif
241
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
242
#define PyObject_Malloc(s) PyMem_Malloc(s)
243
#define PyObject_Free(p) PyMem_Free(p)
244
#define PyObject_Realloc(p) PyMem_Realloc(p)
245
#endif
246
#if CYTHON_COMPILING_IN_PYSTON
247
#define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
248
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
249
#else
250
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
251
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
252
#endif
253
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
254
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
255
#if PY_MAJOR_VERSION >= 3
256
#define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
257
#else
258
#define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
259
#endif
260
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
261
#define PyObject_ASCII(o) PyObject_Repr(o)
262
#endif
263
#if PY_MAJOR_VERSION >= 3
264
#define PyBaseString_Type PyUnicode_Type
265
#define PyStringObject PyUnicodeObject
266
#define PyString_Type PyUnicode_Type
267
#define PyString_Check PyUnicode_Check
268
#define PyString_CheckExact PyUnicode_CheckExact
269
#endif
270
#if PY_MAJOR_VERSION >= 3
271
#define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
272
#define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
273
#else
274
#define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
275
#define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
276
#endif
277
#ifndef PySet_CheckExact
278
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
279
#endif
280
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
281
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
282
#if PY_MAJOR_VERSION >= 3
283
#define PyIntObject PyLongObject
284
#define PyInt_Type PyLong_Type
285
#define PyInt_Check(op) PyLong_Check(op)
286
#define PyInt_CheckExact(op) PyLong_CheckExact(op)
287
#define PyInt_FromString PyLong_FromString
288
#define PyInt_FromUnicode PyLong_FromUnicode
289
#define PyInt_FromLong PyLong_FromLong
290
#define PyInt_FromSize_t PyLong_FromSize_t
291
#define PyInt_FromSsize_t PyLong_FromSsize_t
292
#define PyInt_AsLong PyLong_AsLong
293
#define PyInt_AS_LONG PyLong_AS_LONG
294
#define PyInt_AsSsize_t PyLong_AsSsize_t
295
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
296
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
297
#define PyNumber_Int PyNumber_Long
298
#endif
299
#if PY_MAJOR_VERSION >= 3
300
#define PyBoolObject PyLongObject
301
#endif
302
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
303
#ifndef PyUnicode_InternFromString
304
#define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
305
#endif
306
#endif
307
#if PY_VERSION_HEX < 0x030200A4
308
typedef long Py_hash_t;
309
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
310
#define __Pyx_PyInt_AsHash_t PyInt_AsLong
311
#else
312
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
313
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
314
#endif
315
#if PY_MAJOR_VERSION >= 3
316
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
317
#else
318
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
319
#endif
320
#if CYTHON_USE_ASYNC_SLOTS
321
#if PY_VERSION_HEX >= 0x030500B1
322
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
323
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
324
#else
325
typedef struct {
326
unaryfunc am_await;
327
unaryfunc am_aiter;
328
unaryfunc am_anext;
329
} __Pyx_PyAsyncMethodsStruct;
330
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
331
#endif
332
#else
333
#define __Pyx_PyType_AsAsync(obj) NULL
334
#endif
335
#ifndef CYTHON_RESTRICT
336
#if defined(__GNUC__)
337
#define CYTHON_RESTRICT __restrict__
338
#elif defined(_MSC_VER) && _MSC_VER >= 1400
339
#define CYTHON_RESTRICT __restrict
340
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
341
#define CYTHON_RESTRICT restrict
342
#else
343
#define CYTHON_RESTRICT
344
#endif
345
#endif
346
#ifndef CYTHON_UNUSED
347
# if defined(__GNUC__)
348
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
349
# define CYTHON_UNUSED __attribute__ ((__unused__))
350
# else
351
# define CYTHON_UNUSED
352
# endif
353
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
354
# define CYTHON_UNUSED __attribute__ ((__unused__))
355
# else
356
# define CYTHON_UNUSED
357
# endif
358
#endif
359
#ifndef CYTHON_MAYBE_UNUSED_VAR
360
# if defined(__cplusplus)
361
template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
362
# else
363
# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
364
# endif
365
#endif
366
#ifndef CYTHON_NCP_UNUSED
367
# if CYTHON_COMPILING_IN_CPYTHON
368
# define CYTHON_NCP_UNUSED
369
# else
370
# define CYTHON_NCP_UNUSED CYTHON_UNUSED
371
# endif
372
#endif
373
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
374
375
#ifndef CYTHON_INLINE
376
#if defined(__clang__)
377
#define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
378
#elif defined(__GNUC__)
379
#define CYTHON_INLINE __inline__
380
#elif defined(_MSC_VER)
381
#define CYTHON_INLINE __inline
382
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
383
#define CYTHON_INLINE inline
384
#else
385
#define CYTHON_INLINE
386
#endif
387
#endif
388
389
#if defined(WIN32) || defined(MS_WINDOWS)
390
#define _USE_MATH_DEFINES
391
#endif
392
#include <math.h>
393
#ifdef NAN
394
#define __PYX_NAN() ((float) NAN)
395
#else
396
static CYTHON_INLINE float __PYX_NAN() {
397
float value;
398
memset(&value, 0xFF, sizeof(value));
399
return value;
400
}
401
#endif
402
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
403
#define __Pyx_truncl trunc
404
#else
405
#define __Pyx_truncl truncl
406
#endif
407
408
409
#define __PYX_ERR(f_index, lineno, Ln_error) \
410
{ \
411
__pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
412
}
413
414
#if PY_MAJOR_VERSION >= 3
415
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
416
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
417
#else
418
#define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
419
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
420
#endif
421
422
#ifndef __PYX_EXTERN_C
423
#ifdef __cplusplus
424
#define __PYX_EXTERN_C extern "C"
425
#else
426
#define __PYX_EXTERN_C extern
427
#endif
428
#endif
429
430
#define __PYX_HAVE__code__alex__psage__psage__ellcurve__lseries__fast_twist
431
#define __PYX_HAVE_API__code__alex__psage__psage__ellcurve__lseries__fast_twist
432
#include "struct_signals.h"
433
#include "pxi.h"
434
#include <string.h>
435
#include <stdlib.h>
436
#include <stdio.h>
437
#include "gsl/gsl_sf_expint.h"
438
#ifdef _OPENMP
439
#include <omp.h>
440
#endif /* _OPENMP */
441
442
#ifdef PYREX_WITHOUT_ASSERTIONS
443
#define CYTHON_WITHOUT_ASSERTIONS
444
#endif
445
446
typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
447
const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
448
449
#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
450
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
451
#define __PYX_DEFAULT_STRING_ENCODING ""
452
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
453
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
454
#define __Pyx_uchar_cast(c) ((unsigned char)c)
455
#define __Pyx_long_cast(x) ((long)x)
456
#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
457
(sizeof(type) < sizeof(Py_ssize_t)) ||\
458
(sizeof(type) > sizeof(Py_ssize_t) &&\
459
likely(v < (type)PY_SSIZE_T_MAX ||\
460
v == (type)PY_SSIZE_T_MAX) &&\
461
(!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
462
v == (type)PY_SSIZE_T_MIN))) ||\
463
(sizeof(type) == sizeof(Py_ssize_t) &&\
464
(is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
465
v == (type)PY_SSIZE_T_MAX))) )
466
#if defined (__cplusplus) && __cplusplus >= 201103L
467
#include <cstdlib>
468
#define __Pyx_sst_abs(value) std::abs(value)
469
#elif SIZEOF_INT >= SIZEOF_SIZE_T
470
#define __Pyx_sst_abs(value) abs(value)
471
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
472
#define __Pyx_sst_abs(value) labs(value)
473
#elif defined (_MSC_VER) && defined (_M_X64)
474
#define __Pyx_sst_abs(value) _abs64(value)
475
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
476
#define __Pyx_sst_abs(value) llabs(value)
477
#elif defined (__GNUC__)
478
#define __Pyx_sst_abs(value) __builtin_llabs(value)
479
#else
480
#define __Pyx_sst_abs(value) ((value<0) ? -value : value)
481
#endif
482
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
483
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
484
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
485
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
486
#define __Pyx_PyBytes_FromString PyBytes_FromString
487
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
488
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
489
#if PY_MAJOR_VERSION < 3
490
#define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
491
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
492
#else
493
#define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
494
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
495
#endif
496
#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
497
#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
498
#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
499
#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
500
#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
501
#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
502
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
503
#if PY_MAJOR_VERSION < 3
504
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
505
{
506
const Py_UNICODE *u_end = u;
507
while (*u_end++) ;
508
return (size_t)(u_end - u - 1);
509
}
510
#else
511
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
512
#endif
513
#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
514
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
515
#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
516
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
517
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
518
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
519
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
520
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
521
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
522
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
523
#if CYTHON_ASSUME_SAFE_MACROS
524
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
525
#else
526
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
527
#endif
528
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
529
#if PY_MAJOR_VERSION >= 3
530
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
531
#else
532
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
533
#endif
534
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
535
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
536
static int __Pyx_sys_getdefaultencoding_not_ascii;
537
static int __Pyx_init_sys_getdefaultencoding_params(void) {
538
PyObject* sys;
539
PyObject* default_encoding = NULL;
540
PyObject* ascii_chars_u = NULL;
541
PyObject* ascii_chars_b = NULL;
542
const char* default_encoding_c;
543
sys = PyImport_ImportModule("sys");
544
if (!sys) goto bad;
545
default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
546
Py_DECREF(sys);
547
if (!default_encoding) goto bad;
548
default_encoding_c = PyBytes_AsString(default_encoding);
549
if (!default_encoding_c) goto bad;
550
if (strcmp(default_encoding_c, "ascii") == 0) {
551
__Pyx_sys_getdefaultencoding_not_ascii = 0;
552
} else {
553
char ascii_chars[128];
554
int c;
555
for (c = 0; c < 128; c++) {
556
ascii_chars[c] = c;
557
}
558
__Pyx_sys_getdefaultencoding_not_ascii = 1;
559
ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
560
if (!ascii_chars_u) goto bad;
561
ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
562
if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
563
PyErr_Format(
564
PyExc_ValueError,
565
"This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
566
default_encoding_c);
567
goto bad;
568
}
569
Py_DECREF(ascii_chars_u);
570
Py_DECREF(ascii_chars_b);
571
}
572
Py_DECREF(default_encoding);
573
return 0;
574
bad:
575
Py_XDECREF(default_encoding);
576
Py_XDECREF(ascii_chars_u);
577
Py_XDECREF(ascii_chars_b);
578
return -1;
579
}
580
#endif
581
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
582
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
583
#else
584
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
585
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
586
static char* __PYX_DEFAULT_STRING_ENCODING;
587
static int __Pyx_init_sys_getdefaultencoding_params(void) {
588
PyObject* sys;
589
PyObject* default_encoding = NULL;
590
char* default_encoding_c;
591
sys = PyImport_ImportModule("sys");
592
if (!sys) goto bad;
593
default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
594
Py_DECREF(sys);
595
if (!default_encoding) goto bad;
596
default_encoding_c = PyBytes_AsString(default_encoding);
597
if (!default_encoding_c) goto bad;
598
__PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
599
if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
600
strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
601
Py_DECREF(default_encoding);
602
return 0;
603
bad:
604
Py_XDECREF(default_encoding);
605
return -1;
606
}
607
#endif
608
#endif
609
610
611
/* Test for GCC > 2.95 */
612
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
613
#define likely(x) __builtin_expect(!!(x), 1)
614
#define unlikely(x) __builtin_expect(!!(x), 0)
615
#else /* !__GNUC__ or GCC < 2.95 */
616
#define likely(x) (x)
617
#define unlikely(x) (x)
618
#endif /* __GNUC__ */
619
620
static PyObject *__pyx_m;
621
static PyObject *__pyx_d;
622
static PyObject *__pyx_b;
623
static PyObject *__pyx_empty_tuple;
624
static PyObject *__pyx_empty_bytes;
625
static PyObject *__pyx_empty_unicode;
626
static int __pyx_lineno;
627
static int __pyx_clineno = 0;
628
static const char * __pyx_cfilenm= __FILE__;
629
static const char *__pyx_filename;
630
631
632
static const char *__pyx_f[] = {
633
"code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx",
634
"memory.pxd",
635
"stdsage.pxd",
636
"type.pxd",
637
"time_series.pxd",
638
"intlist.pxd",
639
"signals.pxi",
640
"stdsage.pxi",
641
"interrupt.pxi",
642
};
643
644
/*--- Type declarations ---*/
645
struct __pyx_obj_4sage_7finance_11time_series_TimeSeries;
646
struct __pyx_obj_4sage_5stats_7intlist_IntList;
647
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist;
648
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists;
649
650
/* "sage/finance/time_series.pxd":1
651
* cdef class TimeSeries: # <<<<<<<<<<<<<<
652
* cdef double* _values
653
* cdef Py_ssize_t _length
654
*/
655
struct __pyx_obj_4sage_7finance_11time_series_TimeSeries {
656
PyObject_HEAD
657
struct __pyx_vtabstruct_4sage_7finance_11time_series_TimeSeries *__pyx_vtab;
658
double *_values;
659
Py_ssize_t _length;
660
};
661
662
663
/* "sage/stats/intlist.pxd":8
664
* #############################################################################
665
*
666
* cdef class IntList: # <<<<<<<<<<<<<<
667
* cdef int* _values
668
* cdef Py_ssize_t _length
669
*/
670
struct __pyx_obj_4sage_5stats_7intlist_IntList {
671
PyObject_HEAD
672
struct __pyx_vtabstruct_4sage_5stats_7intlist_IntList *__pyx_vtab;
673
int *_values;
674
Py_ssize_t _length;
675
};
676
677
678
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":26
679
* cdef double pi = 3.1415926535897932384626433833
680
*
681
* cdef class anlist: # <<<<<<<<<<<<<<
682
* cdef IntList a
683
* cdef object E
684
*/
685
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist {
686
PyObject_HEAD
687
struct __pyx_obj_4sage_5stats_7intlist_IntList *a;
688
PyObject *E;
689
Py_ssize_t B;
690
};
691
692
693
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":103
694
* return self.a[i]
695
*
696
* cdef class FastHeegnerTwists: # <<<<<<<<<<<<<<
697
* cdef Py_ssize_t B
698
* cdef TimeSeries a
699
*/
700
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists {
701
PyObject_HEAD
702
Py_ssize_t B;
703
struct __pyx_obj_4sage_7finance_11time_series_TimeSeries *a;
704
PyObject *E;
705
int root_number;
706
int N;
707
};
708
709
710
711
/* "sage/finance/time_series.pxd":1
712
* cdef class TimeSeries: # <<<<<<<<<<<<<<
713
* cdef double* _values
714
* cdef Py_ssize_t _length
715
*/
716
717
struct __pyx_vtabstruct_4sage_7finance_11time_series_TimeSeries {
718
PyObject *(*rescale)(struct __pyx_obj_4sage_7finance_11time_series_TimeSeries *, double, int __pyx_skip_dispatch);
719
double (*sum)(struct __pyx_obj_4sage_7finance_11time_series_TimeSeries *, int __pyx_skip_dispatch);
720
};
721
static struct __pyx_vtabstruct_4sage_7finance_11time_series_TimeSeries *__pyx_vtabptr_4sage_7finance_11time_series_TimeSeries;
722
723
724
/* "sage/stats/intlist.pxd":8
725
* #############################################################################
726
*
727
* cdef class IntList: # <<<<<<<<<<<<<<
728
* cdef int* _values
729
* cdef Py_ssize_t _length
730
*/
731
732
struct __pyx_vtabstruct_4sage_5stats_7intlist_IntList {
733
int (*prod)(struct __pyx_obj_4sage_5stats_7intlist_IntList *, int __pyx_skip_dispatch);
734
int (*sum)(struct __pyx_obj_4sage_5stats_7intlist_IntList *, int __pyx_skip_dispatch);
735
};
736
static struct __pyx_vtabstruct_4sage_5stats_7intlist_IntList *__pyx_vtabptr_4sage_5stats_7intlist_IntList;
737
738
/* --- Runtime support code (head) --- */
739
/* Refnanny.proto */
740
#ifndef CYTHON_REFNANNY
741
#define CYTHON_REFNANNY 0
742
#endif
743
#if CYTHON_REFNANNY
744
typedef struct {
745
void (*INCREF)(void*, PyObject*, int);
746
void (*DECREF)(void*, PyObject*, int);
747
void (*GOTREF)(void*, PyObject*, int);
748
void (*GIVEREF)(void*, PyObject*, int);
749
void* (*SetupContext)(const char*, int, const char*);
750
void (*FinishContext)(void**);
751
} __Pyx_RefNannyAPIStruct;
752
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
753
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
754
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
755
#ifdef WITH_THREAD
756
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
757
if (acquire_gil) {\
758
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
759
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
760
PyGILState_Release(__pyx_gilstate_save);\
761
} else {\
762
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
763
}
764
#else
765
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
766
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
767
#endif
768
#define __Pyx_RefNannyFinishContext()\
769
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
770
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
771
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
772
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
773
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
774
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
775
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
776
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
777
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
778
#else
779
#define __Pyx_RefNannyDeclarations
780
#define __Pyx_RefNannySetupContext(name, acquire_gil)
781
#define __Pyx_RefNannyFinishContext()
782
#define __Pyx_INCREF(r) Py_INCREF(r)
783
#define __Pyx_DECREF(r) Py_DECREF(r)
784
#define __Pyx_GOTREF(r)
785
#define __Pyx_GIVEREF(r)
786
#define __Pyx_XINCREF(r) Py_XINCREF(r)
787
#define __Pyx_XDECREF(r) Py_XDECREF(r)
788
#define __Pyx_XGOTREF(r)
789
#define __Pyx_XGIVEREF(r)
790
#endif
791
#define __Pyx_XDECREF_SET(r, v) do {\
792
PyObject *tmp = (PyObject *) r;\
793
r = v; __Pyx_XDECREF(tmp);\
794
} while (0)
795
#define __Pyx_DECREF_SET(r, v) do {\
796
PyObject *tmp = (PyObject *) r;\
797
r = v; __Pyx_DECREF(tmp);\
798
} while (0)
799
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
800
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
801
802
/* PyObjectGetAttrStr.proto */
803
#if CYTHON_USE_TYPE_SLOTS
804
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
805
PyTypeObject* tp = Py_TYPE(obj);
806
if (likely(tp->tp_getattro))
807
return tp->tp_getattro(obj, attr_name);
808
#if PY_MAJOR_VERSION < 3
809
if (likely(tp->tp_getattr))
810
return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
811
#endif
812
return PyObject_GetAttr(obj, attr_name);
813
}
814
#else
815
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
816
#endif
817
818
/* GetBuiltinName.proto */
819
static PyObject *__Pyx_GetBuiltinName(PyObject *name);
820
821
/* RaiseArgTupleInvalid.proto */
822
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
823
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
824
825
/* RaiseDoubleKeywords.proto */
826
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
827
828
/* ParseKeywords.proto */
829
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
830
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
831
const char* function_name);
832
833
/* PyObjectCall.proto */
834
#if CYTHON_COMPILING_IN_CPYTHON
835
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
836
#else
837
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
838
#endif
839
840
/* PyCFunctionFastCall.proto */
841
#if CYTHON_FAST_PYCCALL
842
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
843
#else
844
#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
845
#endif
846
847
/* PyFunctionFastCall.proto */
848
#if CYTHON_FAST_PYCALL
849
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
850
__Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
851
#if 1 || PY_VERSION_HEX < 0x030600B1
852
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
853
#else
854
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
855
#endif
856
#endif
857
858
/* PyObjectCallMethO.proto */
859
#if CYTHON_COMPILING_IN_CPYTHON
860
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
861
#endif
862
863
/* PyObjectCallOneArg.proto */
864
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
865
866
/* PyObjectCallNoArg.proto */
867
#if CYTHON_COMPILING_IN_CPYTHON
868
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
869
#else
870
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
871
#endif
872
873
/* RaiseTooManyValuesToUnpack.proto */
874
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
875
876
/* RaiseNeedMoreValuesToUnpack.proto */
877
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
878
879
/* IterFinish.proto */
880
static CYTHON_INLINE int __Pyx_IterFinish(void);
881
882
/* UnpackItemEndCheck.proto */
883
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
884
885
/* GetModuleGlobalName.proto */
886
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
887
888
/* PyObjectCallMethod0.proto */
889
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
890
891
/* RaiseNoneIterError.proto */
892
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
893
894
/* UnpackTupleError.proto */
895
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);
896
897
/* UnpackTuple2.proto */
898
static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** value1, PyObject** value2,
899
int is_tuple, int has_known_size, int decref_tuple);
900
901
/* dict_iter.proto */
902
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
903
Py_ssize_t* p_orig_length, int* p_is_dict);
904
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
905
PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);
906
907
/* None.proto */
908
static CYTHON_INLINE Py_ssize_t __Pyx_mod_Py_ssize_t(Py_ssize_t, Py_ssize_t);
909
910
/* None.proto */
911
static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
912
913
/* UnaryNegOverflows.proto */
914
#define UNARY_NEG_WOULD_OVERFLOW(x)\
915
(((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
916
917
/* GetItemInt.proto */
918
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
919
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
920
__Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
921
(is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
922
__Pyx_GetItemInt_Generic(o, to_py_func(i))))
923
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
924
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
925
__Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
926
(PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
927
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
928
int wraparound, int boundscheck);
929
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
930
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
931
__Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
932
(PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
933
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
934
int wraparound, int boundscheck);
935
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
936
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
937
int is_list, int wraparound, int boundscheck);
938
939
/* SetItemInt.proto */
940
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
941
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
942
__Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
943
(is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
944
__Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
945
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
946
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
947
int is_list, int wraparound, int boundscheck);
948
949
/* abs_long.proto */
950
static CYTHON_INLINE unsigned long __Pyx_abs_long(long x) {
951
if (unlikely(x == -LONG_MAX-1))
952
return ((unsigned long)LONG_MAX) + 1U;
953
return (unsigned long) labs(x);
954
}
955
956
/* PyThreadStateGet.proto */
957
#if CYTHON_FAST_THREAD_STATE
958
#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
959
#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET();
960
#else
961
#define __Pyx_PyThreadState_declare
962
#define __Pyx_PyThreadState_assign
963
#endif
964
965
/* PyErrFetchRestore.proto */
966
#if CYTHON_FAST_THREAD_STATE
967
#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
968
#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
969
#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
970
#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
971
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
972
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
973
#else
974
#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
975
#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
976
#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
977
#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
978
#endif
979
980
/* RaiseException.proto */
981
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
982
983
/* None.proto */
984
static CYTHON_INLINE long __Pyx_mod_long(long, long);
985
986
/* GetVTable.proto */
987
static void* __Pyx_GetVtable(PyObject *dict);
988
989
/* Import.proto */
990
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
991
992
/* ImportFrom.proto */
993
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
994
995
/* CodeObjectCache.proto */
996
typedef struct {
997
PyCodeObject* code_object;
998
int code_line;
999
} __Pyx_CodeObjectCacheEntry;
1000
struct __Pyx_CodeObjectCache {
1001
int count;
1002
int max_count;
1003
__Pyx_CodeObjectCacheEntry* entries;
1004
};
1005
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1006
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1007
static PyCodeObject *__pyx_find_code_object(int code_line);
1008
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1009
1010
/* AddTraceback.proto */
1011
static void __Pyx_AddTraceback(const char *funcname, int c_line,
1012
int py_line, const char *filename);
1013
1014
/* CIntToPy.proto */
1015
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1016
1017
/* CIntToPy.proto */
1018
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1019
1020
/* CIntFromPy.proto */
1021
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1022
1023
/* CIntFromPy.proto */
1024
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1025
1026
/* CheckBinaryVersion.proto */
1027
static int __Pyx_check_binary_version(void);
1028
1029
/* PyIdentifierFromString.proto */
1030
#if !defined(__Pyx_PyIdentifier_FromString)
1031
#if PY_MAJOR_VERSION < 3
1032
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
1033
#else
1034
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
1035
#endif
1036
#endif
1037
1038
/* ModuleImport.proto */
1039
static PyObject *__Pyx_ImportModule(const char *name);
1040
1041
/* TypeImport.proto */
1042
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
1043
1044
/* VoidPtrImport.proto */
1045
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
1046
1047
/* InitStrings.proto */
1048
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1049
1050
1051
/* Module declarations from 'cysignals.__init__' */
1052
1053
/* Module declarations from 'cysignals' */
1054
1055
/* Module declarations from 'cysignals.signals' */
1056
static cysigs_t *__pyx_vp_9cysignals_7signals_cysigs = 0;
1057
#define cysigs (*__pyx_vp_9cysignals_7signals_cysigs)
1058
static void (*__pyx_f_9cysignals_7signals_print_backtrace)(void); /*proto*/
1059
static void (*__pyx_f_9cysignals_7signals__sig_on_interrupt_received)(void); /*proto*/
1060
static void (*__pyx_f_9cysignals_7signals__sig_on_recover)(void); /*proto*/
1061
static void (*__pyx_f_9cysignals_7signals__sig_off_warning)(char const *, int); /*proto*/
1062
1063
/* Module declarations from 'cython' */
1064
1065
/* Module declarations from 'libc.string' */
1066
1067
/* Module declarations from 'libc.stdlib' */
1068
1069
/* Module declarations from 'cysignals.memory' */
1070
static CYTHON_INLINE void *sig_malloc(size_t); /*proto*/
1071
static CYTHON_INLINE void *sig_realloc(void *, size_t); /*proto*/
1072
static CYTHON_INLINE void *sig_calloc(size_t, size_t); /*proto*/
1073
static CYTHON_INLINE void sig_free(void *); /*proto*/
1074
static CYTHON_INLINE size_t __pyx_f_9cysignals_6memory_mul_overflowcheck(size_t, size_t); /*proto*/
1075
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_allocarray(size_t, size_t); /*proto*/
1076
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_reallocarray(void *, size_t, size_t); /*proto*/
1077
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_malloc(size_t); /*proto*/
1078
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_realloc(void *, size_t); /*proto*/
1079
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_calloc(size_t, size_t); /*proto*/
1080
1081
/* Module declarations from 'libc.stdio' */
1082
1083
/* Module declarations from '__builtin__' */
1084
1085
/* Module declarations from 'cpython.type' */
1086
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1087
1088
/* Module declarations from 'cpython' */
1089
1090
/* Module declarations from 'cpython.object' */
1091
1092
/* Module declarations from 'sage.ext.stdsage' */
1093
static CYTHON_INLINE PyObject *__pyx_f_4sage_3ext_7stdsage_PY_NEW(PyTypeObject *); /*proto*/
1094
static CYTHON_INLINE int __pyx_f_4sage_3ext_7stdsage_HAS_DICTIONARY(PyObject *); /*proto*/
1095
1096
/* Module declarations from 'sage.finance.time_series' */
1097
static PyTypeObject *__pyx_ptype_4sage_7finance_11time_series_TimeSeries = 0;
1098
1099
/* Module declarations from 'sage.stats.intlist' */
1100
static PyTypeObject *__pyx_ptype_4sage_5stats_7intlist_IntList = 0;
1101
1102
/* Module declarations from 'code.alex.psage.psage.ellcurve.lseries.fast_twist' */
1103
static PyTypeObject *__pyx_ptype_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist = 0;
1104
static PyTypeObject *__pyx_ptype_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists = 0;
1105
static double __pyx_v_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_pi;
1106
__PYX_EXTERN_C DL_IMPORT(double) exp(double); /*proto*/
1107
__PYX_EXTERN_C DL_IMPORT(double) log(double); /*proto*/
1108
__PYX_EXTERN_C DL_IMPORT(double) sqrt(double); /*proto*/
1109
#define __Pyx_MODULE_NAME "code.alex.psage.psage.ellcurve.lseries.fast_twist"
1110
int __pyx_module_is_main_code__alex__psage__psage__ellcurve__lseries__fast_twist = 0;
1111
1112
/* Implementation of 'code.alex.psage.psage.ellcurve.lseries.fast_twist' */
1113
static PyObject *__pyx_builtin_range;
1114
static PyObject *__pyx_builtin_ValueError;
1115
static PyObject *__pyx_builtin_MemoryError;
1116
static const char __pyx_k_B[] = "B";
1117
static const char __pyx_k_D[] = "D";
1118
static const char __pyx_k_E[] = "E";
1119
static const char __pyx_k_x[] = "x";
1120
static const char __pyx_k_ZZ[] = "ZZ";
1121
static const char __pyx_k_ap[] = "ap";
1122
static const char __pyx_k_tol[] = "tol";
1123
static const char __pyx_k_keys[] = "keys";
1124
static const char __pyx_k_main[] = "__main__";
1125
static const char __pyx_k_sort[] = "sort";
1126
static const char __pyx_k_test[] = "__test__";
1127
static const char __pyx_k_range[] = "range";
1128
static const char __pyx_k_import[] = "__import__";
1129
static const char __pyx_k_SmallJac[] = "SmallJac";
1130
static const char __pyx_k_conductor[] = "conductor";
1131
static const char __pyx_k_iteritems[] = "iteritems";
1132
static const char __pyx_k_kronecker[] = "kronecker";
1133
static const char __pyx_k_ValueError[] = "ValueError";
1134
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
1135
static const char __pyx_k_MemoryError[] = "MemoryError";
1136
static const char __pyx_k_deprecation[] = "deprecation";
1137
static const char __pyx_k_root_number[] = "root_number";
1138
static const char __pyx_k_a_invariants[] = "a_invariants";
1139
static const char __pyx_k_sage_rings_all[] = "sage.rings.all";
1140
static const char __pyx_k_sage_ext_memory[] = "sage.ext.memory";
1141
static const char __pyx_k_sage_misc_superseded[] = "sage.misc.superseded";
1142
static const char __pyx_k_heegner_discriminants[] = "heegner_discriminants";
1143
static const char __pyx_k_init_memory_functions[] = "init_memory_functions";
1144
static const char __pyx_k_short_weierstrass_model[] = "short_weierstrass_model";
1145
static const char __pyx_k_List_of_coefficients_a_n_E[] = "List of coefficients a_n(E).";
1146
static const char __pyx_k_failed_to_allocate_s_bytes[] = "failed to allocate %s bytes";
1147
static const char __pyx_k_psage_libs_smalljac_wrapper[] = "psage.libs.smalljac.wrapper";
1148
static const char __pyx_k_failed_to_allocate_s_s_bytes[] = "failed to allocate %s * %s bytes";
1149
static const char __pyx_k_File_fast_twist_pyx_starting_at[] = "File: fast_twist.pyx (starting at line 1)\n\nNumerically computing L'(E/K,1) for E an elliptic curve over Q and K a\nquadratic imaginary field satisfying the Heegner hypothesis.\n";
1150
static const char __pyx_k_Fast_Heegner_twist_object_associ[] = "Fast Heegner twist object associated to %s";
1151
static const char __pyx_k_import_cysignals_signals_pxi_ins[] = "import \"cysignals/signals.pxi\" instead of \"sage/ext/interrupt.pxi\"";
1152
static const char __pyx_k_not_enough_terms_of_L_series_kno[] = "not enough terms of L-series known (%s needed, but %s known)";
1153
static PyObject *__pyx_n_s_B;
1154
static PyObject *__pyx_n_s_D;
1155
static PyObject *__pyx_n_s_E;
1156
static PyObject *__pyx_kp_s_Fast_Heegner_twist_object_associ;
1157
static PyObject *__pyx_kp_s_List_of_coefficients_a_n_E;
1158
static PyObject *__pyx_n_s_MemoryError;
1159
static PyObject *__pyx_n_s_SmallJac;
1160
static PyObject *__pyx_n_s_ValueError;
1161
static PyObject *__pyx_n_s_ZZ;
1162
static PyObject *__pyx_n_s_a_invariants;
1163
static PyObject *__pyx_n_s_ap;
1164
static PyObject *__pyx_n_s_conductor;
1165
static PyObject *__pyx_n_s_deprecation;
1166
static PyObject *__pyx_kp_s_failed_to_allocate_s_bytes;
1167
static PyObject *__pyx_kp_s_failed_to_allocate_s_s_bytes;
1168
static PyObject *__pyx_n_s_heegner_discriminants;
1169
static PyObject *__pyx_n_s_import;
1170
static PyObject *__pyx_kp_s_import_cysignals_signals_pxi_ins;
1171
static PyObject *__pyx_n_s_init_memory_functions;
1172
static PyObject *__pyx_n_s_iteritems;
1173
static PyObject *__pyx_n_s_keys;
1174
static PyObject *__pyx_n_s_kronecker;
1175
static PyObject *__pyx_n_s_main;
1176
static PyObject *__pyx_kp_s_not_enough_terms_of_L_series_kno;
1177
static PyObject *__pyx_n_s_psage_libs_smalljac_wrapper;
1178
static PyObject *__pyx_n_s_pyx_vtable;
1179
static PyObject *__pyx_n_s_range;
1180
static PyObject *__pyx_n_s_root_number;
1181
static PyObject *__pyx_n_s_sage_ext_memory;
1182
static PyObject *__pyx_n_s_sage_misc_superseded;
1183
static PyObject *__pyx_n_s_sage_rings_all;
1184
static PyObject *__pyx_n_s_short_weierstrass_model;
1185
static PyObject *__pyx_n_s_sort;
1186
static PyObject *__pyx_n_s_test;
1187
static PyObject *__pyx_n_s_tol;
1188
static PyObject *__pyx_n_s_x;
1189
static int __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist___init__(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *__pyx_v_self, PyObject *__pyx_v_E, Py_ssize_t __pyx_v_B); /* proto */
1190
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_2__repr__(CYTHON_UNUSED struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *__pyx_v_self); /* proto */
1191
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_4__getitem__(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *__pyx_v_self, Py_ssize_t __pyx_v_i); /* proto */
1192
static int __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists___init__(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *__pyx_v_self, PyObject *__pyx_v_E, Py_ssize_t __pyx_v_B); /* proto */
1193
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_2__repr__(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *__pyx_v_self); /* proto */
1194
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_4elliptic_curve(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *__pyx_v_self); /* proto */
1195
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_6discs(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *__pyx_v_self, PyObject *__pyx_v_bound); /* proto */
1196
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_8twist_special_value(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *__pyx_v_self, long __pyx_v_D, PyObject *__pyx_v_tol); /* proto */
1197
static PyObject *__pyx_tp_new_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1198
static PyObject *__pyx_tp_new_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1199
static PyObject *__pyx_float_1eneg_6;
1200
static PyObject *__pyx_int_0;
1201
static PyObject *__pyx_int_1;
1202
static PyObject *__pyx_int_2;
1203
static PyObject *__pyx_int_20002;
1204
static PyObject *__pyx_tuple_;
1205
1206
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":31
1207
* cdef Py_ssize_t B
1208
*
1209
* def __init__(self, E, Py_ssize_t B): # <<<<<<<<<<<<<<
1210
* self.a = IntList(B)
1211
* cdef int* a = self.a._values
1212
*/
1213
1214
/* Python wrapper */
1215
static int __pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1216
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist___init__[] = "File: fast_twist.pyx (starting at line 31)";
1217
#if CYTHON_COMPILING_IN_CPYTHON
1218
struct wrapperbase __pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist___init__;
1219
#endif
1220
static int __pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1221
PyObject *__pyx_v_E = 0;
1222
Py_ssize_t __pyx_v_B;
1223
int __pyx_r;
1224
__Pyx_RefNannyDeclarations
1225
__Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
1226
{
1227
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_E,&__pyx_n_s_B,0};
1228
PyObject* values[2] = {0,0};
1229
if (unlikely(__pyx_kwds)) {
1230
Py_ssize_t kw_args;
1231
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1232
switch (pos_args) {
1233
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1234
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1235
case 0: break;
1236
default: goto __pyx_L5_argtuple_error;
1237
}
1238
kw_args = PyDict_Size(__pyx_kwds);
1239
switch (pos_args) {
1240
case 0:
1241
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_E)) != 0)) kw_args--;
1242
else goto __pyx_L5_argtuple_error;
1243
case 1:
1244
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_B)) != 0)) kw_args--;
1245
else {
1246
__Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 31, __pyx_L3_error)
1247
}
1248
}
1249
if (unlikely(kw_args > 0)) {
1250
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 31, __pyx_L3_error)
1251
}
1252
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
1253
goto __pyx_L5_argtuple_error;
1254
} else {
1255
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1256
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1257
}
1258
__pyx_v_E = values[0];
1259
__pyx_v_B = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_B == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 31, __pyx_L3_error)
1260
}
1261
goto __pyx_L4_argument_unpacking_done;
1262
__pyx_L5_argtuple_error:;
1263
__Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 31, __pyx_L3_error)
1264
__pyx_L3_error:;
1265
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.fast_twist.anlist.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1266
__Pyx_RefNannyFinishContext();
1267
return -1;
1268
__pyx_L4_argument_unpacking_done:;
1269
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist___init__(((struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *)__pyx_v_self), __pyx_v_E, __pyx_v_B);
1270
1271
/* function exit code */
1272
__Pyx_RefNannyFinishContext();
1273
return __pyx_r;
1274
}
1275
1276
static int __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist___init__(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *__pyx_v_self, PyObject *__pyx_v_E, Py_ssize_t __pyx_v_B) {
1277
int *__pyx_v_a;
1278
long __pyx_v_UNKNOWN;
1279
Py_ssize_t __pyx_v_i;
1280
long __pyx_v_N;
1281
PyObject *__pyx_v_a1 = NULL;
1282
PyObject *__pyx_v_a2 = NULL;
1283
PyObject *__pyx_v_a3 = NULL;
1284
PyObject *__pyx_v_a4 = NULL;
1285
PyObject *__pyx_v_a6 = NULL;
1286
CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
1287
PyObject *__pyx_v_R = NULL;
1288
PyObject *__pyx_v_f = NULL;
1289
PyObject *__pyx_v_C = NULL;
1290
PyObject *__pyx_v_ap_dict = NULL;
1291
Py_ssize_t __pyx_v_p;
1292
Py_ssize_t __pyx_v_q;
1293
Py_ssize_t __pyx_v_n;
1294
PyObject *__pyx_v_v = 0;
1295
PyObject *__pyx_v_primes = NULL;
1296
int __pyx_r;
1297
__Pyx_RefNannyDeclarations
1298
PyObject *__pyx_t_1 = NULL;
1299
PyObject *__pyx_t_2 = NULL;
1300
int *__pyx_t_3;
1301
Py_ssize_t __pyx_t_4;
1302
Py_ssize_t __pyx_t_5;
1303
PyObject *__pyx_t_6 = NULL;
1304
long __pyx_t_7;
1305
PyObject *__pyx_t_8 = NULL;
1306
PyObject *__pyx_t_9 = NULL;
1307
PyObject *__pyx_t_10 = NULL;
1308
PyObject *__pyx_t_11 = NULL;
1309
PyObject *(*__pyx_t_12)(PyObject *);
1310
int __pyx_t_13;
1311
int __pyx_t_14;
1312
int __pyx_t_15;
1313
int __pyx_t_16;
1314
Py_ssize_t __pyx_t_17;
1315
PyObject *(*__pyx_t_18)(PyObject *);
1316
__Pyx_RefNannySetupContext("__init__", 0);
1317
1318
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":32
1319
*
1320
* def __init__(self, E, Py_ssize_t B):
1321
* self.a = IntList(B) # <<<<<<<<<<<<<<
1322
* cdef int* a = self.a._values
1323
* self.E = E
1324
*/
1325
__pyx_t_1 = PyInt_FromSsize_t(__pyx_v_B); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
1326
__Pyx_GOTREF(__pyx_t_1);
1327
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
1328
__Pyx_GOTREF(__pyx_t_2);
1329
__Pyx_GIVEREF(__pyx_t_1);
1330
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
1331
__pyx_t_1 = 0;
1332
__pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4sage_5stats_7intlist_IntList), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
1333
__Pyx_GOTREF(__pyx_t_1);
1334
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1335
__Pyx_GIVEREF(__pyx_t_1);
1336
__Pyx_GOTREF(__pyx_v_self->a);
1337
__Pyx_DECREF(((PyObject *)__pyx_v_self->a));
1338
__pyx_v_self->a = ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)__pyx_t_1);
1339
__pyx_t_1 = 0;
1340
1341
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":33
1342
* def __init__(self, E, Py_ssize_t B):
1343
* self.a = IntList(B)
1344
* cdef int* a = self.a._values # <<<<<<<<<<<<<<
1345
* self.E = E
1346
* self.B = B
1347
*/
1348
__pyx_t_3 = __pyx_v_self->a->_values;
1349
__pyx_v_a = __pyx_t_3;
1350
1351
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":34
1352
* self.a = IntList(B)
1353
* cdef int* a = self.a._values
1354
* self.E = E # <<<<<<<<<<<<<<
1355
* self.B = B
1356
*
1357
*/
1358
__Pyx_INCREF(__pyx_v_E);
1359
__Pyx_GIVEREF(__pyx_v_E);
1360
__Pyx_GOTREF(__pyx_v_self->E);
1361
__Pyx_DECREF(__pyx_v_self->E);
1362
__pyx_v_self->E = __pyx_v_E;
1363
1364
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":35
1365
* cdef int* a = self.a._values
1366
* self.E = E
1367
* self.B = B # <<<<<<<<<<<<<<
1368
*
1369
* cdef long UNKNOWN = 10*B # coefficients not yet known; safely outside Hasse interval
1370
*/
1371
__pyx_v_self->B = __pyx_v_B;
1372
1373
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":37
1374
* self.B = B
1375
*
1376
* cdef long UNKNOWN = 10*B # coefficients not yet known; safely outside Hasse interval # <<<<<<<<<<<<<<
1377
* cdef Py_ssize_t i
1378
* for i in range(B):
1379
*/
1380
__pyx_v_UNKNOWN = (10 * __pyx_v_B);
1381
1382
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":39
1383
* cdef long UNKNOWN = 10*B # coefficients not yet known; safely outside Hasse interval
1384
* cdef Py_ssize_t i
1385
* for i in range(B): # <<<<<<<<<<<<<<
1386
* a[i] = UNKNOWN
1387
*
1388
*/
1389
__pyx_t_4 = __pyx_v_B;
1390
for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
1391
__pyx_v_i = __pyx_t_5;
1392
1393
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":40
1394
* cdef Py_ssize_t i
1395
* for i in range(B):
1396
* a[i] = UNKNOWN # <<<<<<<<<<<<<<
1397
*
1398
* # easy cases
1399
*/
1400
(__pyx_v_a[__pyx_v_i]) = __pyx_v_UNKNOWN;
1401
}
1402
1403
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":43
1404
*
1405
* # easy cases
1406
* a[0] = 0 # <<<<<<<<<<<<<<
1407
* a[1] = 1
1408
*
1409
*/
1410
(__pyx_v_a[0]) = 0;
1411
1412
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":44
1413
* # easy cases
1414
* a[0] = 0
1415
* a[1] = 1 # <<<<<<<<<<<<<<
1416
*
1417
* cdef long N = E.conductor()
1418
*/
1419
(__pyx_v_a[1]) = 1;
1420
1421
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":46
1422
* a[1] = 1
1423
*
1424
* cdef long N = E.conductor() # <<<<<<<<<<<<<<
1425
*
1426
* ##############################################################
1427
*/
1428
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_E, __pyx_n_s_conductor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error)
1429
__Pyx_GOTREF(__pyx_t_2);
1430
__pyx_t_6 = NULL;
1431
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
1432
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
1433
if (likely(__pyx_t_6)) {
1434
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
1435
__Pyx_INCREF(__pyx_t_6);
1436
__Pyx_INCREF(function);
1437
__Pyx_DECREF_SET(__pyx_t_2, function);
1438
}
1439
}
1440
if (__pyx_t_6) {
1441
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
1442
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1443
} else {
1444
__pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
1445
}
1446
__Pyx_GOTREF(__pyx_t_1);
1447
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1448
__pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error)
1449
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1450
__pyx_v_N = __pyx_t_7;
1451
1452
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":52
1453
* # (and also Sage for bad primes)
1454
* ##############################################################
1455
* a1,a2,a3,a4,a6 = E.a_invariants() # <<<<<<<<<<<<<<
1456
* if a1 or a2 or a3:
1457
* _,_,_,a4,a6 = E.short_weierstrass_model().a_invariants()
1458
*/
1459
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_E, __pyx_n_s_a_invariants); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error)
1460
__Pyx_GOTREF(__pyx_t_2);
1461
__pyx_t_6 = NULL;
1462
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
1463
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
1464
if (likely(__pyx_t_6)) {
1465
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
1466
__Pyx_INCREF(__pyx_t_6);
1467
__Pyx_INCREF(function);
1468
__Pyx_DECREF_SET(__pyx_t_2, function);
1469
}
1470
}
1471
if (__pyx_t_6) {
1472
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
1473
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1474
} else {
1475
__pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
1476
}
1477
__Pyx_GOTREF(__pyx_t_1);
1478
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1479
if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
1480
PyObject* sequence = __pyx_t_1;
1481
#if !CYTHON_COMPILING_IN_PYPY
1482
Py_ssize_t size = Py_SIZE(sequence);
1483
#else
1484
Py_ssize_t size = PySequence_Size(sequence);
1485
#endif
1486
if (unlikely(size != 5)) {
1487
if (size > 5) __Pyx_RaiseTooManyValuesError(5);
1488
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
1489
__PYX_ERR(0, 52, __pyx_L1_error)
1490
}
1491
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1492
if (likely(PyTuple_CheckExact(sequence))) {
1493
__pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
1494
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
1495
__pyx_t_8 = PyTuple_GET_ITEM(sequence, 2);
1496
__pyx_t_9 = PyTuple_GET_ITEM(sequence, 3);
1497
__pyx_t_10 = PyTuple_GET_ITEM(sequence, 4);
1498
} else {
1499
__pyx_t_2 = PyList_GET_ITEM(sequence, 0);
1500
__pyx_t_6 = PyList_GET_ITEM(sequence, 1);
1501
__pyx_t_8 = PyList_GET_ITEM(sequence, 2);
1502
__pyx_t_9 = PyList_GET_ITEM(sequence, 3);
1503
__pyx_t_10 = PyList_GET_ITEM(sequence, 4);
1504
}
1505
__Pyx_INCREF(__pyx_t_2);
1506
__Pyx_INCREF(__pyx_t_6);
1507
__Pyx_INCREF(__pyx_t_8);
1508
__Pyx_INCREF(__pyx_t_9);
1509
__Pyx_INCREF(__pyx_t_10);
1510
#else
1511
{
1512
Py_ssize_t i;
1513
PyObject** temps[5] = {&__pyx_t_2,&__pyx_t_6,&__pyx_t_8,&__pyx_t_9,&__pyx_t_10};
1514
for (i=0; i < 5; i++) {
1515
PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 52, __pyx_L1_error)
1516
__Pyx_GOTREF(item);
1517
*(temps[i]) = item;
1518
}
1519
}
1520
#endif
1521
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1522
} else {
1523
Py_ssize_t index = -1;
1524
PyObject** temps[5] = {&__pyx_t_2,&__pyx_t_6,&__pyx_t_8,&__pyx_t_9,&__pyx_t_10};
1525
__pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 52, __pyx_L1_error)
1526
__Pyx_GOTREF(__pyx_t_11);
1527
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1528
__pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
1529
for (index=0; index < 5; index++) {
1530
PyObject* item = __pyx_t_12(__pyx_t_11); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
1531
__Pyx_GOTREF(item);
1532
*(temps[index]) = item;
1533
}
1534
if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 5) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
1535
__pyx_t_12 = NULL;
1536
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
1537
goto __pyx_L6_unpacking_done;
1538
__pyx_L5_unpacking_failed:;
1539
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
1540
__pyx_t_12 = NULL;
1541
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
1542
__PYX_ERR(0, 52, __pyx_L1_error)
1543
__pyx_L6_unpacking_done:;
1544
}
1545
__pyx_v_a1 = __pyx_t_2;
1546
__pyx_t_2 = 0;
1547
__pyx_v_a2 = __pyx_t_6;
1548
__pyx_t_6 = 0;
1549
__pyx_v_a3 = __pyx_t_8;
1550
__pyx_t_8 = 0;
1551
__pyx_v_a4 = __pyx_t_9;
1552
__pyx_t_9 = 0;
1553
__pyx_v_a6 = __pyx_t_10;
1554
__pyx_t_10 = 0;
1555
1556
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":53
1557
* ##############################################################
1558
* a1,a2,a3,a4,a6 = E.a_invariants()
1559
* if a1 or a2 or a3: # <<<<<<<<<<<<<<
1560
* _,_,_,a4,a6 = E.short_weierstrass_model().a_invariants()
1561
* R = ZZ['x']
1562
*/
1563
__pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_v_a1); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 53, __pyx_L1_error)
1564
if (!__pyx_t_14) {
1565
} else {
1566
__pyx_t_13 = __pyx_t_14;
1567
goto __pyx_L8_bool_binop_done;
1568
}
1569
__pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_v_a2); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 53, __pyx_L1_error)
1570
if (!__pyx_t_14) {
1571
} else {
1572
__pyx_t_13 = __pyx_t_14;
1573
goto __pyx_L8_bool_binop_done;
1574
}
1575
__pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_v_a3); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 53, __pyx_L1_error)
1576
__pyx_t_13 = __pyx_t_14;
1577
__pyx_L8_bool_binop_done:;
1578
if (__pyx_t_13) {
1579
1580
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":54
1581
* a1,a2,a3,a4,a6 = E.a_invariants()
1582
* if a1 or a2 or a3:
1583
* _,_,_,a4,a6 = E.short_weierstrass_model().a_invariants() # <<<<<<<<<<<<<<
1584
* R = ZZ['x']
1585
* f = R([a6,a4,0,1])
1586
*/
1587
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_E, __pyx_n_s_short_weierstrass_model); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L1_error)
1588
__Pyx_GOTREF(__pyx_t_9);
1589
__pyx_t_8 = NULL;
1590
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
1591
__pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
1592
if (likely(__pyx_t_8)) {
1593
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
1594
__Pyx_INCREF(__pyx_t_8);
1595
__Pyx_INCREF(function);
1596
__Pyx_DECREF_SET(__pyx_t_9, function);
1597
}
1598
}
1599
if (__pyx_t_8) {
1600
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 54, __pyx_L1_error)
1601
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
1602
} else {
1603
__pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 54, __pyx_L1_error)
1604
}
1605
__Pyx_GOTREF(__pyx_t_10);
1606
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
1607
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_a_invariants); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L1_error)
1608
__Pyx_GOTREF(__pyx_t_9);
1609
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1610
__pyx_t_10 = NULL;
1611
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
1612
__pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
1613
if (likely(__pyx_t_10)) {
1614
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
1615
__Pyx_INCREF(__pyx_t_10);
1616
__Pyx_INCREF(function);
1617
__Pyx_DECREF_SET(__pyx_t_9, function);
1618
}
1619
}
1620
if (__pyx_t_10) {
1621
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error)
1622
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1623
} else {
1624
__pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error)
1625
}
1626
__Pyx_GOTREF(__pyx_t_1);
1627
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
1628
if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
1629
PyObject* sequence = __pyx_t_1;
1630
#if !CYTHON_COMPILING_IN_PYPY
1631
Py_ssize_t size = Py_SIZE(sequence);
1632
#else
1633
Py_ssize_t size = PySequence_Size(sequence);
1634
#endif
1635
if (unlikely(size != 5)) {
1636
if (size > 5) __Pyx_RaiseTooManyValuesError(5);
1637
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
1638
__PYX_ERR(0, 54, __pyx_L1_error)
1639
}
1640
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1641
if (likely(PyTuple_CheckExact(sequence))) {
1642
__pyx_t_9 = PyTuple_GET_ITEM(sequence, 0);
1643
__pyx_t_10 = PyTuple_GET_ITEM(sequence, 1);
1644
__pyx_t_8 = PyTuple_GET_ITEM(sequence, 2);
1645
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 3);
1646
__pyx_t_2 = PyTuple_GET_ITEM(sequence, 4);
1647
} else {
1648
__pyx_t_9 = PyList_GET_ITEM(sequence, 0);
1649
__pyx_t_10 = PyList_GET_ITEM(sequence, 1);
1650
__pyx_t_8 = PyList_GET_ITEM(sequence, 2);
1651
__pyx_t_6 = PyList_GET_ITEM(sequence, 3);
1652
__pyx_t_2 = PyList_GET_ITEM(sequence, 4);
1653
}
1654
__Pyx_INCREF(__pyx_t_9);
1655
__Pyx_INCREF(__pyx_t_10);
1656
__Pyx_INCREF(__pyx_t_8);
1657
__Pyx_INCREF(__pyx_t_6);
1658
__Pyx_INCREF(__pyx_t_2);
1659
#else
1660
{
1661
Py_ssize_t i;
1662
PyObject** temps[5] = {&__pyx_t_9,&__pyx_t_10,&__pyx_t_8,&__pyx_t_6,&__pyx_t_2};
1663
for (i=0; i < 5; i++) {
1664
PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 54, __pyx_L1_error)
1665
__Pyx_GOTREF(item);
1666
*(temps[i]) = item;
1667
}
1668
}
1669
#endif
1670
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1671
} else {
1672
Py_ssize_t index = -1;
1673
PyObject** temps[5] = {&__pyx_t_9,&__pyx_t_10,&__pyx_t_8,&__pyx_t_6,&__pyx_t_2};
1674
__pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 54, __pyx_L1_error)
1675
__Pyx_GOTREF(__pyx_t_11);
1676
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1677
__pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
1678
for (index=0; index < 5; index++) {
1679
PyObject* item = __pyx_t_12(__pyx_t_11); if (unlikely(!item)) goto __pyx_L11_unpacking_failed;
1680
__Pyx_GOTREF(item);
1681
*(temps[index]) = item;
1682
}
1683
if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 5) < 0) __PYX_ERR(0, 54, __pyx_L1_error)
1684
__pyx_t_12 = NULL;
1685
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
1686
goto __pyx_L12_unpacking_done;
1687
__pyx_L11_unpacking_failed:;
1688
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
1689
__pyx_t_12 = NULL;
1690
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
1691
__PYX_ERR(0, 54, __pyx_L1_error)
1692
__pyx_L12_unpacking_done:;
1693
}
1694
__pyx_v__ = __pyx_t_9;
1695
__pyx_t_9 = 0;
1696
__Pyx_DECREF_SET(__pyx_v__, __pyx_t_10);
1697
__pyx_t_10 = 0;
1698
__Pyx_DECREF_SET(__pyx_v__, __pyx_t_8);
1699
__pyx_t_8 = 0;
1700
__Pyx_DECREF_SET(__pyx_v_a4, __pyx_t_6);
1701
__pyx_t_6 = 0;
1702
__Pyx_DECREF_SET(__pyx_v_a6, __pyx_t_2);
1703
__pyx_t_2 = 0;
1704
1705
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":53
1706
* ##############################################################
1707
* a1,a2,a3,a4,a6 = E.a_invariants()
1708
* if a1 or a2 or a3: # <<<<<<<<<<<<<<
1709
* _,_,_,a4,a6 = E.short_weierstrass_model().a_invariants()
1710
* R = ZZ['x']
1711
*/
1712
}
1713
1714
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":55
1715
* if a1 or a2 or a3:
1716
* _,_,_,a4,a6 = E.short_weierstrass_model().a_invariants()
1717
* R = ZZ['x'] # <<<<<<<<<<<<<<
1718
* f = R([a6,a4,0,1])
1719
* C = SmallJac(f)
1720
*/
1721
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ZZ); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error)
1722
__Pyx_GOTREF(__pyx_t_1);
1723
__pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_n_s_x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error)
1724
__Pyx_GOTREF(__pyx_t_2);
1725
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1726
__pyx_v_R = __pyx_t_2;
1727
__pyx_t_2 = 0;
1728
1729
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":56
1730
* _,_,_,a4,a6 = E.short_weierstrass_model().a_invariants()
1731
* R = ZZ['x']
1732
* f = R([a6,a4,0,1]) # <<<<<<<<<<<<<<
1733
* C = SmallJac(f)
1734
* sig_on()
1735
*/
1736
__pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
1737
__Pyx_GOTREF(__pyx_t_1);
1738
__Pyx_INCREF(__pyx_v_a6);
1739
__Pyx_GIVEREF(__pyx_v_a6);
1740
PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_a6);
1741
__Pyx_INCREF(__pyx_v_a4);
1742
__Pyx_GIVEREF(__pyx_v_a4);
1743
PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_a4);
1744
__Pyx_INCREF(__pyx_int_0);
1745
__Pyx_GIVEREF(__pyx_int_0);
1746
PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_0);
1747
__Pyx_INCREF(__pyx_int_1);
1748
__Pyx_GIVEREF(__pyx_int_1);
1749
PyList_SET_ITEM(__pyx_t_1, 3, __pyx_int_1);
1750
__Pyx_INCREF(__pyx_v_R);
1751
__pyx_t_6 = __pyx_v_R; __pyx_t_8 = NULL;
1752
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
1753
__pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
1754
if (likely(__pyx_t_8)) {
1755
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
1756
__Pyx_INCREF(__pyx_t_8);
1757
__Pyx_INCREF(function);
1758
__Pyx_DECREF_SET(__pyx_t_6, function);
1759
}
1760
}
1761
if (!__pyx_t_8) {
1762
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
1763
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1764
__Pyx_GOTREF(__pyx_t_2);
1765
} else {
1766
#if CYTHON_FAST_PYCALL
1767
if (PyFunction_Check(__pyx_t_6)) {
1768
PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1};
1769
__pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
1770
__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
1771
__Pyx_GOTREF(__pyx_t_2);
1772
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1773
} else
1774
#endif
1775
#if CYTHON_FAST_PYCCALL
1776
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
1777
PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1};
1778
__pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
1779
__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
1780
__Pyx_GOTREF(__pyx_t_2);
1781
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1782
} else
1783
#endif
1784
{
1785
__pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 56, __pyx_L1_error)
1786
__Pyx_GOTREF(__pyx_t_10);
1787
__Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
1788
__Pyx_GIVEREF(__pyx_t_1);
1789
PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_1);
1790
__pyx_t_1 = 0;
1791
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
1792
__Pyx_GOTREF(__pyx_t_2);
1793
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1794
}
1795
}
1796
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1797
__pyx_v_f = __pyx_t_2;
1798
__pyx_t_2 = 0;
1799
1800
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":57
1801
* R = ZZ['x']
1802
* f = R([a6,a4,0,1])
1803
* C = SmallJac(f) # <<<<<<<<<<<<<<
1804
* sig_on()
1805
* ap_dict = C.ap(0,B)
1806
*/
1807
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_SmallJac); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 57, __pyx_L1_error)
1808
__Pyx_GOTREF(__pyx_t_6);
1809
__pyx_t_10 = NULL;
1810
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
1811
__pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
1812
if (likely(__pyx_t_10)) {
1813
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
1814
__Pyx_INCREF(__pyx_t_10);
1815
__Pyx_INCREF(function);
1816
__Pyx_DECREF_SET(__pyx_t_6, function);
1817
}
1818
}
1819
if (!__pyx_t_10) {
1820
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_f); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)
1821
__Pyx_GOTREF(__pyx_t_2);
1822
} else {
1823
#if CYTHON_FAST_PYCALL
1824
if (PyFunction_Check(__pyx_t_6)) {
1825
PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_f};
1826
__pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)
1827
__Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
1828
__Pyx_GOTREF(__pyx_t_2);
1829
} else
1830
#endif
1831
#if CYTHON_FAST_PYCCALL
1832
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
1833
PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_f};
1834
__pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)
1835
__Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
1836
__Pyx_GOTREF(__pyx_t_2);
1837
} else
1838
#endif
1839
{
1840
__pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)
1841
__Pyx_GOTREF(__pyx_t_1);
1842
__Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); __pyx_t_10 = NULL;
1843
__Pyx_INCREF(__pyx_v_f);
1844
__Pyx_GIVEREF(__pyx_v_f);
1845
PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_f);
1846
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)
1847
__Pyx_GOTREF(__pyx_t_2);
1848
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1849
}
1850
}
1851
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1852
__pyx_v_C = __pyx_t_2;
1853
__pyx_t_2 = 0;
1854
1855
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":58
1856
* f = R([a6,a4,0,1])
1857
* C = SmallJac(f)
1858
* sig_on() # <<<<<<<<<<<<<<
1859
* ap_dict = C.ap(0,B)
1860
* sig_off()
1861
*/
1862
__pyx_t_15 = sig_on(); if (unlikely(__pyx_t_15 == 0)) __PYX_ERR(0, 58, __pyx_L1_error)
1863
1864
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":59
1865
* C = SmallJac(f)
1866
* sig_on()
1867
* ap_dict = C.ap(0,B) # <<<<<<<<<<<<<<
1868
* sig_off()
1869
* cdef Py_ssize_t p, q, n
1870
*/
1871
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_C, __pyx_n_s_ap); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 59, __pyx_L1_error)
1872
__Pyx_GOTREF(__pyx_t_6);
1873
__pyx_t_1 = PyInt_FromSsize_t(__pyx_v_B); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
1874
__Pyx_GOTREF(__pyx_t_1);
1875
__pyx_t_10 = NULL;
1876
__pyx_t_15 = 0;
1877
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
1878
__pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
1879
if (likely(__pyx_t_10)) {
1880
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
1881
__Pyx_INCREF(__pyx_t_10);
1882
__Pyx_INCREF(function);
1883
__Pyx_DECREF_SET(__pyx_t_6, function);
1884
__pyx_t_15 = 1;
1885
}
1886
}
1887
#if CYTHON_FAST_PYCALL
1888
if (PyFunction_Check(__pyx_t_6)) {
1889
PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_int_0, __pyx_t_1};
1890
__pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error)
1891
__Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
1892
__Pyx_GOTREF(__pyx_t_2);
1893
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1894
} else
1895
#endif
1896
#if CYTHON_FAST_PYCCALL
1897
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
1898
PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_int_0, __pyx_t_1};
1899
__pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error)
1900
__Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
1901
__Pyx_GOTREF(__pyx_t_2);
1902
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1903
} else
1904
#endif
1905
{
1906
__pyx_t_8 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 59, __pyx_L1_error)
1907
__Pyx_GOTREF(__pyx_t_8);
1908
if (__pyx_t_10) {
1909
__Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL;
1910
}
1911
__Pyx_INCREF(__pyx_int_0);
1912
__Pyx_GIVEREF(__pyx_int_0);
1913
PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_15, __pyx_int_0);
1914
__Pyx_GIVEREF(__pyx_t_1);
1915
PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_15, __pyx_t_1);
1916
__pyx_t_1 = 0;
1917
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error)
1918
__Pyx_GOTREF(__pyx_t_2);
1919
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
1920
}
1921
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1922
__pyx_v_ap_dict = __pyx_t_2;
1923
__pyx_t_2 = 0;
1924
1925
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":60
1926
* sig_on()
1927
* ap_dict = C.ap(0,B)
1928
* sig_off() # <<<<<<<<<<<<<<
1929
* cdef Py_ssize_t p, q, n
1930
* cdef object v
1931
*/
1932
sig_off();
1933
1934
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":63
1935
* cdef Py_ssize_t p, q, n
1936
* cdef object v
1937
* for p, v in ap_dict.iteritems(): # <<<<<<<<<<<<<<
1938
* if v is None:
1939
* a[p] = E.ap(p)
1940
*/
1941
__pyx_t_4 = 0;
1942
if (unlikely(__pyx_v_ap_dict == Py_None)) {
1943
PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
1944
__PYX_ERR(0, 63, __pyx_L1_error)
1945
}
1946
__pyx_t_6 = __Pyx_dict_iterator(__pyx_v_ap_dict, 0, __pyx_n_s_iteritems, (&__pyx_t_5), (&__pyx_t_15)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 63, __pyx_L1_error)
1947
__Pyx_GOTREF(__pyx_t_6);
1948
__Pyx_XDECREF(__pyx_t_2);
1949
__pyx_t_2 = __pyx_t_6;
1950
__pyx_t_6 = 0;
1951
while (1) {
1952
__pyx_t_16 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_5, &__pyx_t_4, &__pyx_t_6, &__pyx_t_8, NULL, __pyx_t_15);
1953
if (unlikely(__pyx_t_16 == 0)) break;
1954
if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 63, __pyx_L1_error)
1955
__Pyx_GOTREF(__pyx_t_6);
1956
__Pyx_GOTREF(__pyx_t_8);
1957
__pyx_t_17 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_17 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 63, __pyx_L1_error)
1958
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1959
__pyx_v_p = __pyx_t_17;
1960
__Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_8);
1961
__pyx_t_8 = 0;
1962
1963
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":64
1964
* cdef object v
1965
* for p, v in ap_dict.iteritems():
1966
* if v is None: # <<<<<<<<<<<<<<
1967
* a[p] = E.ap(p)
1968
* else:
1969
*/
1970
__pyx_t_13 = (__pyx_v_v == Py_None);
1971
__pyx_t_14 = (__pyx_t_13 != 0);
1972
if (__pyx_t_14) {
1973
1974
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":65
1975
* for p, v in ap_dict.iteritems():
1976
* if v is None:
1977
* a[p] = E.ap(p) # <<<<<<<<<<<<<<
1978
* else:
1979
* a[p] = v
1980
*/
1981
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_E, __pyx_n_s_ap); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 65, __pyx_L1_error)
1982
__Pyx_GOTREF(__pyx_t_6);
1983
__pyx_t_1 = PyInt_FromSsize_t(__pyx_v_p); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
1984
__Pyx_GOTREF(__pyx_t_1);
1985
__pyx_t_10 = NULL;
1986
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
1987
__pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
1988
if (likely(__pyx_t_10)) {
1989
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
1990
__Pyx_INCREF(__pyx_t_10);
1991
__Pyx_INCREF(function);
1992
__Pyx_DECREF_SET(__pyx_t_6, function);
1993
}
1994
}
1995
if (!__pyx_t_10) {
1996
__pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 65, __pyx_L1_error)
1997
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1998
__Pyx_GOTREF(__pyx_t_8);
1999
} else {
2000
#if CYTHON_FAST_PYCALL
2001
if (PyFunction_Check(__pyx_t_6)) {
2002
PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_1};
2003
__pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 65, __pyx_L1_error)
2004
__Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
2005
__Pyx_GOTREF(__pyx_t_8);
2006
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2007
} else
2008
#endif
2009
#if CYTHON_FAST_PYCCALL
2010
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
2011
PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_1};
2012
__pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 65, __pyx_L1_error)
2013
__Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
2014
__Pyx_GOTREF(__pyx_t_8);
2015
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2016
} else
2017
#endif
2018
{
2019
__pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 65, __pyx_L1_error)
2020
__Pyx_GOTREF(__pyx_t_9);
2021
__Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
2022
__Pyx_GIVEREF(__pyx_t_1);
2023
PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_1);
2024
__pyx_t_1 = 0;
2025
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 65, __pyx_L1_error)
2026
__Pyx_GOTREF(__pyx_t_8);
2027
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
2028
}
2029
}
2030
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2031
__pyx_t_16 = __Pyx_PyInt_As_int(__pyx_t_8); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 65, __pyx_L1_error)
2032
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2033
(__pyx_v_a[__pyx_v_p]) = __pyx_t_16;
2034
2035
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":64
2036
* cdef object v
2037
* for p, v in ap_dict.iteritems():
2038
* if v is None: # <<<<<<<<<<<<<<
2039
* a[p] = E.ap(p)
2040
* else:
2041
*/
2042
goto __pyx_L15;
2043
}
2044
2045
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":67
2046
* a[p] = E.ap(p)
2047
* else:
2048
* a[p] = v # <<<<<<<<<<<<<<
2049
* # prime powers
2050
* # a_{p^r} := a_p * a_{p^{r-1}} - eps(p)*p*a_{p^{r-2}}
2051
*/
2052
/*else*/ {
2053
__pyx_t_16 = __Pyx_PyInt_As_int(__pyx_v_v); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 67, __pyx_L1_error)
2054
(__pyx_v_a[__pyx_v_p]) = __pyx_t_16;
2055
}
2056
__pyx_L15:;
2057
2058
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":70
2059
* # prime powers
2060
* # a_{p^r} := a_p * a_{p^{r-1}} - eps(p)*p*a_{p^{r-2}}
2061
* q = p*p # <<<<<<<<<<<<<<
2062
* if N%p == 0:
2063
* while q < B:
2064
*/
2065
__pyx_v_q = (__pyx_v_p * __pyx_v_p);
2066
2067
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":71
2068
* # a_{p^r} := a_p * a_{p^{r-1}} - eps(p)*p*a_{p^{r-2}}
2069
* q = p*p
2070
* if N%p == 0: # <<<<<<<<<<<<<<
2071
* while q < B:
2072
* a[q] = a[p]*a[q//p]
2073
*/
2074
if (unlikely(__pyx_v_p == 0)) {
2075
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
2076
__PYX_ERR(0, 71, __pyx_L1_error)
2077
}
2078
__pyx_t_14 = ((__Pyx_mod_Py_ssize_t(__pyx_v_N, __pyx_v_p) == 0) != 0);
2079
if (__pyx_t_14) {
2080
2081
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":72
2082
* q = p*p
2083
* if N%p == 0:
2084
* while q < B: # <<<<<<<<<<<<<<
2085
* a[q] = a[p]*a[q//p]
2086
* q *= p
2087
*/
2088
while (1) {
2089
__pyx_t_14 = ((__pyx_v_q < __pyx_v_B) != 0);
2090
if (!__pyx_t_14) break;
2091
2092
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":73
2093
* if N%p == 0:
2094
* while q < B:
2095
* a[q] = a[p]*a[q//p] # <<<<<<<<<<<<<<
2096
* q *= p
2097
* else:
2098
*/
2099
if (unlikely(__pyx_v_p == 0)) {
2100
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
2101
__PYX_ERR(0, 73, __pyx_L1_error)
2102
}
2103
else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_p == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_q))) {
2104
PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
2105
__PYX_ERR(0, 73, __pyx_L1_error)
2106
}
2107
(__pyx_v_a[__pyx_v_q]) = ((__pyx_v_a[__pyx_v_p]) * (__pyx_v_a[__Pyx_div_Py_ssize_t(__pyx_v_q, __pyx_v_p)]));
2108
2109
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":74
2110
* while q < B:
2111
* a[q] = a[p]*a[q//p]
2112
* q *= p # <<<<<<<<<<<<<<
2113
* else:
2114
* while q < B:
2115
*/
2116
__pyx_v_q = (__pyx_v_q * __pyx_v_p);
2117
}
2118
2119
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":71
2120
* # a_{p^r} := a_p * a_{p^{r-1}} - eps(p)*p*a_{p^{r-2}}
2121
* q = p*p
2122
* if N%p == 0: # <<<<<<<<<<<<<<
2123
* while q < B:
2124
* a[q] = a[p]*a[q//p]
2125
*/
2126
goto __pyx_L16;
2127
}
2128
2129
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":76
2130
* q *= p
2131
* else:
2132
* while q < B: # <<<<<<<<<<<<<<
2133
* a[q] = a[p]*a[q//p] - p*a[q/(p*p)]
2134
* q *= p
2135
*/
2136
/*else*/ {
2137
while (1) {
2138
__pyx_t_14 = ((__pyx_v_q < __pyx_v_B) != 0);
2139
if (!__pyx_t_14) break;
2140
2141
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":77
2142
* else:
2143
* while q < B:
2144
* a[q] = a[p]*a[q//p] - p*a[q/(p*p)] # <<<<<<<<<<<<<<
2145
* q *= p
2146
*
2147
*/
2148
if (unlikely(__pyx_v_p == 0)) {
2149
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
2150
__PYX_ERR(0, 77, __pyx_L1_error)
2151
}
2152
else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_p == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_q))) {
2153
PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
2154
__PYX_ERR(0, 77, __pyx_L1_error)
2155
}
2156
__pyx_t_17 = (__pyx_v_p * __pyx_v_p);
2157
if (unlikely(__pyx_t_17 == 0)) {
2158
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
2159
__PYX_ERR(0, 77, __pyx_L1_error)
2160
}
2161
else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_t_17 == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_q))) {
2162
PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
2163
__PYX_ERR(0, 77, __pyx_L1_error)
2164
}
2165
(__pyx_v_a[__pyx_v_q]) = (((__pyx_v_a[__pyx_v_p]) * (__pyx_v_a[__Pyx_div_Py_ssize_t(__pyx_v_q, __pyx_v_p)])) - (__pyx_v_p * (__pyx_v_a[__Pyx_div_Py_ssize_t(__pyx_v_q, __pyx_t_17)])));
2166
2167
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":78
2168
* while q < B:
2169
* a[q] = a[p]*a[q//p] - p*a[q/(p*p)]
2170
* q *= p # <<<<<<<<<<<<<<
2171
*
2172
* ##############################################################
2173
*/
2174
__pyx_v_q = (__pyx_v_q * __pyx_v_p);
2175
}
2176
}
2177
__pyx_L16:;
2178
}
2179
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2180
2181
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":84
2182
* # since we now have all prime powers.
2183
* ##############################################################
2184
* primes = ap_dict.keys(); primes.sort() # todo: speedup? # <<<<<<<<<<<<<<
2185
* for p in primes:
2186
* q = p
2187
*/
2188
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_ap_dict, __pyx_n_s_keys); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 84, __pyx_L1_error)
2189
__Pyx_GOTREF(__pyx_t_8);
2190
__pyx_t_6 = NULL;
2191
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
2192
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
2193
if (likely(__pyx_t_6)) {
2194
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
2195
__Pyx_INCREF(__pyx_t_6);
2196
__Pyx_INCREF(function);
2197
__Pyx_DECREF_SET(__pyx_t_8, function);
2198
}
2199
}
2200
if (__pyx_t_6) {
2201
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
2202
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2203
} else {
2204
__pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
2205
}
2206
__Pyx_GOTREF(__pyx_t_2);
2207
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2208
__pyx_v_primes = __pyx_t_2;
2209
__pyx_t_2 = 0;
2210
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_primes, __pyx_n_s_sort); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 84, __pyx_L1_error)
2211
__Pyx_GOTREF(__pyx_t_8);
2212
__pyx_t_6 = NULL;
2213
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
2214
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
2215
if (likely(__pyx_t_6)) {
2216
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
2217
__Pyx_INCREF(__pyx_t_6);
2218
__Pyx_INCREF(function);
2219
__Pyx_DECREF_SET(__pyx_t_8, function);
2220
}
2221
}
2222
if (__pyx_t_6) {
2223
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
2224
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2225
} else {
2226
__pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
2227
}
2228
__Pyx_GOTREF(__pyx_t_2);
2229
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2230
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2231
2232
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":85
2233
* ##############################################################
2234
* primes = ap_dict.keys(); primes.sort() # todo: speedup?
2235
* for p in primes: # <<<<<<<<<<<<<<
2236
* q = p
2237
* while q < B:
2238
*/
2239
if (likely(PyList_CheckExact(__pyx_v_primes)) || PyTuple_CheckExact(__pyx_v_primes)) {
2240
__pyx_t_2 = __pyx_v_primes; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
2241
__pyx_t_18 = NULL;
2242
} else {
2243
__pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_primes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error)
2244
__Pyx_GOTREF(__pyx_t_2);
2245
__pyx_t_18 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 85, __pyx_L1_error)
2246
}
2247
for (;;) {
2248
if (likely(!__pyx_t_18)) {
2249
if (likely(PyList_CheckExact(__pyx_t_2))) {
2250
if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
2251
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2252
__pyx_t_8 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_8); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 85, __pyx_L1_error)
2253
#else
2254
__pyx_t_8 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 85, __pyx_L1_error)
2255
__Pyx_GOTREF(__pyx_t_8);
2256
#endif
2257
} else {
2258
if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
2259
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2260
__pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_8); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 85, __pyx_L1_error)
2261
#else
2262
__pyx_t_8 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 85, __pyx_L1_error)
2263
__Pyx_GOTREF(__pyx_t_8);
2264
#endif
2265
}
2266
} else {
2267
__pyx_t_8 = __pyx_t_18(__pyx_t_2);
2268
if (unlikely(!__pyx_t_8)) {
2269
PyObject* exc_type = PyErr_Occurred();
2270
if (exc_type) {
2271
if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
2272
else __PYX_ERR(0, 85, __pyx_L1_error)
2273
}
2274
break;
2275
}
2276
__Pyx_GOTREF(__pyx_t_8);
2277
}
2278
__pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error)
2279
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2280
__pyx_v_p = __pyx_t_4;
2281
2282
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":86
2283
* primes = ap_dict.keys(); primes.sort() # todo: speedup?
2284
* for p in primes:
2285
* q = p # <<<<<<<<<<<<<<
2286
* while q < B:
2287
* # set a_{qn} = a_q * a_n for each n coprime to p with q*n < B with a_n known.
2288
*/
2289
__pyx_v_q = __pyx_v_p;
2290
2291
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":87
2292
* for p in primes:
2293
* q = p
2294
* while q < B: # <<<<<<<<<<<<<<
2295
* # set a_{qn} = a_q * a_n for each n coprime to p with q*n < B with a_n known.
2296
* n = 2
2297
*/
2298
while (1) {
2299
__pyx_t_14 = ((__pyx_v_q < __pyx_v_B) != 0);
2300
if (!__pyx_t_14) break;
2301
2302
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":89
2303
* while q < B:
2304
* # set a_{qn} = a_q * a_n for each n coprime to p with q*n < B with a_n known.
2305
* n = 2 # <<<<<<<<<<<<<<
2306
* while n*q < B:
2307
* if n%p and a[n] != UNKNOWN:
2308
*/
2309
__pyx_v_n = 2;
2310
2311
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":90
2312
* # set a_{qn} = a_q * a_n for each n coprime to p with q*n < B with a_n known.
2313
* n = 2
2314
* while n*q < B: # <<<<<<<<<<<<<<
2315
* if n%p and a[n] != UNKNOWN:
2316
* a[q*n] = a[q]*a[n]
2317
*/
2318
while (1) {
2319
__pyx_t_14 = (((__pyx_v_n * __pyx_v_q) < __pyx_v_B) != 0);
2320
if (!__pyx_t_14) break;
2321
2322
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":91
2323
* n = 2
2324
* while n*q < B:
2325
* if n%p and a[n] != UNKNOWN: # <<<<<<<<<<<<<<
2326
* a[q*n] = a[q]*a[n]
2327
* n += 1
2328
*/
2329
if (unlikely(__pyx_v_p == 0)) {
2330
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
2331
__PYX_ERR(0, 91, __pyx_L1_error)
2332
}
2333
__pyx_t_13 = (__Pyx_mod_Py_ssize_t(__pyx_v_n, __pyx_v_p) != 0);
2334
if (__pyx_t_13) {
2335
} else {
2336
__pyx_t_14 = __pyx_t_13;
2337
goto __pyx_L28_bool_binop_done;
2338
}
2339
__pyx_t_13 = (((__pyx_v_a[__pyx_v_n]) != __pyx_v_UNKNOWN) != 0);
2340
__pyx_t_14 = __pyx_t_13;
2341
__pyx_L28_bool_binop_done:;
2342
if (__pyx_t_14) {
2343
2344
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":92
2345
* while n*q < B:
2346
* if n%p and a[n] != UNKNOWN:
2347
* a[q*n] = a[q]*a[n] # <<<<<<<<<<<<<<
2348
* n += 1
2349
* q *= p
2350
*/
2351
(__pyx_v_a[(__pyx_v_q * __pyx_v_n)]) = ((__pyx_v_a[__pyx_v_q]) * (__pyx_v_a[__pyx_v_n]));
2352
2353
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":91
2354
* n = 2
2355
* while n*q < B:
2356
* if n%p and a[n] != UNKNOWN: # <<<<<<<<<<<<<<
2357
* a[q*n] = a[q]*a[n]
2358
* n += 1
2359
*/
2360
}
2361
2362
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":93
2363
* if n%p and a[n] != UNKNOWN:
2364
* a[q*n] = a[q]*a[n]
2365
* n += 1 # <<<<<<<<<<<<<<
2366
* q *= p
2367
*
2368
*/
2369
__pyx_v_n = (__pyx_v_n + 1);
2370
}
2371
2372
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":94
2373
* a[q*n] = a[q]*a[n]
2374
* n += 1
2375
* q *= p # <<<<<<<<<<<<<<
2376
*
2377
*
2378
*/
2379
__pyx_v_q = (__pyx_v_q * __pyx_v_p);
2380
}
2381
2382
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":85
2383
* ##############################################################
2384
* primes = ap_dict.keys(); primes.sort() # todo: speedup?
2385
* for p in primes: # <<<<<<<<<<<<<<
2386
* q = p
2387
* while q < B:
2388
*/
2389
}
2390
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2391
2392
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":31
2393
* cdef Py_ssize_t B
2394
*
2395
* def __init__(self, E, Py_ssize_t B): # <<<<<<<<<<<<<<
2396
* self.a = IntList(B)
2397
* cdef int* a = self.a._values
2398
*/
2399
2400
/* function exit code */
2401
__pyx_r = 0;
2402
goto __pyx_L0;
2403
__pyx_L1_error:;
2404
__Pyx_XDECREF(__pyx_t_1);
2405
__Pyx_XDECREF(__pyx_t_2);
2406
__Pyx_XDECREF(__pyx_t_6);
2407
__Pyx_XDECREF(__pyx_t_8);
2408
__Pyx_XDECREF(__pyx_t_9);
2409
__Pyx_XDECREF(__pyx_t_10);
2410
__Pyx_XDECREF(__pyx_t_11);
2411
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.fast_twist.anlist.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2412
__pyx_r = -1;
2413
__pyx_L0:;
2414
__Pyx_XDECREF(__pyx_v_a1);
2415
__Pyx_XDECREF(__pyx_v_a2);
2416
__Pyx_XDECREF(__pyx_v_a3);
2417
__Pyx_XDECREF(__pyx_v_a4);
2418
__Pyx_XDECREF(__pyx_v_a6);
2419
__Pyx_XDECREF(__pyx_v__);
2420
__Pyx_XDECREF(__pyx_v_R);
2421
__Pyx_XDECREF(__pyx_v_f);
2422
__Pyx_XDECREF(__pyx_v_C);
2423
__Pyx_XDECREF(__pyx_v_ap_dict);
2424
__Pyx_XDECREF(__pyx_v_v);
2425
__Pyx_XDECREF(__pyx_v_primes);
2426
__Pyx_RefNannyFinishContext();
2427
return __pyx_r;
2428
}
2429
2430
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":97
2431
*
2432
*
2433
* def __repr__(self): # <<<<<<<<<<<<<<
2434
* return "List of coefficients a_n(E)."
2435
*
2436
*/
2437
2438
/* Python wrapper */
2439
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_3__repr__(PyObject *__pyx_v_self); /*proto*/
2440
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_2__repr__[] = "File: fast_twist.pyx (starting at line 97)";
2441
#if CYTHON_COMPILING_IN_CPYTHON
2442
struct wrapperbase __pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_2__repr__;
2443
#endif
2444
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_3__repr__(PyObject *__pyx_v_self) {
2445
PyObject *__pyx_r = 0;
2446
__Pyx_RefNannyDeclarations
2447
__Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
2448
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_2__repr__(((struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *)__pyx_v_self));
2449
2450
/* function exit code */
2451
__Pyx_RefNannyFinishContext();
2452
return __pyx_r;
2453
}
2454
2455
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_2__repr__(CYTHON_UNUSED struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *__pyx_v_self) {
2456
PyObject *__pyx_r = NULL;
2457
__Pyx_RefNannyDeclarations
2458
__Pyx_RefNannySetupContext("__repr__", 0);
2459
2460
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":98
2461
*
2462
* def __repr__(self):
2463
* return "List of coefficients a_n(E)." # <<<<<<<<<<<<<<
2464
*
2465
* def __getitem__(self, Py_ssize_t i):
2466
*/
2467
__Pyx_XDECREF(__pyx_r);
2468
__Pyx_INCREF(__pyx_kp_s_List_of_coefficients_a_n_E);
2469
__pyx_r = __pyx_kp_s_List_of_coefficients_a_n_E;
2470
goto __pyx_L0;
2471
2472
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":97
2473
*
2474
*
2475
* def __repr__(self): # <<<<<<<<<<<<<<
2476
* return "List of coefficients a_n(E)."
2477
*
2478
*/
2479
2480
/* function exit code */
2481
__pyx_L0:;
2482
__Pyx_XGIVEREF(__pyx_r);
2483
__Pyx_RefNannyFinishContext();
2484
return __pyx_r;
2485
}
2486
2487
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":100
2488
* return "List of coefficients a_n(E)."
2489
*
2490
* def __getitem__(self, Py_ssize_t i): # <<<<<<<<<<<<<<
2491
* return self.a[i]
2492
*
2493
*/
2494
2495
/* Python wrapper */
2496
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_i); /*proto*/
2497
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_4__getitem__[] = "File: fast_twist.pyx (starting at line 100)";
2498
#if CYTHON_COMPILING_IN_CPYTHON
2499
struct wrapperbase __pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_4__getitem__;
2500
#endif
2501
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_i) {
2502
Py_ssize_t __pyx_v_i;
2503
PyObject *__pyx_r = 0;
2504
__Pyx_RefNannyDeclarations
2505
__Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
2506
assert(__pyx_arg_i); {
2507
__pyx_v_i = __Pyx_PyIndex_AsSsize_t(__pyx_arg_i); if (unlikely((__pyx_v_i == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 100, __pyx_L3_error)
2508
}
2509
goto __pyx_L4_argument_unpacking_done;
2510
__pyx_L3_error:;
2511
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.fast_twist.anlist.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2512
__Pyx_RefNannyFinishContext();
2513
return NULL;
2514
__pyx_L4_argument_unpacking_done:;
2515
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_4__getitem__(((struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *)__pyx_v_self), ((Py_ssize_t)__pyx_v_i));
2516
2517
/* function exit code */
2518
__Pyx_RefNannyFinishContext();
2519
return __pyx_r;
2520
}
2521
2522
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_4__getitem__(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *__pyx_v_self, Py_ssize_t __pyx_v_i) {
2523
PyObject *__pyx_r = NULL;
2524
__Pyx_RefNannyDeclarations
2525
PyObject *__pyx_t_1 = NULL;
2526
__Pyx_RefNannySetupContext("__getitem__", 0);
2527
2528
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":101
2529
*
2530
* def __getitem__(self, Py_ssize_t i):
2531
* return self.a[i] # <<<<<<<<<<<<<<
2532
*
2533
* cdef class FastHeegnerTwists:
2534
*/
2535
__Pyx_XDECREF(__pyx_r);
2536
__pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->a), __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error)
2537
__Pyx_GOTREF(__pyx_t_1);
2538
__pyx_r = __pyx_t_1;
2539
__pyx_t_1 = 0;
2540
goto __pyx_L0;
2541
2542
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":100
2543
* return "List of coefficients a_n(E)."
2544
*
2545
* def __getitem__(self, Py_ssize_t i): # <<<<<<<<<<<<<<
2546
* return self.a[i]
2547
*
2548
*/
2549
2550
/* function exit code */
2551
__pyx_L1_error:;
2552
__Pyx_XDECREF(__pyx_t_1);
2553
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.fast_twist.anlist.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2554
__pyx_r = NULL;
2555
__pyx_L0:;
2556
__Pyx_XGIVEREF(__pyx_r);
2557
__Pyx_RefNannyFinishContext();
2558
return __pyx_r;
2559
}
2560
2561
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":111
2562
* cdef int N
2563
*
2564
* def __init__(self, E, Py_ssize_t B): # <<<<<<<<<<<<<<
2565
* self.E = E
2566
* self.N = E.conductor()
2567
*/
2568
2569
/* Python wrapper */
2570
static int __pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2571
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists___init__[] = "File: fast_twist.pyx (starting at line 111)";
2572
#if CYTHON_COMPILING_IN_CPYTHON
2573
struct wrapperbase __pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists___init__;
2574
#endif
2575
static int __pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2576
PyObject *__pyx_v_E = 0;
2577
Py_ssize_t __pyx_v_B;
2578
int __pyx_r;
2579
__Pyx_RefNannyDeclarations
2580
__Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
2581
{
2582
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_E,&__pyx_n_s_B,0};
2583
PyObject* values[2] = {0,0};
2584
if (unlikely(__pyx_kwds)) {
2585
Py_ssize_t kw_args;
2586
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2587
switch (pos_args) {
2588
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2589
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2590
case 0: break;
2591
default: goto __pyx_L5_argtuple_error;
2592
}
2593
kw_args = PyDict_Size(__pyx_kwds);
2594
switch (pos_args) {
2595
case 0:
2596
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_E)) != 0)) kw_args--;
2597
else goto __pyx_L5_argtuple_error;
2598
case 1:
2599
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_B)) != 0)) kw_args--;
2600
else {
2601
__Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 111, __pyx_L3_error)
2602
}
2603
}
2604
if (unlikely(kw_args > 0)) {
2605
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 111, __pyx_L3_error)
2606
}
2607
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
2608
goto __pyx_L5_argtuple_error;
2609
} else {
2610
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2611
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2612
}
2613
__pyx_v_E = values[0];
2614
__pyx_v_B = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_B == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 111, __pyx_L3_error)
2615
}
2616
goto __pyx_L4_argument_unpacking_done;
2617
__pyx_L5_argtuple_error:;
2618
__Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 111, __pyx_L3_error)
2619
__pyx_L3_error:;
2620
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.fast_twist.FastHeegnerTwists.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2621
__Pyx_RefNannyFinishContext();
2622
return -1;
2623
__pyx_L4_argument_unpacking_done:;
2624
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists___init__(((struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *)__pyx_v_self), __pyx_v_E, __pyx_v_B);
2625
2626
/* function exit code */
2627
__Pyx_RefNannyFinishContext();
2628
return __pyx_r;
2629
}
2630
2631
static int __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists___init__(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *__pyx_v_self, PyObject *__pyx_v_E, Py_ssize_t __pyx_v_B) {
2632
Py_ssize_t __pyx_v_i;
2633
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *__pyx_v_v = 0;
2634
int __pyx_r;
2635
__Pyx_RefNannyDeclarations
2636
PyObject *__pyx_t_1 = NULL;
2637
PyObject *__pyx_t_2 = NULL;
2638
PyObject *__pyx_t_3 = NULL;
2639
int __pyx_t_4;
2640
Py_ssize_t __pyx_t_5;
2641
Py_ssize_t __pyx_t_6;
2642
__Pyx_RefNannySetupContext("__init__", 0);
2643
2644
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":112
2645
*
2646
* def __init__(self, E, Py_ssize_t B):
2647
* self.E = E # <<<<<<<<<<<<<<
2648
* self.N = E.conductor()
2649
* #self.bad_primes = E.conductor().prime_divisors()
2650
*/
2651
__Pyx_INCREF(__pyx_v_E);
2652
__Pyx_GIVEREF(__pyx_v_E);
2653
__Pyx_GOTREF(__pyx_v_self->E);
2654
__Pyx_DECREF(__pyx_v_self->E);
2655
__pyx_v_self->E = __pyx_v_E;
2656
2657
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":113
2658
* def __init__(self, E, Py_ssize_t B):
2659
* self.E = E
2660
* self.N = E.conductor() # <<<<<<<<<<<<<<
2661
* #self.bad_primes = E.conductor().prime_divisors()
2662
* self.B = B
2663
*/
2664
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_E, __pyx_n_s_conductor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
2665
__Pyx_GOTREF(__pyx_t_2);
2666
__pyx_t_3 = NULL;
2667
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
2668
__pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
2669
if (likely(__pyx_t_3)) {
2670
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2671
__Pyx_INCREF(__pyx_t_3);
2672
__Pyx_INCREF(function);
2673
__Pyx_DECREF_SET(__pyx_t_2, function);
2674
}
2675
}
2676
if (__pyx_t_3) {
2677
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error)
2678
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2679
} else {
2680
__pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error)
2681
}
2682
__Pyx_GOTREF(__pyx_t_1);
2683
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2684
__pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 113, __pyx_L1_error)
2685
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2686
__pyx_v_self->N = __pyx_t_4;
2687
2688
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":115
2689
* self.N = E.conductor()
2690
* #self.bad_primes = E.conductor().prime_divisors()
2691
* self.B = B # <<<<<<<<<<<<<<
2692
* self.a = TimeSeries(B)
2693
* cdef Py_ssize_t i
2694
*/
2695
__pyx_v_self->B = __pyx_v_B;
2696
2697
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":116
2698
* #self.bad_primes = E.conductor().prime_divisors()
2699
* self.B = B
2700
* self.a = TimeSeries(B) # <<<<<<<<<<<<<<
2701
* cdef Py_ssize_t i
2702
* cdef anlist v = anlist(E, B)
2703
*/
2704
__pyx_t_1 = PyInt_FromSsize_t(__pyx_v_B); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error)
2705
__Pyx_GOTREF(__pyx_t_1);
2706
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error)
2707
__Pyx_GOTREF(__pyx_t_2);
2708
__Pyx_GIVEREF(__pyx_t_1);
2709
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
2710
__pyx_t_1 = 0;
2711
__pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4sage_7finance_11time_series_TimeSeries), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error)
2712
__Pyx_GOTREF(__pyx_t_1);
2713
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2714
__Pyx_GIVEREF(__pyx_t_1);
2715
__Pyx_GOTREF(__pyx_v_self->a);
2716
__Pyx_DECREF(((PyObject *)__pyx_v_self->a));
2717
__pyx_v_self->a = ((struct __pyx_obj_4sage_7finance_11time_series_TimeSeries *)__pyx_t_1);
2718
__pyx_t_1 = 0;
2719
2720
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":118
2721
* self.a = TimeSeries(B)
2722
* cdef Py_ssize_t i
2723
* cdef anlist v = anlist(E, B) # <<<<<<<<<<<<<<
2724
* for i in range(B):
2725
* self.a[i] = v.a[i]
2726
*/
2727
__pyx_t_1 = PyInt_FromSsize_t(__pyx_v_B); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error)
2728
__Pyx_GOTREF(__pyx_t_1);
2729
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error)
2730
__Pyx_GOTREF(__pyx_t_2);
2731
__Pyx_INCREF(__pyx_v_E);
2732
__Pyx_GIVEREF(__pyx_v_E);
2733
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_E);
2734
__Pyx_GIVEREF(__pyx_t_1);
2735
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
2736
__pyx_t_1 = 0;
2737
__pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error)
2738
__Pyx_GOTREF(__pyx_t_1);
2739
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2740
__pyx_v_v = ((struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *)__pyx_t_1);
2741
__pyx_t_1 = 0;
2742
2743
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":119
2744
* cdef Py_ssize_t i
2745
* cdef anlist v = anlist(E, B)
2746
* for i in range(B): # <<<<<<<<<<<<<<
2747
* self.a[i] = v.a[i]
2748
* self.root_number = E.root_number()
2749
*/
2750
__pyx_t_5 = __pyx_v_B;
2751
for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
2752
__pyx_v_i = __pyx_t_6;
2753
2754
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":120
2755
* cdef anlist v = anlist(E, B)
2756
* for i in range(B):
2757
* self.a[i] = v.a[i] # <<<<<<<<<<<<<<
2758
* self.root_number = E.root_number()
2759
*
2760
*/
2761
__pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_v->a), __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error)
2762
__Pyx_GOTREF(__pyx_t_1);
2763
if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_v_self->a), __pyx_v_i, __pyx_t_1, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(0, 120, __pyx_L1_error)
2764
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2765
}
2766
2767
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":121
2768
* for i in range(B):
2769
* self.a[i] = v.a[i]
2770
* self.root_number = E.root_number() # <<<<<<<<<<<<<<
2771
*
2772
* def __repr__(self):
2773
*/
2774
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_E, __pyx_n_s_root_number); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error)
2775
__Pyx_GOTREF(__pyx_t_2);
2776
__pyx_t_3 = NULL;
2777
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
2778
__pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
2779
if (likely(__pyx_t_3)) {
2780
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2781
__Pyx_INCREF(__pyx_t_3);
2782
__Pyx_INCREF(function);
2783
__Pyx_DECREF_SET(__pyx_t_2, function);
2784
}
2785
}
2786
if (__pyx_t_3) {
2787
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error)
2788
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2789
} else {
2790
__pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error)
2791
}
2792
__Pyx_GOTREF(__pyx_t_1);
2793
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2794
__pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error)
2795
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2796
__pyx_v_self->root_number = __pyx_t_4;
2797
2798
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":111
2799
* cdef int N
2800
*
2801
* def __init__(self, E, Py_ssize_t B): # <<<<<<<<<<<<<<
2802
* self.E = E
2803
* self.N = E.conductor()
2804
*/
2805
2806
/* function exit code */
2807
__pyx_r = 0;
2808
goto __pyx_L0;
2809
__pyx_L1_error:;
2810
__Pyx_XDECREF(__pyx_t_1);
2811
__Pyx_XDECREF(__pyx_t_2);
2812
__Pyx_XDECREF(__pyx_t_3);
2813
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.fast_twist.FastHeegnerTwists.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2814
__pyx_r = -1;
2815
__pyx_L0:;
2816
__Pyx_XDECREF((PyObject *)__pyx_v_v);
2817
__Pyx_RefNannyFinishContext();
2818
return __pyx_r;
2819
}
2820
2821
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":123
2822
* self.root_number = E.root_number()
2823
*
2824
* def __repr__(self): # <<<<<<<<<<<<<<
2825
* return "Fast Heegner twist object associated to %s"%self.E
2826
*
2827
*/
2828
2829
/* Python wrapper */
2830
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_3__repr__(PyObject *__pyx_v_self); /*proto*/
2831
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_2__repr__[] = "File: fast_twist.pyx (starting at line 123)";
2832
#if CYTHON_COMPILING_IN_CPYTHON
2833
struct wrapperbase __pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_2__repr__;
2834
#endif
2835
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_3__repr__(PyObject *__pyx_v_self) {
2836
PyObject *__pyx_r = 0;
2837
__Pyx_RefNannyDeclarations
2838
__Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
2839
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_2__repr__(((struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *)__pyx_v_self));
2840
2841
/* function exit code */
2842
__Pyx_RefNannyFinishContext();
2843
return __pyx_r;
2844
}
2845
2846
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_2__repr__(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *__pyx_v_self) {
2847
PyObject *__pyx_r = NULL;
2848
__Pyx_RefNannyDeclarations
2849
PyObject *__pyx_t_1 = NULL;
2850
__Pyx_RefNannySetupContext("__repr__", 0);
2851
2852
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":124
2853
*
2854
* def __repr__(self):
2855
* return "Fast Heegner twist object associated to %s"%self.E # <<<<<<<<<<<<<<
2856
*
2857
* def elliptic_curve(self):
2858
*/
2859
__Pyx_XDECREF(__pyx_r);
2860
__pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Fast_Heegner_twist_object_associ, __pyx_v_self->E); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
2861
__Pyx_GOTREF(__pyx_t_1);
2862
__pyx_r = __pyx_t_1;
2863
__pyx_t_1 = 0;
2864
goto __pyx_L0;
2865
2866
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":123
2867
* self.root_number = E.root_number()
2868
*
2869
* def __repr__(self): # <<<<<<<<<<<<<<
2870
* return "Fast Heegner twist object associated to %s"%self.E
2871
*
2872
*/
2873
2874
/* function exit code */
2875
__pyx_L1_error:;
2876
__Pyx_XDECREF(__pyx_t_1);
2877
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.fast_twist.FastHeegnerTwists.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2878
__pyx_r = NULL;
2879
__pyx_L0:;
2880
__Pyx_XGIVEREF(__pyx_r);
2881
__Pyx_RefNannyFinishContext();
2882
return __pyx_r;
2883
}
2884
2885
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":126
2886
* return "Fast Heegner twist object associated to %s"%self.E
2887
*
2888
* def elliptic_curve(self): # <<<<<<<<<<<<<<
2889
* return self.E
2890
*
2891
*/
2892
2893
/* Python wrapper */
2894
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_5elliptic_curve(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
2895
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_4elliptic_curve[] = "File: fast_twist.pyx (starting at line 126)";
2896
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_5elliptic_curve(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
2897
PyObject *__pyx_r = 0;
2898
__Pyx_RefNannyDeclarations
2899
__Pyx_RefNannySetupContext("elliptic_curve (wrapper)", 0);
2900
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_4elliptic_curve(((struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *)__pyx_v_self));
2901
2902
/* function exit code */
2903
__Pyx_RefNannyFinishContext();
2904
return __pyx_r;
2905
}
2906
2907
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_4elliptic_curve(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *__pyx_v_self) {
2908
PyObject *__pyx_r = NULL;
2909
__Pyx_RefNannyDeclarations
2910
__Pyx_RefNannySetupContext("elliptic_curve", 0);
2911
2912
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":127
2913
*
2914
* def elliptic_curve(self):
2915
* return self.E # <<<<<<<<<<<<<<
2916
*
2917
* def discs(self, bound):
2918
*/
2919
__Pyx_XDECREF(__pyx_r);
2920
__Pyx_INCREF(__pyx_v_self->E);
2921
__pyx_r = __pyx_v_self->E;
2922
goto __pyx_L0;
2923
2924
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":126
2925
* return "Fast Heegner twist object associated to %s"%self.E
2926
*
2927
* def elliptic_curve(self): # <<<<<<<<<<<<<<
2928
* return self.E
2929
*
2930
*/
2931
2932
/* function exit code */
2933
__pyx_L0:;
2934
__Pyx_XGIVEREF(__pyx_r);
2935
__Pyx_RefNannyFinishContext();
2936
return __pyx_r;
2937
}
2938
2939
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":129
2940
* return self.E
2941
*
2942
* def discs(self, bound): # <<<<<<<<<<<<<<
2943
* return self.E.heegner_discriminants(bound)
2944
*
2945
*/
2946
2947
/* Python wrapper */
2948
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_7discs(PyObject *__pyx_v_self, PyObject *__pyx_v_bound); /*proto*/
2949
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_6discs[] = "File: fast_twist.pyx (starting at line 129)";
2950
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_7discs(PyObject *__pyx_v_self, PyObject *__pyx_v_bound) {
2951
PyObject *__pyx_r = 0;
2952
__Pyx_RefNannyDeclarations
2953
__Pyx_RefNannySetupContext("discs (wrapper)", 0);
2954
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_6discs(((struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *)__pyx_v_self), ((PyObject *)__pyx_v_bound));
2955
2956
/* function exit code */
2957
__Pyx_RefNannyFinishContext();
2958
return __pyx_r;
2959
}
2960
2961
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_6discs(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *__pyx_v_self, PyObject *__pyx_v_bound) {
2962
PyObject *__pyx_r = NULL;
2963
__Pyx_RefNannyDeclarations
2964
PyObject *__pyx_t_1 = NULL;
2965
PyObject *__pyx_t_2 = NULL;
2966
PyObject *__pyx_t_3 = NULL;
2967
PyObject *__pyx_t_4 = NULL;
2968
__Pyx_RefNannySetupContext("discs", 0);
2969
2970
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":130
2971
*
2972
* def discs(self, bound):
2973
* return self.E.heegner_discriminants(bound) # <<<<<<<<<<<<<<
2974
*
2975
* def twist_special_value(self, long D, tol=1e-6):
2976
*/
2977
__Pyx_XDECREF(__pyx_r);
2978
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->E, __pyx_n_s_heegner_discriminants); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error)
2979
__Pyx_GOTREF(__pyx_t_2);
2980
__pyx_t_3 = NULL;
2981
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
2982
__pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
2983
if (likely(__pyx_t_3)) {
2984
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2985
__Pyx_INCREF(__pyx_t_3);
2986
__Pyx_INCREF(function);
2987
__Pyx_DECREF_SET(__pyx_t_2, function);
2988
}
2989
}
2990
if (!__pyx_t_3) {
2991
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_bound); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
2992
__Pyx_GOTREF(__pyx_t_1);
2993
} else {
2994
#if CYTHON_FAST_PYCALL
2995
if (PyFunction_Check(__pyx_t_2)) {
2996
PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_bound};
2997
__pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
2998
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2999
__Pyx_GOTREF(__pyx_t_1);
3000
} else
3001
#endif
3002
#if CYTHON_FAST_PYCCALL
3003
if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
3004
PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_bound};
3005
__pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
3006
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3007
__Pyx_GOTREF(__pyx_t_1);
3008
} else
3009
#endif
3010
{
3011
__pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 130, __pyx_L1_error)
3012
__Pyx_GOTREF(__pyx_t_4);
3013
__Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
3014
__Pyx_INCREF(__pyx_v_bound);
3015
__Pyx_GIVEREF(__pyx_v_bound);
3016
PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_bound);
3017
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
3018
__Pyx_GOTREF(__pyx_t_1);
3019
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3020
}
3021
}
3022
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3023
__pyx_r = __pyx_t_1;
3024
__pyx_t_1 = 0;
3025
goto __pyx_L0;
3026
3027
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":129
3028
* return self.E
3029
*
3030
* def discs(self, bound): # <<<<<<<<<<<<<<
3031
* return self.E.heegner_discriminants(bound)
3032
*
3033
*/
3034
3035
/* function exit code */
3036
__pyx_L1_error:;
3037
__Pyx_XDECREF(__pyx_t_1);
3038
__Pyx_XDECREF(__pyx_t_2);
3039
__Pyx_XDECREF(__pyx_t_3);
3040
__Pyx_XDECREF(__pyx_t_4);
3041
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.fast_twist.FastHeegnerTwists.discs", __pyx_clineno, __pyx_lineno, __pyx_filename);
3042
__pyx_r = NULL;
3043
__pyx_L0:;
3044
__Pyx_XGIVEREF(__pyx_r);
3045
__Pyx_RefNannyFinishContext();
3046
return __pyx_r;
3047
}
3048
3049
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":132
3050
* return self.E.heegner_discriminants(bound)
3051
*
3052
* def twist_special_value(self, long D, tol=1e-6): # <<<<<<<<<<<<<<
3053
* # 1. Make floating point table of value of the quadratic
3054
* # symbol (D/-) modulo 4*|D|.
3055
*/
3056
3057
/* Python wrapper */
3058
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_9twist_special_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3059
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_8twist_special_value[] = "File: fast_twist.pyx (starting at line 132)";
3060
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_9twist_special_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3061
long __pyx_v_D;
3062
PyObject *__pyx_v_tol = 0;
3063
PyObject *__pyx_r = 0;
3064
__Pyx_RefNannyDeclarations
3065
__Pyx_RefNannySetupContext("twist_special_value (wrapper)", 0);
3066
{
3067
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_D,&__pyx_n_s_tol,0};
3068
PyObject* values[2] = {0,0};
3069
values[1] = ((PyObject *)__pyx_float_1eneg_6);
3070
if (unlikely(__pyx_kwds)) {
3071
Py_ssize_t kw_args;
3072
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3073
switch (pos_args) {
3074
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3075
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3076
case 0: break;
3077
default: goto __pyx_L5_argtuple_error;
3078
}
3079
kw_args = PyDict_Size(__pyx_kwds);
3080
switch (pos_args) {
3081
case 0:
3082
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_D)) != 0)) kw_args--;
3083
else goto __pyx_L5_argtuple_error;
3084
case 1:
3085
if (kw_args > 0) {
3086
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tol);
3087
if (value) { values[1] = value; kw_args--; }
3088
}
3089
}
3090
if (unlikely(kw_args > 0)) {
3091
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "twist_special_value") < 0)) __PYX_ERR(0, 132, __pyx_L3_error)
3092
}
3093
} else {
3094
switch (PyTuple_GET_SIZE(__pyx_args)) {
3095
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3096
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3097
break;
3098
default: goto __pyx_L5_argtuple_error;
3099
}
3100
}
3101
__pyx_v_D = __Pyx_PyInt_As_long(values[0]); if (unlikely((__pyx_v_D == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 132, __pyx_L3_error)
3102
__pyx_v_tol = values[1];
3103
}
3104
goto __pyx_L4_argument_unpacking_done;
3105
__pyx_L5_argtuple_error:;
3106
__Pyx_RaiseArgtupleInvalid("twist_special_value", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 132, __pyx_L3_error)
3107
__pyx_L3_error:;
3108
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.fast_twist.FastHeegnerTwists.twist_special_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
3109
__Pyx_RefNannyFinishContext();
3110
return NULL;
3111
__pyx_L4_argument_unpacking_done:;
3112
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_8twist_special_value(((struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *)__pyx_v_self), __pyx_v_D, __pyx_v_tol);
3113
3114
/* function exit code */
3115
__Pyx_RefNannyFinishContext();
3116
return __pyx_r;
3117
}
3118
3119
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_8twist_special_value(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *__pyx_v_self, long __pyx_v_D, PyObject *__pyx_v_tol) {
3120
long __pyx_v_D4;
3121
struct __pyx_obj_4sage_7finance_11time_series_TimeSeries *__pyx_v_chi = NULL;
3122
int __pyx_v_n;
3123
PyObject *__pyx_v_Dz = NULL;
3124
double __pyx_v_s;
3125
double *__pyx_v_a;
3126
double __pyx_v_X;
3127
Py_ssize_t __pyx_v_nterms;
3128
PyObject *__pyx_r = NULL;
3129
__Pyx_RefNannyDeclarations
3130
unsigned long __pyx_t_1;
3131
PyObject *__pyx_t_2 = NULL;
3132
PyObject *__pyx_t_3 = NULL;
3133
PyObject *__pyx_t_4 = NULL;
3134
PyObject *__pyx_t_5 = NULL;
3135
PyObject *__pyx_t_6 = NULL;
3136
Py_ssize_t __pyx_t_7;
3137
int __pyx_t_8;
3138
double __pyx_t_9;
3139
double *__pyx_t_10;
3140
double __pyx_t_11;
3141
int __pyx_t_12;
3142
__Pyx_RefNannySetupContext("twist_special_value", 0);
3143
3144
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":135
3145
* # 1. Make floating point table of value of the quadratic
3146
* # symbol (D/-) modulo 4*|D|.
3147
* assert D < 0 # <<<<<<<<<<<<<<
3148
* cdef long D4 = abs(D)*4
3149
* chi = TimeSeries(D4)
3150
*/
3151
#ifndef CYTHON_WITHOUT_ASSERTIONS
3152
if (unlikely(!Py_OptimizeFlag)) {
3153
if (unlikely(!((__pyx_v_D < 0) != 0))) {
3154
PyErr_SetNone(PyExc_AssertionError);
3155
__PYX_ERR(0, 135, __pyx_L1_error)
3156
}
3157
}
3158
#endif
3159
3160
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":136
3161
* # symbol (D/-) modulo 4*|D|.
3162
* assert D < 0
3163
* cdef long D4 = abs(D)*4 # <<<<<<<<<<<<<<
3164
* chi = TimeSeries(D4)
3165
* cdef int n
3166
*/
3167
__pyx_t_1 = __Pyx_abs_long(__pyx_v_D);
3168
__pyx_v_D4 = (__pyx_t_1 * 4);
3169
3170
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":137
3171
* assert D < 0
3172
* cdef long D4 = abs(D)*4
3173
* chi = TimeSeries(D4) # <<<<<<<<<<<<<<
3174
* cdef int n
3175
* Dz = ZZ(D)
3176
*/
3177
__pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_D4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
3178
__Pyx_GOTREF(__pyx_t_2);
3179
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error)
3180
__Pyx_GOTREF(__pyx_t_3);
3181
__Pyx_GIVEREF(__pyx_t_2);
3182
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
3183
__pyx_t_2 = 0;
3184
__pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4sage_7finance_11time_series_TimeSeries), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
3185
__Pyx_GOTREF(__pyx_t_2);
3186
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3187
__pyx_v_chi = ((struct __pyx_obj_4sage_7finance_11time_series_TimeSeries *)__pyx_t_2);
3188
__pyx_t_2 = 0;
3189
3190
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":139
3191
* chi = TimeSeries(D4)
3192
* cdef int n
3193
* Dz = ZZ(D) # <<<<<<<<<<<<<<
3194
* for n in range(len(chi)):
3195
* chi._values[n] = Dz.kronecker(n)
3196
*/
3197
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ZZ); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L1_error)
3198
__Pyx_GOTREF(__pyx_t_3);
3199
__pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_D); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L1_error)
3200
__Pyx_GOTREF(__pyx_t_4);
3201
__pyx_t_5 = NULL;
3202
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3203
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
3204
if (likely(__pyx_t_5)) {
3205
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3206
__Pyx_INCREF(__pyx_t_5);
3207
__Pyx_INCREF(function);
3208
__Pyx_DECREF_SET(__pyx_t_3, function);
3209
}
3210
}
3211
if (!__pyx_t_5) {
3212
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
3213
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3214
__Pyx_GOTREF(__pyx_t_2);
3215
} else {
3216
#if CYTHON_FAST_PYCALL
3217
if (PyFunction_Check(__pyx_t_3)) {
3218
PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
3219
__pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
3220
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3221
__Pyx_GOTREF(__pyx_t_2);
3222
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3223
} else
3224
#endif
3225
#if CYTHON_FAST_PYCCALL
3226
if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
3227
PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
3228
__pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
3229
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3230
__Pyx_GOTREF(__pyx_t_2);
3231
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3232
} else
3233
#endif
3234
{
3235
__pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 139, __pyx_L1_error)
3236
__Pyx_GOTREF(__pyx_t_6);
3237
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
3238
__Pyx_GIVEREF(__pyx_t_4);
3239
PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
3240
__pyx_t_4 = 0;
3241
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
3242
__Pyx_GOTREF(__pyx_t_2);
3243
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3244
}
3245
}
3246
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3247
__pyx_v_Dz = __pyx_t_2;
3248
__pyx_t_2 = 0;
3249
3250
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":140
3251
* cdef int n
3252
* Dz = ZZ(D)
3253
* for n in range(len(chi)): # <<<<<<<<<<<<<<
3254
* chi._values[n] = Dz.kronecker(n)
3255
*
3256
*/
3257
__pyx_t_7 = PyObject_Length(((PyObject *)__pyx_v_chi)); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 140, __pyx_L1_error)
3258
for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
3259
__pyx_v_n = __pyx_t_8;
3260
3261
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":141
3262
* Dz = ZZ(D)
3263
* for n in range(len(chi)):
3264
* chi._values[n] = Dz.kronecker(n) # <<<<<<<<<<<<<<
3265
*
3266
* # 2. Approximate either L(E,chi,1) or L'(E,chi,1) depending on
3267
*/
3268
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_Dz, __pyx_n_s_kronecker); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
3269
__Pyx_GOTREF(__pyx_t_3);
3270
__pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 141, __pyx_L1_error)
3271
__Pyx_GOTREF(__pyx_t_6);
3272
__pyx_t_4 = NULL;
3273
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
3274
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
3275
if (likely(__pyx_t_4)) {
3276
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3277
__Pyx_INCREF(__pyx_t_4);
3278
__Pyx_INCREF(function);
3279
__Pyx_DECREF_SET(__pyx_t_3, function);
3280
}
3281
}
3282
if (!__pyx_t_4) {
3283
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
3284
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3285
__Pyx_GOTREF(__pyx_t_2);
3286
} else {
3287
#if CYTHON_FAST_PYCALL
3288
if (PyFunction_Check(__pyx_t_3)) {
3289
PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6};
3290
__pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
3291
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3292
__Pyx_GOTREF(__pyx_t_2);
3293
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3294
} else
3295
#endif
3296
#if CYTHON_FAST_PYCCALL
3297
if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
3298
PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6};
3299
__pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
3300
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3301
__Pyx_GOTREF(__pyx_t_2);
3302
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3303
} else
3304
#endif
3305
{
3306
__pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error)
3307
__Pyx_GOTREF(__pyx_t_5);
3308
__Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
3309
__Pyx_GIVEREF(__pyx_t_6);
3310
PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6);
3311
__pyx_t_6 = 0;
3312
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
3313
__Pyx_GOTREF(__pyx_t_2);
3314
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3315
}
3316
}
3317
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3318
__pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error)
3319
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3320
(__pyx_v_chi->_values[__pyx_v_n]) = __pyx_t_9;
3321
}
3322
3323
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":146
3324
* # root_number of E.
3325
* # Conductor of E^D = N * |D|^2.
3326
* cdef double s = 0 # running sum below # <<<<<<<<<<<<<<
3327
* cdef double* a = self.a._values
3328
* cdef double X = 1/(abs(D) * sqrt(self.N))
3329
*/
3330
__pyx_v_s = 0.0;
3331
3332
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":147
3333
* # Conductor of E^D = N * |D|^2.
3334
* cdef double s = 0 # running sum below
3335
* cdef double* a = self.a._values # <<<<<<<<<<<<<<
3336
* cdef double X = 1/(abs(D) * sqrt(self.N))
3337
*
3338
*/
3339
__pyx_t_10 = __pyx_v_self->a->_values;
3340
__pyx_v_a = __pyx_t_10;
3341
3342
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":148
3343
* cdef double s = 0 # running sum below
3344
* cdef double* a = self.a._values
3345
* cdef double X = 1/(abs(D) * sqrt(self.N)) # <<<<<<<<<<<<<<
3346
*
3347
* cdef Py_ssize_t nterms
3348
*/
3349
__pyx_t_1 = __Pyx_abs_long(__pyx_v_D);
3350
__pyx_t_9 = (__pyx_t_1 * sqrt(__pyx_v_self->N));
3351
if (unlikely(__pyx_t_9 == 0)) {
3352
PyErr_SetString(PyExc_ZeroDivisionError, "float division");
3353
__PYX_ERR(0, 148, __pyx_L1_error)
3354
}
3355
__pyx_v_X = (1.0 / __pyx_t_9);
3356
3357
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":152
3358
* cdef Py_ssize_t nterms
3359
*
3360
* nterms = <int>(log(tol*(1-exp(-2*pi*X))/2)/(-2*pi*X)) + 3 # <<<<<<<<<<<<<<
3361
* if nterms >= self.B:
3362
* raise ValueError, "not enough terms of L-series known (%s needed, but %s known)"%(
3363
*/
3364
__pyx_t_2 = PyFloat_FromDouble((1.0 - exp(((-2.0 * __pyx_v_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_pi) * __pyx_v_X)))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
3365
__Pyx_GOTREF(__pyx_t_2);
3366
__pyx_t_3 = PyNumber_Multiply(__pyx_v_tol, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 152, __pyx_L1_error)
3367
__Pyx_GOTREF(__pyx_t_3);
3368
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3369
__pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_int_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
3370
__Pyx_GOTREF(__pyx_t_2);
3371
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3372
__pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L1_error)
3373
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3374
__pyx_t_11 = log(__pyx_t_9);
3375
__pyx_t_9 = ((-2.0 * __pyx_v_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_pi) * __pyx_v_X);
3376
if (unlikely(__pyx_t_9 == 0)) {
3377
PyErr_SetString(PyExc_ZeroDivisionError, "float division");
3378
__PYX_ERR(0, 152, __pyx_L1_error)
3379
}
3380
__pyx_v_nterms = (((int)(__pyx_t_11 / __pyx_t_9)) + 3);
3381
3382
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":153
3383
*
3384
* nterms = <int>(log(tol*(1-exp(-2*pi*X))/2)/(-2*pi*X)) + 3
3385
* if nterms >= self.B: # <<<<<<<<<<<<<<
3386
* raise ValueError, "not enough terms of L-series known (%s needed, but %s known)"%(
3387
* nterms, self.B)
3388
*/
3389
__pyx_t_12 = ((__pyx_v_nterms >= __pyx_v_self->B) != 0);
3390
if (__pyx_t_12) {
3391
3392
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":155
3393
* if nterms >= self.B:
3394
* raise ValueError, "not enough terms of L-series known (%s needed, but %s known)"%(
3395
* nterms, self.B) # <<<<<<<<<<<<<<
3396
*
3397
* if self.root_number == -1:
3398
*/
3399
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_nterms); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error)
3400
__Pyx_GOTREF(__pyx_t_2);
3401
__pyx_t_3 = PyInt_FromSsize_t(__pyx_v_self->B); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error)
3402
__Pyx_GOTREF(__pyx_t_3);
3403
__pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 155, __pyx_L1_error)
3404
__Pyx_GOTREF(__pyx_t_5);
3405
__Pyx_GIVEREF(__pyx_t_2);
3406
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
3407
__Pyx_GIVEREF(__pyx_t_3);
3408
PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
3409
__pyx_t_2 = 0;
3410
__pyx_t_3 = 0;
3411
3412
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":154
3413
* nterms = <int>(log(tol*(1-exp(-2*pi*X))/2)/(-2*pi*X)) + 3
3414
* if nterms >= self.B:
3415
* raise ValueError, "not enough terms of L-series known (%s needed, but %s known)"%( # <<<<<<<<<<<<<<
3416
* nterms, self.B)
3417
*
3418
*/
3419
__pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_not_enough_terms_of_L_series_kno, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 154, __pyx_L1_error)
3420
__Pyx_GOTREF(__pyx_t_3);
3421
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3422
__Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_3, 0, 0);
3423
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3424
__PYX_ERR(0, 154, __pyx_L1_error)
3425
3426
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":153
3427
*
3428
* nterms = <int>(log(tol*(1-exp(-2*pi*X))/2)/(-2*pi*X)) + 3
3429
* if nterms >= self.B: # <<<<<<<<<<<<<<
3430
* raise ValueError, "not enough terms of L-series known (%s needed, but %s known)"%(
3431
* nterms, self.B)
3432
*/
3433
}
3434
3435
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":157
3436
* nterms, self.B)
3437
*
3438
* if self.root_number == -1: # <<<<<<<<<<<<<<
3439
* # compute L(E,chi,1) =
3440
* # 2 * sum_{n=1}^{k} (chi(n) * a_n / n) * exp(-2*pi*n/sqrt(N*D^2))
3441
*/
3442
__pyx_t_12 = ((__pyx_v_self->root_number == -1L) != 0);
3443
if (__pyx_t_12) {
3444
3445
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":160
3446
* # compute L(E,chi,1) =
3447
* # 2 * sum_{n=1}^{k} (chi(n) * a_n / n) * exp(-2*pi*n/sqrt(N*D^2))
3448
* for n in range(1, nterms): # <<<<<<<<<<<<<<
3449
* s += (chi._values[n%D4] * a[n] / n) * exp(-2*pi*n*X)
3450
* else:
3451
*/
3452
__pyx_t_7 = __pyx_v_nterms;
3453
for (__pyx_t_8 = 1; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
3454
__pyx_v_n = __pyx_t_8;
3455
3456
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":161
3457
* # 2 * sum_{n=1}^{k} (chi(n) * a_n / n) * exp(-2*pi*n/sqrt(N*D^2))
3458
* for n in range(1, nterms):
3459
* s += (chi._values[n%D4] * a[n] / n) * exp(-2*pi*n*X) # <<<<<<<<<<<<<<
3460
* else:
3461
* # compute L'(E,chi,1) =
3462
*/
3463
if (unlikely(__pyx_v_D4 == 0)) {
3464
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
3465
__PYX_ERR(0, 161, __pyx_L1_error)
3466
}
3467
__pyx_t_9 = ((__pyx_v_chi->_values[__Pyx_mod_long(__pyx_v_n, __pyx_v_D4)]) * (__pyx_v_a[__pyx_v_n]));
3468
if (unlikely(__pyx_v_n == 0)) {
3469
PyErr_SetString(PyExc_ZeroDivisionError, "float division");
3470
__PYX_ERR(0, 161, __pyx_L1_error)
3471
}
3472
__pyx_v_s = (__pyx_v_s + ((__pyx_t_9 / __pyx_v_n) * exp((((-2.0 * __pyx_v_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_pi) * __pyx_v_n) * __pyx_v_X))));
3473
}
3474
3475
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":157
3476
* nterms, self.B)
3477
*
3478
* if self.root_number == -1: # <<<<<<<<<<<<<<
3479
* # compute L(E,chi,1) =
3480
* # 2 * sum_{n=1}^{k} (chi(n) * a_n / n) * exp(-2*pi*n/sqrt(N*D^2))
3481
*/
3482
goto __pyx_L6;
3483
}
3484
3485
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":165
3486
* # compute L'(E,chi,1) =
3487
* # 2 * sum_{n=1}^{k} (chi(n) * a_n / n) * E_1(2*pi*n/sqrt(N*D^2))
3488
* for n in range(1, nterms): # <<<<<<<<<<<<<<
3489
* s += (chi._values[n%D4] * a[n] / n) * gsl_sf_expint_E1 (2*pi*n*X)
3490
*
3491
*/
3492
/*else*/ {
3493
__pyx_t_7 = __pyx_v_nterms;
3494
for (__pyx_t_8 = 1; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
3495
__pyx_v_n = __pyx_t_8;
3496
3497
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":166
3498
* # 2 * sum_{n=1}^{k} (chi(n) * a_n / n) * E_1(2*pi*n/sqrt(N*D^2))
3499
* for n in range(1, nterms):
3500
* s += (chi._values[n%D4] * a[n] / n) * gsl_sf_expint_E1 (2*pi*n*X) # <<<<<<<<<<<<<<
3501
*
3502
* return 2*s, nterms
3503
*/
3504
if (unlikely(__pyx_v_D4 == 0)) {
3505
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
3506
__PYX_ERR(0, 166, __pyx_L1_error)
3507
}
3508
__pyx_t_9 = ((__pyx_v_chi->_values[__Pyx_mod_long(__pyx_v_n, __pyx_v_D4)]) * (__pyx_v_a[__pyx_v_n]));
3509
if (unlikely(__pyx_v_n == 0)) {
3510
PyErr_SetString(PyExc_ZeroDivisionError, "float division");
3511
__PYX_ERR(0, 166, __pyx_L1_error)
3512
}
3513
__pyx_v_s = (__pyx_v_s + ((__pyx_t_9 / __pyx_v_n) * gsl_sf_expint_E1((((2.0 * __pyx_v_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_pi) * __pyx_v_n) * __pyx_v_X))));
3514
}
3515
}
3516
__pyx_L6:;
3517
3518
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":168
3519
* s += (chi._values[n%D4] * a[n] / n) * gsl_sf_expint_E1 (2*pi*n*X)
3520
*
3521
* return 2*s, nterms # <<<<<<<<<<<<<<
3522
*
3523
*
3524
*/
3525
__Pyx_XDECREF(__pyx_r);
3526
__pyx_t_3 = PyFloat_FromDouble((2.0 * __pyx_v_s)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 168, __pyx_L1_error)
3527
__Pyx_GOTREF(__pyx_t_3);
3528
__pyx_t_5 = PyInt_FromSsize_t(__pyx_v_nterms); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 168, __pyx_L1_error)
3529
__Pyx_GOTREF(__pyx_t_5);
3530
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 168, __pyx_L1_error)
3531
__Pyx_GOTREF(__pyx_t_2);
3532
__Pyx_GIVEREF(__pyx_t_3);
3533
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
3534
__Pyx_GIVEREF(__pyx_t_5);
3535
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
3536
__pyx_t_3 = 0;
3537
__pyx_t_5 = 0;
3538
__pyx_r = __pyx_t_2;
3539
__pyx_t_2 = 0;
3540
goto __pyx_L0;
3541
3542
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":132
3543
* return self.E.heegner_discriminants(bound)
3544
*
3545
* def twist_special_value(self, long D, tol=1e-6): # <<<<<<<<<<<<<<
3546
* # 1. Make floating point table of value of the quadratic
3547
* # symbol (D/-) modulo 4*|D|.
3548
*/
3549
3550
/* function exit code */
3551
__pyx_L1_error:;
3552
__Pyx_XDECREF(__pyx_t_2);
3553
__Pyx_XDECREF(__pyx_t_3);
3554
__Pyx_XDECREF(__pyx_t_4);
3555
__Pyx_XDECREF(__pyx_t_5);
3556
__Pyx_XDECREF(__pyx_t_6);
3557
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.fast_twist.FastHeegnerTwists.twist_special_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
3558
__pyx_r = NULL;
3559
__pyx_L0:;
3560
__Pyx_XDECREF((PyObject *)__pyx_v_chi);
3561
__Pyx_XDECREF(__pyx_v_Dz);
3562
__Pyx_XGIVEREF(__pyx_r);
3563
__Pyx_RefNannyFinishContext();
3564
return __pyx_r;
3565
}
3566
3567
/* "cysignals/memory.pxd":40
3568
*
3569
*
3570
* cdef inline void* sig_malloc "sig_malloc"(size_t n) nogil: # <<<<<<<<<<<<<<
3571
* sig_block()
3572
* cdef void* ret = malloc(n)
3573
*/
3574
3575
static CYTHON_INLINE void *sig_malloc(size_t __pyx_v_n) {
3576
void *__pyx_v_ret;
3577
void *__pyx_r;
3578
3579
/* "cysignals/memory.pxd":41
3580
*
3581
* cdef inline void* sig_malloc "sig_malloc"(size_t n) nogil:
3582
* sig_block() # <<<<<<<<<<<<<<
3583
* cdef void* ret = malloc(n)
3584
* sig_unblock()
3585
*/
3586
sig_block();
3587
3588
/* "cysignals/memory.pxd":42
3589
* cdef inline void* sig_malloc "sig_malloc"(size_t n) nogil:
3590
* sig_block()
3591
* cdef void* ret = malloc(n) # <<<<<<<<<<<<<<
3592
* sig_unblock()
3593
* return ret
3594
*/
3595
__pyx_v_ret = malloc(__pyx_v_n);
3596
3597
/* "cysignals/memory.pxd":43
3598
* sig_block()
3599
* cdef void* ret = malloc(n)
3600
* sig_unblock() # <<<<<<<<<<<<<<
3601
* return ret
3602
*
3603
*/
3604
sig_unblock();
3605
3606
/* "cysignals/memory.pxd":44
3607
* cdef void* ret = malloc(n)
3608
* sig_unblock()
3609
* return ret # <<<<<<<<<<<<<<
3610
*
3611
*
3612
*/
3613
__pyx_r = __pyx_v_ret;
3614
goto __pyx_L0;
3615
3616
/* "cysignals/memory.pxd":40
3617
*
3618
*
3619
* cdef inline void* sig_malloc "sig_malloc"(size_t n) nogil: # <<<<<<<<<<<<<<
3620
* sig_block()
3621
* cdef void* ret = malloc(n)
3622
*/
3623
3624
/* function exit code */
3625
__pyx_L0:;
3626
return __pyx_r;
3627
}
3628
3629
/* "cysignals/memory.pxd":47
3630
*
3631
*
3632
* cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) nogil: # <<<<<<<<<<<<<<
3633
* sig_block()
3634
* cdef void* ret = realloc(ptr, size)
3635
*/
3636
3637
static CYTHON_INLINE void *sig_realloc(void *__pyx_v_ptr, size_t __pyx_v_size) {
3638
void *__pyx_v_ret;
3639
void *__pyx_r;
3640
3641
/* "cysignals/memory.pxd":48
3642
*
3643
* cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) nogil:
3644
* sig_block() # <<<<<<<<<<<<<<
3645
* cdef void* ret = realloc(ptr, size)
3646
* sig_unblock()
3647
*/
3648
sig_block();
3649
3650
/* "cysignals/memory.pxd":49
3651
* cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) nogil:
3652
* sig_block()
3653
* cdef void* ret = realloc(ptr, size) # <<<<<<<<<<<<<<
3654
* sig_unblock()
3655
* return ret
3656
*/
3657
__pyx_v_ret = realloc(__pyx_v_ptr, __pyx_v_size);
3658
3659
/* "cysignals/memory.pxd":50
3660
* sig_block()
3661
* cdef void* ret = realloc(ptr, size)
3662
* sig_unblock() # <<<<<<<<<<<<<<
3663
* return ret
3664
*
3665
*/
3666
sig_unblock();
3667
3668
/* "cysignals/memory.pxd":51
3669
* cdef void* ret = realloc(ptr, size)
3670
* sig_unblock()
3671
* return ret # <<<<<<<<<<<<<<
3672
*
3673
*
3674
*/
3675
__pyx_r = __pyx_v_ret;
3676
goto __pyx_L0;
3677
3678
/* "cysignals/memory.pxd":47
3679
*
3680
*
3681
* cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) nogil: # <<<<<<<<<<<<<<
3682
* sig_block()
3683
* cdef void* ret = realloc(ptr, size)
3684
*/
3685
3686
/* function exit code */
3687
__pyx_L0:;
3688
return __pyx_r;
3689
}
3690
3691
/* "cysignals/memory.pxd":54
3692
*
3693
*
3694
* cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) nogil: # <<<<<<<<<<<<<<
3695
* sig_block()
3696
* cdef void* ret = calloc(nmemb, size)
3697
*/
3698
3699
static CYTHON_INLINE void *sig_calloc(size_t __pyx_v_nmemb, size_t __pyx_v_size) {
3700
void *__pyx_v_ret;
3701
void *__pyx_r;
3702
3703
/* "cysignals/memory.pxd":55
3704
*
3705
* cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) nogil:
3706
* sig_block() # <<<<<<<<<<<<<<
3707
* cdef void* ret = calloc(nmemb, size)
3708
* sig_unblock()
3709
*/
3710
sig_block();
3711
3712
/* "cysignals/memory.pxd":56
3713
* cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) nogil:
3714
* sig_block()
3715
* cdef void* ret = calloc(nmemb, size) # <<<<<<<<<<<<<<
3716
* sig_unblock()
3717
* return ret
3718
*/
3719
__pyx_v_ret = calloc(__pyx_v_nmemb, __pyx_v_size);
3720
3721
/* "cysignals/memory.pxd":57
3722
* sig_block()
3723
* cdef void* ret = calloc(nmemb, size)
3724
* sig_unblock() # <<<<<<<<<<<<<<
3725
* return ret
3726
*
3727
*/
3728
sig_unblock();
3729
3730
/* "cysignals/memory.pxd":58
3731
* cdef void* ret = calloc(nmemb, size)
3732
* sig_unblock()
3733
* return ret # <<<<<<<<<<<<<<
3734
*
3735
*
3736
*/
3737
__pyx_r = __pyx_v_ret;
3738
goto __pyx_L0;
3739
3740
/* "cysignals/memory.pxd":54
3741
*
3742
*
3743
* cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) nogil: # <<<<<<<<<<<<<<
3744
* sig_block()
3745
* cdef void* ret = calloc(nmemb, size)
3746
*/
3747
3748
/* function exit code */
3749
__pyx_L0:;
3750
return __pyx_r;
3751
}
3752
3753
/* "cysignals/memory.pxd":61
3754
*
3755
*
3756
* cdef inline void sig_free "sig_free"(void* ptr) nogil: # <<<<<<<<<<<<<<
3757
* sig_block()
3758
* free(ptr)
3759
*/
3760
3761
static CYTHON_INLINE void sig_free(void *__pyx_v_ptr) {
3762
3763
/* "cysignals/memory.pxd":62
3764
*
3765
* cdef inline void sig_free "sig_free"(void* ptr) nogil:
3766
* sig_block() # <<<<<<<<<<<<<<
3767
* free(ptr)
3768
* sig_unblock()
3769
*/
3770
sig_block();
3771
3772
/* "cysignals/memory.pxd":63
3773
* cdef inline void sig_free "sig_free"(void* ptr) nogil:
3774
* sig_block()
3775
* free(ptr) # <<<<<<<<<<<<<<
3776
* sig_unblock()
3777
*
3778
*/
3779
free(__pyx_v_ptr);
3780
3781
/* "cysignals/memory.pxd":64
3782
* sig_block()
3783
* free(ptr)
3784
* sig_unblock() # <<<<<<<<<<<<<<
3785
*
3786
*
3787
*/
3788
sig_unblock();
3789
3790
/* "cysignals/memory.pxd":61
3791
*
3792
*
3793
* cdef inline void sig_free "sig_free"(void* ptr) nogil: # <<<<<<<<<<<<<<
3794
* sig_block()
3795
* free(ptr)
3796
*/
3797
3798
/* function exit code */
3799
}
3800
3801
/* "cysignals/memory.pxd":68
3802
*
3803
* @cython.cdivision(True)
3804
* cdef inline size_t mul_overflowcheck(size_t a, size_t b) nogil: # <<<<<<<<<<<<<<
3805
* """
3806
* Return a*b, checking for overflow. Assume that a > 0.
3807
*/
3808
3809
static CYTHON_INLINE size_t __pyx_f_9cysignals_6memory_mul_overflowcheck(size_t __pyx_v_a, size_t __pyx_v_b) {
3810
size_t __pyx_v_MUL_NO_OVERFLOW;
3811
size_t __pyx_r;
3812
int __pyx_t_1;
3813
int __pyx_t_2;
3814
3815
/* "cysignals/memory.pxd":75
3816
* """
3817
* # If a and b both less than MUL_NO_OVERFLOW, no overflow can occur
3818
* cdef size_t MUL_NO_OVERFLOW = ((<size_t>1) << (4*sizeof(size_t))) # <<<<<<<<<<<<<<
3819
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW:
3820
* if unlikely(b > (<size_t>-1) // a):
3821
*/
3822
__pyx_v_MUL_NO_OVERFLOW = (((size_t)1) << (4 * (sizeof(size_t))));
3823
3824
/* "cysignals/memory.pxd":76
3825
* # If a and b both less than MUL_NO_OVERFLOW, no overflow can occur
3826
* cdef size_t MUL_NO_OVERFLOW = ((<size_t>1) << (4*sizeof(size_t)))
3827
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW: # <<<<<<<<<<<<<<
3828
* if unlikely(b > (<size_t>-1) // a):
3829
* return <size_t>(-1)
3830
*/
3831
__pyx_t_2 = ((__pyx_v_a >= __pyx_v_MUL_NO_OVERFLOW) != 0);
3832
if (!__pyx_t_2) {
3833
} else {
3834
__pyx_t_1 = __pyx_t_2;
3835
goto __pyx_L4_bool_binop_done;
3836
}
3837
__pyx_t_2 = ((__pyx_v_b >= __pyx_v_MUL_NO_OVERFLOW) != 0);
3838
__pyx_t_1 = __pyx_t_2;
3839
__pyx_L4_bool_binop_done:;
3840
if (__pyx_t_1) {
3841
3842
/* "cysignals/memory.pxd":77
3843
* cdef size_t MUL_NO_OVERFLOW = ((<size_t>1) << (4*sizeof(size_t)))
3844
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW:
3845
* if unlikely(b > (<size_t>-1) // a): # <<<<<<<<<<<<<<
3846
* return <size_t>(-1)
3847
* return a*b
3848
*/
3849
__pyx_t_1 = (unlikely((__pyx_v_b > (((size_t)-1L) / __pyx_v_a))) != 0);
3850
if (__pyx_t_1) {
3851
3852
/* "cysignals/memory.pxd":78
3853
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW:
3854
* if unlikely(b > (<size_t>-1) // a):
3855
* return <size_t>(-1) # <<<<<<<<<<<<<<
3856
* return a*b
3857
*
3858
*/
3859
__pyx_r = ((size_t)-1L);
3860
goto __pyx_L0;
3861
3862
/* "cysignals/memory.pxd":77
3863
* cdef size_t MUL_NO_OVERFLOW = ((<size_t>1) << (4*sizeof(size_t)))
3864
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW:
3865
* if unlikely(b > (<size_t>-1) // a): # <<<<<<<<<<<<<<
3866
* return <size_t>(-1)
3867
* return a*b
3868
*/
3869
}
3870
3871
/* "cysignals/memory.pxd":76
3872
* # If a and b both less than MUL_NO_OVERFLOW, no overflow can occur
3873
* cdef size_t MUL_NO_OVERFLOW = ((<size_t>1) << (4*sizeof(size_t)))
3874
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW: # <<<<<<<<<<<<<<
3875
* if unlikely(b > (<size_t>-1) // a):
3876
* return <size_t>(-1)
3877
*/
3878
}
3879
3880
/* "cysignals/memory.pxd":79
3881
* if unlikely(b > (<size_t>-1) // a):
3882
* return <size_t>(-1)
3883
* return a*b # <<<<<<<<<<<<<<
3884
*
3885
*
3886
*/
3887
__pyx_r = (__pyx_v_a * __pyx_v_b);
3888
goto __pyx_L0;
3889
3890
/* "cysignals/memory.pxd":68
3891
*
3892
* @cython.cdivision(True)
3893
* cdef inline size_t mul_overflowcheck(size_t a, size_t b) nogil: # <<<<<<<<<<<<<<
3894
* """
3895
* Return a*b, checking for overflow. Assume that a > 0.
3896
*/
3897
3898
/* function exit code */
3899
__pyx_L0:;
3900
return __pyx_r;
3901
}
3902
3903
/* "cysignals/memory.pxd":82
3904
*
3905
*
3906
* cdef inline void* check_allocarray(size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
3907
* """
3908
* Allocate memory for ``nmemb`` elements of size ``size``.
3909
*/
3910
3911
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_allocarray(size_t __pyx_v_nmemb, size_t __pyx_v_size) {
3912
size_t __pyx_v_n;
3913
void *__pyx_v_ret;
3914
void *__pyx_r;
3915
__Pyx_RefNannyDeclarations
3916
int __pyx_t_1;
3917
PyObject *__pyx_t_2 = NULL;
3918
PyObject *__pyx_t_3 = NULL;
3919
PyObject *__pyx_t_4 = NULL;
3920
__Pyx_RefNannySetupContext("check_allocarray", 0);
3921
3922
/* "cysignals/memory.pxd":86
3923
* Allocate memory for ``nmemb`` elements of size ``size``.
3924
* """
3925
* if nmemb == 0: # <<<<<<<<<<<<<<
3926
* return NULL
3927
* cdef size_t n = mul_overflowcheck(nmemb, size)
3928
*/
3929
__pyx_t_1 = ((__pyx_v_nmemb == 0) != 0);
3930
if (__pyx_t_1) {
3931
3932
/* "cysignals/memory.pxd":87
3933
* """
3934
* if nmemb == 0:
3935
* return NULL # <<<<<<<<<<<<<<
3936
* cdef size_t n = mul_overflowcheck(nmemb, size)
3937
* cdef void* ret = sig_malloc(n)
3938
*/
3939
__pyx_r = NULL;
3940
goto __pyx_L0;
3941
3942
/* "cysignals/memory.pxd":86
3943
* Allocate memory for ``nmemb`` elements of size ``size``.
3944
* """
3945
* if nmemb == 0: # <<<<<<<<<<<<<<
3946
* return NULL
3947
* cdef size_t n = mul_overflowcheck(nmemb, size)
3948
*/
3949
}
3950
3951
/* "cysignals/memory.pxd":88
3952
* if nmemb == 0:
3953
* return NULL
3954
* cdef size_t n = mul_overflowcheck(nmemb, size) # <<<<<<<<<<<<<<
3955
* cdef void* ret = sig_malloc(n)
3956
* if unlikely(ret == NULL):
3957
*/
3958
__pyx_v_n = __pyx_f_9cysignals_6memory_mul_overflowcheck(__pyx_v_nmemb, __pyx_v_size);
3959
3960
/* "cysignals/memory.pxd":89
3961
* return NULL
3962
* cdef size_t n = mul_overflowcheck(nmemb, size)
3963
* cdef void* ret = sig_malloc(n) # <<<<<<<<<<<<<<
3964
* if unlikely(ret == NULL):
3965
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
3966
*/
3967
__pyx_v_ret = sig_malloc(__pyx_v_n);
3968
3969
/* "cysignals/memory.pxd":90
3970
* cdef size_t n = mul_overflowcheck(nmemb, size)
3971
* cdef void* ret = sig_malloc(n)
3972
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
3973
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
3974
* return ret
3975
*/
3976
__pyx_t_1 = (unlikely((__pyx_v_ret == NULL)) != 0);
3977
if (__pyx_t_1) {
3978
3979
/* "cysignals/memory.pxd":91
3980
* cdef void* ret = sig_malloc(n)
3981
* if unlikely(ret == NULL):
3982
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size)) # <<<<<<<<<<<<<<
3983
* return ret
3984
*
3985
*/
3986
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_nmemb); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 91, __pyx_L1_error)
3987
__Pyx_GOTREF(__pyx_t_2);
3988
__pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 91, __pyx_L1_error)
3989
__Pyx_GOTREF(__pyx_t_3);
3990
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 91, __pyx_L1_error)
3991
__Pyx_GOTREF(__pyx_t_4);
3992
__Pyx_GIVEREF(__pyx_t_2);
3993
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
3994
__Pyx_GIVEREF(__pyx_t_3);
3995
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
3996
__pyx_t_2 = 0;
3997
__pyx_t_3 = 0;
3998
__pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_allocate_s_s_bytes, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 91, __pyx_L1_error)
3999
__Pyx_GOTREF(__pyx_t_3);
4000
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4001
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 91, __pyx_L1_error)
4002
__Pyx_GOTREF(__pyx_t_4);
4003
__Pyx_GIVEREF(__pyx_t_3);
4004
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
4005
__pyx_t_3 = 0;
4006
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 91, __pyx_L1_error)
4007
__Pyx_GOTREF(__pyx_t_3);
4008
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4009
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
4010
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4011
__PYX_ERR(1, 91, __pyx_L1_error)
4012
4013
/* "cysignals/memory.pxd":90
4014
* cdef size_t n = mul_overflowcheck(nmemb, size)
4015
* cdef void* ret = sig_malloc(n)
4016
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
4017
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
4018
* return ret
4019
*/
4020
}
4021
4022
/* "cysignals/memory.pxd":92
4023
* if unlikely(ret == NULL):
4024
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
4025
* return ret # <<<<<<<<<<<<<<
4026
*
4027
*
4028
*/
4029
__pyx_r = __pyx_v_ret;
4030
goto __pyx_L0;
4031
4032
/* "cysignals/memory.pxd":82
4033
*
4034
*
4035
* cdef inline void* check_allocarray(size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
4036
* """
4037
* Allocate memory for ``nmemb`` elements of size ``size``.
4038
*/
4039
4040
/* function exit code */
4041
__pyx_L1_error:;
4042
__Pyx_XDECREF(__pyx_t_2);
4043
__Pyx_XDECREF(__pyx_t_3);
4044
__Pyx_XDECREF(__pyx_t_4);
4045
__Pyx_AddTraceback("cysignals.memory.check_allocarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
4046
__pyx_r = NULL;
4047
__pyx_L0:;
4048
__Pyx_RefNannyFinishContext();
4049
return __pyx_r;
4050
}
4051
4052
/* "cysignals/memory.pxd":95
4053
*
4054
*
4055
* cdef inline void* check_reallocarray(void* ptr, size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
4056
* """
4057
* Re-allocate memory at ``ptr`` to hold ``nmemb`` elements of size
4058
*/
4059
4060
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_reallocarray(void *__pyx_v_ptr, size_t __pyx_v_nmemb, size_t __pyx_v_size) {
4061
size_t __pyx_v_n;
4062
void *__pyx_v_ret;
4063
void *__pyx_r;
4064
__Pyx_RefNannyDeclarations
4065
int __pyx_t_1;
4066
PyObject *__pyx_t_2 = NULL;
4067
PyObject *__pyx_t_3 = NULL;
4068
PyObject *__pyx_t_4 = NULL;
4069
__Pyx_RefNannySetupContext("check_reallocarray", 0);
4070
4071
/* "cysignals/memory.pxd":103
4072
* When ``nmemb`` equals 0, then free the memory at ``ptr``.
4073
* """
4074
* if nmemb == 0: # <<<<<<<<<<<<<<
4075
* sig_free(ptr)
4076
* return NULL
4077
*/
4078
__pyx_t_1 = ((__pyx_v_nmemb == 0) != 0);
4079
if (__pyx_t_1) {
4080
4081
/* "cysignals/memory.pxd":104
4082
* """
4083
* if nmemb == 0:
4084
* sig_free(ptr) # <<<<<<<<<<<<<<
4085
* return NULL
4086
* cdef size_t n = mul_overflowcheck(nmemb, size)
4087
*/
4088
sig_free(__pyx_v_ptr);
4089
4090
/* "cysignals/memory.pxd":105
4091
* if nmemb == 0:
4092
* sig_free(ptr)
4093
* return NULL # <<<<<<<<<<<<<<
4094
* cdef size_t n = mul_overflowcheck(nmemb, size)
4095
* cdef void* ret = sig_realloc(ptr, n)
4096
*/
4097
__pyx_r = NULL;
4098
goto __pyx_L0;
4099
4100
/* "cysignals/memory.pxd":103
4101
* When ``nmemb`` equals 0, then free the memory at ``ptr``.
4102
* """
4103
* if nmemb == 0: # <<<<<<<<<<<<<<
4104
* sig_free(ptr)
4105
* return NULL
4106
*/
4107
}
4108
4109
/* "cysignals/memory.pxd":106
4110
* sig_free(ptr)
4111
* return NULL
4112
* cdef size_t n = mul_overflowcheck(nmemb, size) # <<<<<<<<<<<<<<
4113
* cdef void* ret = sig_realloc(ptr, n)
4114
* if unlikely(ret == NULL):
4115
*/
4116
__pyx_v_n = __pyx_f_9cysignals_6memory_mul_overflowcheck(__pyx_v_nmemb, __pyx_v_size);
4117
4118
/* "cysignals/memory.pxd":107
4119
* return NULL
4120
* cdef size_t n = mul_overflowcheck(nmemb, size)
4121
* cdef void* ret = sig_realloc(ptr, n) # <<<<<<<<<<<<<<
4122
* if unlikely(ret == NULL):
4123
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
4124
*/
4125
__pyx_v_ret = sig_realloc(__pyx_v_ptr, __pyx_v_n);
4126
4127
/* "cysignals/memory.pxd":108
4128
* cdef size_t n = mul_overflowcheck(nmemb, size)
4129
* cdef void* ret = sig_realloc(ptr, n)
4130
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
4131
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
4132
* return ret
4133
*/
4134
__pyx_t_1 = (unlikely((__pyx_v_ret == NULL)) != 0);
4135
if (__pyx_t_1) {
4136
4137
/* "cysignals/memory.pxd":109
4138
* cdef void* ret = sig_realloc(ptr, n)
4139
* if unlikely(ret == NULL):
4140
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size)) # <<<<<<<<<<<<<<
4141
* return ret
4142
*
4143
*/
4144
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_nmemb); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 109, __pyx_L1_error)
4145
__Pyx_GOTREF(__pyx_t_2);
4146
__pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 109, __pyx_L1_error)
4147
__Pyx_GOTREF(__pyx_t_3);
4148
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 109, __pyx_L1_error)
4149
__Pyx_GOTREF(__pyx_t_4);
4150
__Pyx_GIVEREF(__pyx_t_2);
4151
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
4152
__Pyx_GIVEREF(__pyx_t_3);
4153
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
4154
__pyx_t_2 = 0;
4155
__pyx_t_3 = 0;
4156
__pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_allocate_s_s_bytes, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 109, __pyx_L1_error)
4157
__Pyx_GOTREF(__pyx_t_3);
4158
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4159
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 109, __pyx_L1_error)
4160
__Pyx_GOTREF(__pyx_t_4);
4161
__Pyx_GIVEREF(__pyx_t_3);
4162
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
4163
__pyx_t_3 = 0;
4164
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 109, __pyx_L1_error)
4165
__Pyx_GOTREF(__pyx_t_3);
4166
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4167
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
4168
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4169
__PYX_ERR(1, 109, __pyx_L1_error)
4170
4171
/* "cysignals/memory.pxd":108
4172
* cdef size_t n = mul_overflowcheck(nmemb, size)
4173
* cdef void* ret = sig_realloc(ptr, n)
4174
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
4175
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
4176
* return ret
4177
*/
4178
}
4179
4180
/* "cysignals/memory.pxd":110
4181
* if unlikely(ret == NULL):
4182
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
4183
* return ret # <<<<<<<<<<<<<<
4184
*
4185
*
4186
*/
4187
__pyx_r = __pyx_v_ret;
4188
goto __pyx_L0;
4189
4190
/* "cysignals/memory.pxd":95
4191
*
4192
*
4193
* cdef inline void* check_reallocarray(void* ptr, size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
4194
* """
4195
* Re-allocate memory at ``ptr`` to hold ``nmemb`` elements of size
4196
*/
4197
4198
/* function exit code */
4199
__pyx_L1_error:;
4200
__Pyx_XDECREF(__pyx_t_2);
4201
__Pyx_XDECREF(__pyx_t_3);
4202
__Pyx_XDECREF(__pyx_t_4);
4203
__Pyx_AddTraceback("cysignals.memory.check_reallocarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
4204
__pyx_r = NULL;
4205
__pyx_L0:;
4206
__Pyx_RefNannyFinishContext();
4207
return __pyx_r;
4208
}
4209
4210
/* "cysignals/memory.pxd":113
4211
*
4212
*
4213
* cdef inline void* check_malloc(size_t n) except? NULL: # <<<<<<<<<<<<<<
4214
* """
4215
* Allocate ``n`` bytes of memory.
4216
*/
4217
4218
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_malloc(size_t __pyx_v_n) {
4219
void *__pyx_v_ret;
4220
void *__pyx_r;
4221
__Pyx_RefNannyDeclarations
4222
int __pyx_t_1;
4223
PyObject *__pyx_t_2 = NULL;
4224
PyObject *__pyx_t_3 = NULL;
4225
__Pyx_RefNannySetupContext("check_malloc", 0);
4226
4227
/* "cysignals/memory.pxd":117
4228
* Allocate ``n`` bytes of memory.
4229
* """
4230
* if n == 0: # <<<<<<<<<<<<<<
4231
* return NULL
4232
* cdef void* ret = sig_malloc(n)
4233
*/
4234
__pyx_t_1 = ((__pyx_v_n == 0) != 0);
4235
if (__pyx_t_1) {
4236
4237
/* "cysignals/memory.pxd":118
4238
* """
4239
* if n == 0:
4240
* return NULL # <<<<<<<<<<<<<<
4241
* cdef void* ret = sig_malloc(n)
4242
* if unlikely(ret == NULL):
4243
*/
4244
__pyx_r = NULL;
4245
goto __pyx_L0;
4246
4247
/* "cysignals/memory.pxd":117
4248
* Allocate ``n`` bytes of memory.
4249
* """
4250
* if n == 0: # <<<<<<<<<<<<<<
4251
* return NULL
4252
* cdef void* ret = sig_malloc(n)
4253
*/
4254
}
4255
4256
/* "cysignals/memory.pxd":119
4257
* if n == 0:
4258
* return NULL
4259
* cdef void* ret = sig_malloc(n) # <<<<<<<<<<<<<<
4260
* if unlikely(ret == NULL):
4261
* raise MemoryError("failed to allocate %s bytes" % n)
4262
*/
4263
__pyx_v_ret = sig_malloc(__pyx_v_n);
4264
4265
/* "cysignals/memory.pxd":120
4266
* return NULL
4267
* cdef void* ret = sig_malloc(n)
4268
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
4269
* raise MemoryError("failed to allocate %s bytes" % n)
4270
* return ret
4271
*/
4272
__pyx_t_1 = (unlikely((__pyx_v_ret == NULL)) != 0);
4273
if (__pyx_t_1) {
4274
4275
/* "cysignals/memory.pxd":121
4276
* cdef void* ret = sig_malloc(n)
4277
* if unlikely(ret == NULL):
4278
* raise MemoryError("failed to allocate %s bytes" % n) # <<<<<<<<<<<<<<
4279
* return ret
4280
*
4281
*/
4282
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 121, __pyx_L1_error)
4283
__Pyx_GOTREF(__pyx_t_2);
4284
__pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_allocate_s_bytes, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 121, __pyx_L1_error)
4285
__Pyx_GOTREF(__pyx_t_3);
4286
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4287
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 121, __pyx_L1_error)
4288
__Pyx_GOTREF(__pyx_t_2);
4289
__Pyx_GIVEREF(__pyx_t_3);
4290
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
4291
__pyx_t_3 = 0;
4292
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 121, __pyx_L1_error)
4293
__Pyx_GOTREF(__pyx_t_3);
4294
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4295
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
4296
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4297
__PYX_ERR(1, 121, __pyx_L1_error)
4298
4299
/* "cysignals/memory.pxd":120
4300
* return NULL
4301
* cdef void* ret = sig_malloc(n)
4302
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
4303
* raise MemoryError("failed to allocate %s bytes" % n)
4304
* return ret
4305
*/
4306
}
4307
4308
/* "cysignals/memory.pxd":122
4309
* if unlikely(ret == NULL):
4310
* raise MemoryError("failed to allocate %s bytes" % n)
4311
* return ret # <<<<<<<<<<<<<<
4312
*
4313
*
4314
*/
4315
__pyx_r = __pyx_v_ret;
4316
goto __pyx_L0;
4317
4318
/* "cysignals/memory.pxd":113
4319
*
4320
*
4321
* cdef inline void* check_malloc(size_t n) except? NULL: # <<<<<<<<<<<<<<
4322
* """
4323
* Allocate ``n`` bytes of memory.
4324
*/
4325
4326
/* function exit code */
4327
__pyx_L1_error:;
4328
__Pyx_XDECREF(__pyx_t_2);
4329
__Pyx_XDECREF(__pyx_t_3);
4330
__Pyx_AddTraceback("cysignals.memory.check_malloc", __pyx_clineno, __pyx_lineno, __pyx_filename);
4331
__pyx_r = NULL;
4332
__pyx_L0:;
4333
__Pyx_RefNannyFinishContext();
4334
return __pyx_r;
4335
}
4336
4337
/* "cysignals/memory.pxd":125
4338
*
4339
*
4340
* cdef inline void* check_realloc(void* ptr, size_t n) except? NULL: # <<<<<<<<<<<<<<
4341
* """
4342
* Re-allocate memory at ``ptr`` to hold ``n`` bytes.
4343
*/
4344
4345
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_realloc(void *__pyx_v_ptr, size_t __pyx_v_n) {
4346
void *__pyx_v_ret;
4347
void *__pyx_r;
4348
__Pyx_RefNannyDeclarations
4349
int __pyx_t_1;
4350
PyObject *__pyx_t_2 = NULL;
4351
PyObject *__pyx_t_3 = NULL;
4352
__Pyx_RefNannySetupContext("check_realloc", 0);
4353
4354
/* "cysignals/memory.pxd":130
4355
* If ``ptr`` equals ``NULL``, this behaves as ``check_malloc``.
4356
* """
4357
* if n == 0: # <<<<<<<<<<<<<<
4358
* sig_free(ptr)
4359
* return NULL
4360
*/
4361
__pyx_t_1 = ((__pyx_v_n == 0) != 0);
4362
if (__pyx_t_1) {
4363
4364
/* "cysignals/memory.pxd":131
4365
* """
4366
* if n == 0:
4367
* sig_free(ptr) # <<<<<<<<<<<<<<
4368
* return NULL
4369
* cdef void* ret = sig_realloc(ptr, n)
4370
*/
4371
sig_free(__pyx_v_ptr);
4372
4373
/* "cysignals/memory.pxd":132
4374
* if n == 0:
4375
* sig_free(ptr)
4376
* return NULL # <<<<<<<<<<<<<<
4377
* cdef void* ret = sig_realloc(ptr, n)
4378
* if unlikely(ret == NULL):
4379
*/
4380
__pyx_r = NULL;
4381
goto __pyx_L0;
4382
4383
/* "cysignals/memory.pxd":130
4384
* If ``ptr`` equals ``NULL``, this behaves as ``check_malloc``.
4385
* """
4386
* if n == 0: # <<<<<<<<<<<<<<
4387
* sig_free(ptr)
4388
* return NULL
4389
*/
4390
}
4391
4392
/* "cysignals/memory.pxd":133
4393
* sig_free(ptr)
4394
* return NULL
4395
* cdef void* ret = sig_realloc(ptr, n) # <<<<<<<<<<<<<<
4396
* if unlikely(ret == NULL):
4397
* raise MemoryError("failed to allocate %s bytes" % n)
4398
*/
4399
__pyx_v_ret = sig_realloc(__pyx_v_ptr, __pyx_v_n);
4400
4401
/* "cysignals/memory.pxd":134
4402
* return NULL
4403
* cdef void* ret = sig_realloc(ptr, n)
4404
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
4405
* raise MemoryError("failed to allocate %s bytes" % n)
4406
* return ret
4407
*/
4408
__pyx_t_1 = (unlikely((__pyx_v_ret == NULL)) != 0);
4409
if (__pyx_t_1) {
4410
4411
/* "cysignals/memory.pxd":135
4412
* cdef void* ret = sig_realloc(ptr, n)
4413
* if unlikely(ret == NULL):
4414
* raise MemoryError("failed to allocate %s bytes" % n) # <<<<<<<<<<<<<<
4415
* return ret
4416
*
4417
*/
4418
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 135, __pyx_L1_error)
4419
__Pyx_GOTREF(__pyx_t_2);
4420
__pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_allocate_s_bytes, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 135, __pyx_L1_error)
4421
__Pyx_GOTREF(__pyx_t_3);
4422
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4423
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 135, __pyx_L1_error)
4424
__Pyx_GOTREF(__pyx_t_2);
4425
__Pyx_GIVEREF(__pyx_t_3);
4426
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
4427
__pyx_t_3 = 0;
4428
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 135, __pyx_L1_error)
4429
__Pyx_GOTREF(__pyx_t_3);
4430
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4431
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
4432
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4433
__PYX_ERR(1, 135, __pyx_L1_error)
4434
4435
/* "cysignals/memory.pxd":134
4436
* return NULL
4437
* cdef void* ret = sig_realloc(ptr, n)
4438
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
4439
* raise MemoryError("failed to allocate %s bytes" % n)
4440
* return ret
4441
*/
4442
}
4443
4444
/* "cysignals/memory.pxd":136
4445
* if unlikely(ret == NULL):
4446
* raise MemoryError("failed to allocate %s bytes" % n)
4447
* return ret # <<<<<<<<<<<<<<
4448
*
4449
*
4450
*/
4451
__pyx_r = __pyx_v_ret;
4452
goto __pyx_L0;
4453
4454
/* "cysignals/memory.pxd":125
4455
*
4456
*
4457
* cdef inline void* check_realloc(void* ptr, size_t n) except? NULL: # <<<<<<<<<<<<<<
4458
* """
4459
* Re-allocate memory at ``ptr`` to hold ``n`` bytes.
4460
*/
4461
4462
/* function exit code */
4463
__pyx_L1_error:;
4464
__Pyx_XDECREF(__pyx_t_2);
4465
__Pyx_XDECREF(__pyx_t_3);
4466
__Pyx_AddTraceback("cysignals.memory.check_realloc", __pyx_clineno, __pyx_lineno, __pyx_filename);
4467
__pyx_r = NULL;
4468
__pyx_L0:;
4469
__Pyx_RefNannyFinishContext();
4470
return __pyx_r;
4471
}
4472
4473
/* "cysignals/memory.pxd":139
4474
*
4475
*
4476
* cdef inline void* check_calloc(size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
4477
* """
4478
* Allocate memory for ``nmemb`` elements of size ``size``. The
4479
*/
4480
4481
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_calloc(size_t __pyx_v_nmemb, size_t __pyx_v_size) {
4482
void *__pyx_v_ret;
4483
void *__pyx_r;
4484
__Pyx_RefNannyDeclarations
4485
int __pyx_t_1;
4486
PyObject *__pyx_t_2 = NULL;
4487
PyObject *__pyx_t_3 = NULL;
4488
PyObject *__pyx_t_4 = NULL;
4489
__Pyx_RefNannySetupContext("check_calloc", 0);
4490
4491
/* "cysignals/memory.pxd":144
4492
* resulting memory is zeroed.
4493
* """
4494
* if nmemb == 0: # <<<<<<<<<<<<<<
4495
* return NULL
4496
* cdef void* ret = sig_calloc(nmemb, size)
4497
*/
4498
__pyx_t_1 = ((__pyx_v_nmemb == 0) != 0);
4499
if (__pyx_t_1) {
4500
4501
/* "cysignals/memory.pxd":145
4502
* """
4503
* if nmemb == 0:
4504
* return NULL # <<<<<<<<<<<<<<
4505
* cdef void* ret = sig_calloc(nmemb, size)
4506
* if unlikely(ret == NULL):
4507
*/
4508
__pyx_r = NULL;
4509
goto __pyx_L0;
4510
4511
/* "cysignals/memory.pxd":144
4512
* resulting memory is zeroed.
4513
* """
4514
* if nmemb == 0: # <<<<<<<<<<<<<<
4515
* return NULL
4516
* cdef void* ret = sig_calloc(nmemb, size)
4517
*/
4518
}
4519
4520
/* "cysignals/memory.pxd":146
4521
* if nmemb == 0:
4522
* return NULL
4523
* cdef void* ret = sig_calloc(nmemb, size) # <<<<<<<<<<<<<<
4524
* if unlikely(ret == NULL):
4525
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
4526
*/
4527
__pyx_v_ret = sig_calloc(__pyx_v_nmemb, __pyx_v_size);
4528
4529
/* "cysignals/memory.pxd":147
4530
* return NULL
4531
* cdef void* ret = sig_calloc(nmemb, size)
4532
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
4533
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
4534
* return ret
4535
*/
4536
__pyx_t_1 = (unlikely((__pyx_v_ret == NULL)) != 0);
4537
if (__pyx_t_1) {
4538
4539
/* "cysignals/memory.pxd":148
4540
* cdef void* ret = sig_calloc(nmemb, size)
4541
* if unlikely(ret == NULL):
4542
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size)) # <<<<<<<<<<<<<<
4543
* return ret
4544
*/
4545
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_nmemb); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 148, __pyx_L1_error)
4546
__Pyx_GOTREF(__pyx_t_2);
4547
__pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 148, __pyx_L1_error)
4548
__Pyx_GOTREF(__pyx_t_3);
4549
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 148, __pyx_L1_error)
4550
__Pyx_GOTREF(__pyx_t_4);
4551
__Pyx_GIVEREF(__pyx_t_2);
4552
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
4553
__Pyx_GIVEREF(__pyx_t_3);
4554
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
4555
__pyx_t_2 = 0;
4556
__pyx_t_3 = 0;
4557
__pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_allocate_s_s_bytes, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 148, __pyx_L1_error)
4558
__Pyx_GOTREF(__pyx_t_3);
4559
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4560
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 148, __pyx_L1_error)
4561
__Pyx_GOTREF(__pyx_t_4);
4562
__Pyx_GIVEREF(__pyx_t_3);
4563
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
4564
__pyx_t_3 = 0;
4565
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 148, __pyx_L1_error)
4566
__Pyx_GOTREF(__pyx_t_3);
4567
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4568
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
4569
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4570
__PYX_ERR(1, 148, __pyx_L1_error)
4571
4572
/* "cysignals/memory.pxd":147
4573
* return NULL
4574
* cdef void* ret = sig_calloc(nmemb, size)
4575
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
4576
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
4577
* return ret
4578
*/
4579
}
4580
4581
/* "cysignals/memory.pxd":149
4582
* if unlikely(ret == NULL):
4583
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
4584
* return ret # <<<<<<<<<<<<<<
4585
*/
4586
__pyx_r = __pyx_v_ret;
4587
goto __pyx_L0;
4588
4589
/* "cysignals/memory.pxd":139
4590
*
4591
*
4592
* cdef inline void* check_calloc(size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
4593
* """
4594
* Allocate memory for ``nmemb`` elements of size ``size``. The
4595
*/
4596
4597
/* function exit code */
4598
__pyx_L1_error:;
4599
__Pyx_XDECREF(__pyx_t_2);
4600
__Pyx_XDECREF(__pyx_t_3);
4601
__Pyx_XDECREF(__pyx_t_4);
4602
__Pyx_AddTraceback("cysignals.memory.check_calloc", __pyx_clineno, __pyx_lineno, __pyx_filename);
4603
__pyx_r = NULL;
4604
__pyx_L0:;
4605
__Pyx_RefNannyFinishContext();
4606
return __pyx_r;
4607
}
4608
4609
/* "sage/ext/stdsage.pxd":16
4610
*
4611
*
4612
* cdef inline PY_NEW(type t): # <<<<<<<<<<<<<<
4613
* """
4614
* Return ``t.__new__(t)``. This works even for types like
4615
*/
4616
4617
static CYTHON_INLINE PyObject *__pyx_f_4sage_3ext_7stdsage_PY_NEW(PyTypeObject *__pyx_v_t) {
4618
PyObject *__pyx_r = NULL;
4619
__Pyx_RefNannyDeclarations
4620
PyObject *__pyx_t_1 = NULL;
4621
__Pyx_RefNannySetupContext("PY_NEW", 0);
4622
4623
/* "sage/ext/stdsage.pxd":22
4624
* optimizations assume that ``tp_new`` doesn't change).
4625
* """
4626
* return (<PyTypeObject*>t).tp_new(t, <object>NULL, <object>NULL) # <<<<<<<<<<<<<<
4627
*
4628
*
4629
*/
4630
__Pyx_XDECREF(__pyx_r);
4631
__pyx_t_1 = ((PyTypeObject *)__pyx_v_t)->tp_new(((PyTypeObject *)__pyx_v_t), ((PyObject *)NULL), ((PyObject *)NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 22, __pyx_L1_error)
4632
__Pyx_GOTREF(__pyx_t_1);
4633
__pyx_r = __pyx_t_1;
4634
__pyx_t_1 = 0;
4635
goto __pyx_L0;
4636
4637
/* "sage/ext/stdsage.pxd":16
4638
*
4639
*
4640
* cdef inline PY_NEW(type t): # <<<<<<<<<<<<<<
4641
* """
4642
* Return ``t.__new__(t)``. This works even for types like
4643
*/
4644
4645
/* function exit code */
4646
__pyx_L1_error:;
4647
__Pyx_XDECREF(__pyx_t_1);
4648
__Pyx_AddTraceback("sage.ext.stdsage.PY_NEW", __pyx_clineno, __pyx_lineno, __pyx_filename);
4649
__pyx_r = 0;
4650
__pyx_L0:;
4651
__Pyx_XGIVEREF(__pyx_r);
4652
__Pyx_RefNannyFinishContext();
4653
return __pyx_r;
4654
}
4655
4656
/* "sage/ext/stdsage.pxd":25
4657
*
4658
*
4659
* cdef inline void PY_SET_TP_NEW(type dst, type src): # <<<<<<<<<<<<<<
4660
* """
4661
* Manually set ``dst.__new__`` to ``src.__new__``. This is used to
4662
*/
4663
4664
static CYTHON_INLINE void __pyx_f_4sage_3ext_7stdsage_PY_SET_TP_NEW(PyTypeObject *__pyx_v_dst, PyTypeObject *__pyx_v_src) {
4665
__Pyx_RefNannyDeclarations
4666
newfunc __pyx_t_1;
4667
__Pyx_RefNannySetupContext("PY_SET_TP_NEW", 0);
4668
4669
/* "sage/ext/stdsage.pxd":31
4670
* irrelevant base class ``tp_new`` methods.
4671
* """
4672
* (<PyTypeObject*>dst).tp_new = (<PyTypeObject*>src).tp_new # <<<<<<<<<<<<<<
4673
*
4674
*
4675
*/
4676
__pyx_t_1 = ((PyTypeObject *)__pyx_v_src)->tp_new;
4677
((PyTypeObject *)__pyx_v_dst)->tp_new = __pyx_t_1;
4678
4679
/* "sage/ext/stdsage.pxd":25
4680
*
4681
*
4682
* cdef inline void PY_SET_TP_NEW(type dst, type src): # <<<<<<<<<<<<<<
4683
* """
4684
* Manually set ``dst.__new__`` to ``src.__new__``. This is used to
4685
*/
4686
4687
/* function exit code */
4688
__Pyx_RefNannyFinishContext();
4689
}
4690
4691
/* "sage/ext/stdsage.pxd":34
4692
*
4693
*
4694
* cdef inline bint HAS_DICTIONARY(obj): # <<<<<<<<<<<<<<
4695
* """
4696
* Test whether the given object has a Python dictionary.
4697
*/
4698
4699
static CYTHON_INLINE int __pyx_f_4sage_3ext_7stdsage_HAS_DICTIONARY(PyObject *__pyx_v_obj) {
4700
int __pyx_r;
4701
__Pyx_RefNannyDeclarations
4702
__Pyx_RefNannySetupContext("HAS_DICTIONARY", 0);
4703
4704
/* "sage/ext/stdsage.pxd":38
4705
* Test whether the given object has a Python dictionary.
4706
* """
4707
* return Py_TYPE(obj).tp_dictoffset != 0 # <<<<<<<<<<<<<<
4708
*/
4709
__pyx_r = (Py_TYPE(__pyx_v_obj)->tp_dictoffset != 0);
4710
goto __pyx_L0;
4711
4712
/* "sage/ext/stdsage.pxd":34
4713
*
4714
*
4715
* cdef inline bint HAS_DICTIONARY(obj): # <<<<<<<<<<<<<<
4716
* """
4717
* Test whether the given object has a Python dictionary.
4718
*/
4719
4720
/* function exit code */
4721
__pyx_L0:;
4722
__Pyx_RefNannyFinishContext();
4723
return __pyx_r;
4724
}
4725
4726
/* "cysignals/signals.pxd":35
4727
* # (PyErr_Occurred() is non-NULL). To Cython, it will look like
4728
* # cython_check_exception() actually raised the exception.
4729
* cdef inline void cython_check_exception() nogil except *: # <<<<<<<<<<<<<<
4730
* pass
4731
*
4732
*/
4733
4734
static CYTHON_INLINE void __pyx_f_9cysignals_7signals_cython_check_exception(void) {
4735
4736
/* function exit code */
4737
}
4738
4739
static PyObject *__pyx_tp_new_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
4740
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *p;
4741
PyObject *o;
4742
if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
4743
o = (*t->tp_alloc)(t, 0);
4744
} else {
4745
o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
4746
}
4747
if (unlikely(!o)) return 0;
4748
p = ((struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *)o);
4749
p->a = ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)Py_None); Py_INCREF(Py_None);
4750
p->E = Py_None; Py_INCREF(Py_None);
4751
return o;
4752
}
4753
4754
static void __pyx_tp_dealloc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist(PyObject *o) {
4755
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *p = (struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *)o;
4756
#if PY_VERSION_HEX >= 0x030400a1
4757
if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
4758
if (PyObject_CallFinalizerFromDealloc(o)) return;
4759
}
4760
#endif
4761
PyObject_GC_UnTrack(o);
4762
Py_CLEAR(p->a);
4763
Py_CLEAR(p->E);
4764
(*Py_TYPE(o)->tp_free)(o);
4765
}
4766
4767
static int __pyx_tp_traverse_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist(PyObject *o, visitproc v, void *a) {
4768
int e;
4769
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *p = (struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *)o;
4770
if (p->a) {
4771
e = (*v)(((PyObject*)p->a), a); if (e) return e;
4772
}
4773
if (p->E) {
4774
e = (*v)(p->E, a); if (e) return e;
4775
}
4776
return 0;
4777
}
4778
4779
static int __pyx_tp_clear_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist(PyObject *o) {
4780
PyObject* tmp;
4781
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *p = (struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist *)o;
4782
tmp = ((PyObject*)p->a);
4783
p->a = ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)Py_None); Py_INCREF(Py_None);
4784
Py_XDECREF(tmp);
4785
tmp = ((PyObject*)p->E);
4786
p->E = Py_None; Py_INCREF(Py_None);
4787
Py_XDECREF(tmp);
4788
return 0;
4789
}
4790
static PyObject *__pyx_sq_item_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist(PyObject *o, Py_ssize_t i) {
4791
PyObject *r;
4792
PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
4793
r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
4794
Py_DECREF(x);
4795
return r;
4796
}
4797
4798
static PyMethodDef __pyx_methods_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist[] = {
4799
{0, 0, 0, 0}
4800
};
4801
4802
static PySequenceMethods __pyx_tp_as_sequence_anlist = {
4803
0, /*sq_length*/
4804
0, /*sq_concat*/
4805
0, /*sq_repeat*/
4806
__pyx_sq_item_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist, /*sq_item*/
4807
0, /*sq_slice*/
4808
0, /*sq_ass_item*/
4809
0, /*sq_ass_slice*/
4810
0, /*sq_contains*/
4811
0, /*sq_inplace_concat*/
4812
0, /*sq_inplace_repeat*/
4813
};
4814
4815
static PyMappingMethods __pyx_tp_as_mapping_anlist = {
4816
0, /*mp_length*/
4817
__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_5__getitem__, /*mp_subscript*/
4818
0, /*mp_ass_subscript*/
4819
};
4820
4821
static PyTypeObject __pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist = {
4822
PyVarObject_HEAD_INIT(0, 0)
4823
"code.alex.psage.psage.ellcurve.lseries.fast_twist.anlist", /*tp_name*/
4824
sizeof(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist), /*tp_basicsize*/
4825
0, /*tp_itemsize*/
4826
__pyx_tp_dealloc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist, /*tp_dealloc*/
4827
0, /*tp_print*/
4828
0, /*tp_getattr*/
4829
0, /*tp_setattr*/
4830
#if PY_MAJOR_VERSION < 3
4831
0, /*tp_compare*/
4832
#endif
4833
#if PY_MAJOR_VERSION >= 3
4834
0, /*tp_as_async*/
4835
#endif
4836
__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_3__repr__, /*tp_repr*/
4837
0, /*tp_as_number*/
4838
&__pyx_tp_as_sequence_anlist, /*tp_as_sequence*/
4839
&__pyx_tp_as_mapping_anlist, /*tp_as_mapping*/
4840
0, /*tp_hash*/
4841
0, /*tp_call*/
4842
0, /*tp_str*/
4843
0, /*tp_getattro*/
4844
0, /*tp_setattro*/
4845
0, /*tp_as_buffer*/
4846
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
4847
0, /*tp_doc*/
4848
__pyx_tp_traverse_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist, /*tp_traverse*/
4849
__pyx_tp_clear_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist, /*tp_clear*/
4850
0, /*tp_richcompare*/
4851
0, /*tp_weaklistoffset*/
4852
0, /*tp_iter*/
4853
0, /*tp_iternext*/
4854
__pyx_methods_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist, /*tp_methods*/
4855
0, /*tp_members*/
4856
0, /*tp_getset*/
4857
0, /*tp_base*/
4858
0, /*tp_dict*/
4859
0, /*tp_descr_get*/
4860
0, /*tp_descr_set*/
4861
0, /*tp_dictoffset*/
4862
__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_1__init__, /*tp_init*/
4863
0, /*tp_alloc*/
4864
__pyx_tp_new_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist, /*tp_new*/
4865
0, /*tp_free*/
4866
0, /*tp_is_gc*/
4867
0, /*tp_bases*/
4868
0, /*tp_mro*/
4869
0, /*tp_cache*/
4870
0, /*tp_subclasses*/
4871
0, /*tp_weaklist*/
4872
0, /*tp_del*/
4873
0, /*tp_version_tag*/
4874
#if PY_VERSION_HEX >= 0x030400a1
4875
0, /*tp_finalize*/
4876
#endif
4877
};
4878
4879
static PyObject *__pyx_tp_new_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
4880
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *p;
4881
PyObject *o;
4882
if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
4883
o = (*t->tp_alloc)(t, 0);
4884
} else {
4885
o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
4886
}
4887
if (unlikely(!o)) return 0;
4888
p = ((struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *)o);
4889
p->a = ((struct __pyx_obj_4sage_7finance_11time_series_TimeSeries *)Py_None); Py_INCREF(Py_None);
4890
p->E = Py_None; Py_INCREF(Py_None);
4891
return o;
4892
}
4893
4894
static void __pyx_tp_dealloc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists(PyObject *o) {
4895
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *p = (struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *)o;
4896
#if PY_VERSION_HEX >= 0x030400a1
4897
if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
4898
if (PyObject_CallFinalizerFromDealloc(o)) return;
4899
}
4900
#endif
4901
PyObject_GC_UnTrack(o);
4902
Py_CLEAR(p->a);
4903
Py_CLEAR(p->E);
4904
(*Py_TYPE(o)->tp_free)(o);
4905
}
4906
4907
static int __pyx_tp_traverse_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists(PyObject *o, visitproc v, void *a) {
4908
int e;
4909
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *p = (struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *)o;
4910
if (p->a) {
4911
e = (*v)(((PyObject*)p->a), a); if (e) return e;
4912
}
4913
if (p->E) {
4914
e = (*v)(p->E, a); if (e) return e;
4915
}
4916
return 0;
4917
}
4918
4919
static int __pyx_tp_clear_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists(PyObject *o) {
4920
PyObject* tmp;
4921
struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *p = (struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists *)o;
4922
tmp = ((PyObject*)p->a);
4923
p->a = ((struct __pyx_obj_4sage_7finance_11time_series_TimeSeries *)Py_None); Py_INCREF(Py_None);
4924
Py_XDECREF(tmp);
4925
tmp = ((PyObject*)p->E);
4926
p->E = Py_None; Py_INCREF(Py_None);
4927
Py_XDECREF(tmp);
4928
return 0;
4929
}
4930
4931
static PyMethodDef __pyx_methods_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists[] = {
4932
{"elliptic_curve", (PyCFunction)__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_5elliptic_curve, METH_NOARGS, __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_4elliptic_curve},
4933
{"discs", (PyCFunction)__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_7discs, METH_O, __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_6discs},
4934
{"twist_special_value", (PyCFunction)__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_9twist_special_value, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_8twist_special_value},
4935
{0, 0, 0, 0}
4936
};
4937
4938
static PyTypeObject __pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists = {
4939
PyVarObject_HEAD_INIT(0, 0)
4940
"code.alex.psage.psage.ellcurve.lseries.fast_twist.FastHeegnerTwists", /*tp_name*/
4941
sizeof(struct __pyx_obj_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists), /*tp_basicsize*/
4942
0, /*tp_itemsize*/
4943
__pyx_tp_dealloc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists, /*tp_dealloc*/
4944
0, /*tp_print*/
4945
0, /*tp_getattr*/
4946
0, /*tp_setattr*/
4947
#if PY_MAJOR_VERSION < 3
4948
0, /*tp_compare*/
4949
#endif
4950
#if PY_MAJOR_VERSION >= 3
4951
0, /*tp_as_async*/
4952
#endif
4953
__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_3__repr__, /*tp_repr*/
4954
0, /*tp_as_number*/
4955
0, /*tp_as_sequence*/
4956
0, /*tp_as_mapping*/
4957
0, /*tp_hash*/
4958
0, /*tp_call*/
4959
0, /*tp_str*/
4960
0, /*tp_getattro*/
4961
0, /*tp_setattro*/
4962
0, /*tp_as_buffer*/
4963
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
4964
0, /*tp_doc*/
4965
__pyx_tp_traverse_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists, /*tp_traverse*/
4966
__pyx_tp_clear_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists, /*tp_clear*/
4967
0, /*tp_richcompare*/
4968
0, /*tp_weaklistoffset*/
4969
0, /*tp_iter*/
4970
0, /*tp_iternext*/
4971
__pyx_methods_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists, /*tp_methods*/
4972
0, /*tp_members*/
4973
0, /*tp_getset*/
4974
0, /*tp_base*/
4975
0, /*tp_dict*/
4976
0, /*tp_descr_get*/
4977
0, /*tp_descr_set*/
4978
0, /*tp_dictoffset*/
4979
__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_1__init__, /*tp_init*/
4980
0, /*tp_alloc*/
4981
__pyx_tp_new_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists, /*tp_new*/
4982
0, /*tp_free*/
4983
0, /*tp_is_gc*/
4984
0, /*tp_bases*/
4985
0, /*tp_mro*/
4986
0, /*tp_cache*/
4987
0, /*tp_subclasses*/
4988
0, /*tp_weaklist*/
4989
0, /*tp_del*/
4990
0, /*tp_version_tag*/
4991
#if PY_VERSION_HEX >= 0x030400a1
4992
0, /*tp_finalize*/
4993
#endif
4994
};
4995
4996
static PyMethodDef __pyx_methods[] = {
4997
{0, 0, 0, 0}
4998
};
4999
5000
#if PY_MAJOR_VERSION >= 3
5001
static struct PyModuleDef __pyx_moduledef = {
5002
#if PY_VERSION_HEX < 0x03020000
5003
{ PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
5004
#else
5005
PyModuleDef_HEAD_INIT,
5006
#endif
5007
"fast_twist",
5008
__pyx_k_File_fast_twist_pyx_starting_at, /* m_doc */
5009
-1, /* m_size */
5010
__pyx_methods /* m_methods */,
5011
NULL, /* m_reload */
5012
NULL, /* m_traverse */
5013
NULL, /* m_clear */
5014
NULL /* m_free */
5015
};
5016
#endif
5017
5018
static __Pyx_StringTabEntry __pyx_string_tab[] = {
5019
{&__pyx_n_s_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 0, 1, 1},
5020
{&__pyx_n_s_D, __pyx_k_D, sizeof(__pyx_k_D), 0, 0, 1, 1},
5021
{&__pyx_n_s_E, __pyx_k_E, sizeof(__pyx_k_E), 0, 0, 1, 1},
5022
{&__pyx_kp_s_Fast_Heegner_twist_object_associ, __pyx_k_Fast_Heegner_twist_object_associ, sizeof(__pyx_k_Fast_Heegner_twist_object_associ), 0, 0, 1, 0},
5023
{&__pyx_kp_s_List_of_coefficients_a_n_E, __pyx_k_List_of_coefficients_a_n_E, sizeof(__pyx_k_List_of_coefficients_a_n_E), 0, 0, 1, 0},
5024
{&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
5025
{&__pyx_n_s_SmallJac, __pyx_k_SmallJac, sizeof(__pyx_k_SmallJac), 0, 0, 1, 1},
5026
{&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
5027
{&__pyx_n_s_ZZ, __pyx_k_ZZ, sizeof(__pyx_k_ZZ), 0, 0, 1, 1},
5028
{&__pyx_n_s_a_invariants, __pyx_k_a_invariants, sizeof(__pyx_k_a_invariants), 0, 0, 1, 1},
5029
{&__pyx_n_s_ap, __pyx_k_ap, sizeof(__pyx_k_ap), 0, 0, 1, 1},
5030
{&__pyx_n_s_conductor, __pyx_k_conductor, sizeof(__pyx_k_conductor), 0, 0, 1, 1},
5031
{&__pyx_n_s_deprecation, __pyx_k_deprecation, sizeof(__pyx_k_deprecation), 0, 0, 1, 1},
5032
{&__pyx_kp_s_failed_to_allocate_s_bytes, __pyx_k_failed_to_allocate_s_bytes, sizeof(__pyx_k_failed_to_allocate_s_bytes), 0, 0, 1, 0},
5033
{&__pyx_kp_s_failed_to_allocate_s_s_bytes, __pyx_k_failed_to_allocate_s_s_bytes, sizeof(__pyx_k_failed_to_allocate_s_s_bytes), 0, 0, 1, 0},
5034
{&__pyx_n_s_heegner_discriminants, __pyx_k_heegner_discriminants, sizeof(__pyx_k_heegner_discriminants), 0, 0, 1, 1},
5035
{&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
5036
{&__pyx_kp_s_import_cysignals_signals_pxi_ins, __pyx_k_import_cysignals_signals_pxi_ins, sizeof(__pyx_k_import_cysignals_signals_pxi_ins), 0, 0, 1, 0},
5037
{&__pyx_n_s_init_memory_functions, __pyx_k_init_memory_functions, sizeof(__pyx_k_init_memory_functions), 0, 0, 1, 1},
5038
{&__pyx_n_s_iteritems, __pyx_k_iteritems, sizeof(__pyx_k_iteritems), 0, 0, 1, 1},
5039
{&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1},
5040
{&__pyx_n_s_kronecker, __pyx_k_kronecker, sizeof(__pyx_k_kronecker), 0, 0, 1, 1},
5041
{&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
5042
{&__pyx_kp_s_not_enough_terms_of_L_series_kno, __pyx_k_not_enough_terms_of_L_series_kno, sizeof(__pyx_k_not_enough_terms_of_L_series_kno), 0, 0, 1, 0},
5043
{&__pyx_n_s_psage_libs_smalljac_wrapper, __pyx_k_psage_libs_smalljac_wrapper, sizeof(__pyx_k_psage_libs_smalljac_wrapper), 0, 0, 1, 1},
5044
{&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
5045
{&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
5046
{&__pyx_n_s_root_number, __pyx_k_root_number, sizeof(__pyx_k_root_number), 0, 0, 1, 1},
5047
{&__pyx_n_s_sage_ext_memory, __pyx_k_sage_ext_memory, sizeof(__pyx_k_sage_ext_memory), 0, 0, 1, 1},
5048
{&__pyx_n_s_sage_misc_superseded, __pyx_k_sage_misc_superseded, sizeof(__pyx_k_sage_misc_superseded), 0, 0, 1, 1},
5049
{&__pyx_n_s_sage_rings_all, __pyx_k_sage_rings_all, sizeof(__pyx_k_sage_rings_all), 0, 0, 1, 1},
5050
{&__pyx_n_s_short_weierstrass_model, __pyx_k_short_weierstrass_model, sizeof(__pyx_k_short_weierstrass_model), 0, 0, 1, 1},
5051
{&__pyx_n_s_sort, __pyx_k_sort, sizeof(__pyx_k_sort), 0, 0, 1, 1},
5052
{&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
5053
{&__pyx_n_s_tol, __pyx_k_tol, sizeof(__pyx_k_tol), 0, 0, 1, 1},
5054
{&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
5055
{0, 0, 0, 0, 0, 0, 0}
5056
};
5057
static int __Pyx_InitCachedBuiltins(void) {
5058
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 39, __pyx_L1_error)
5059
__pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 154, __pyx_L1_error)
5060
__pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 91, __pyx_L1_error)
5061
return 0;
5062
__pyx_L1_error:;
5063
return -1;
5064
}
5065
5066
static int __Pyx_InitCachedConstants(void) {
5067
__Pyx_RefNannyDeclarations
5068
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
5069
5070
/* "../../../../../../../sage/sage-7.5/src/sage/ext/interrupt.pxi":2
5071
* from sage.misc.superseded import deprecation
5072
* deprecation(20002, '''import "cysignals/signals.pxi" instead of "sage/ext/interrupt.pxi"''') # <<<<<<<<<<<<<<
5073
*
5074
* include "cysignals/signals.pxi"
5075
*/
5076
__pyx_tuple_ = PyTuple_Pack(2, __pyx_int_20002, __pyx_kp_s_import_cysignals_signals_pxi_ins); if (unlikely(!__pyx_tuple_)) __PYX_ERR(8, 2, __pyx_L1_error)
5077
__Pyx_GOTREF(__pyx_tuple_);
5078
__Pyx_GIVEREF(__pyx_tuple_);
5079
__Pyx_RefNannyFinishContext();
5080
return 0;
5081
__pyx_L1_error:;
5082
__Pyx_RefNannyFinishContext();
5083
return -1;
5084
}
5085
5086
static int __Pyx_InitGlobals(void) {
5087
if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
5088
__pyx_float_1eneg_6 = PyFloat_FromDouble(1e-6); if (unlikely(!__pyx_float_1eneg_6)) __PYX_ERR(0, 1, __pyx_L1_error)
5089
__pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
5090
__pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
5091
__pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
5092
__pyx_int_20002 = PyInt_FromLong(20002L); if (unlikely(!__pyx_int_20002)) __PYX_ERR(0, 1, __pyx_L1_error)
5093
return 0;
5094
__pyx_L1_error:;
5095
return -1;
5096
}
5097
5098
#if PY_MAJOR_VERSION < 3
5099
PyMODINIT_FUNC initfast_twist(void); /*proto*/
5100
PyMODINIT_FUNC initfast_twist(void)
5101
#else
5102
PyMODINIT_FUNC PyInit_fast_twist(void); /*proto*/
5103
PyMODINIT_FUNC PyInit_fast_twist(void)
5104
#endif
5105
{
5106
PyObject *__pyx_t_1 = NULL;
5107
int __pyx_t_2;
5108
PyObject *__pyx_t_3 = NULL;
5109
PyObject *__pyx_t_4 = NULL;
5110
__Pyx_RefNannyDeclarations
5111
#if CYTHON_REFNANNY
5112
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
5113
if (!__Pyx_RefNanny) {
5114
PyErr_Clear();
5115
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
5116
if (!__Pyx_RefNanny)
5117
Py_FatalError("failed to import 'refnanny' module");
5118
}
5119
#endif
5120
__Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_fast_twist(void)", 0);
5121
if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5122
__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
5123
__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
5124
__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
5125
#ifdef __Pyx_CyFunction_USED
5126
if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5127
#endif
5128
#ifdef __Pyx_FusedFunction_USED
5129
if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5130
#endif
5131
#ifdef __Pyx_Coroutine_USED
5132
if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5133
#endif
5134
#ifdef __Pyx_Generator_USED
5135
if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5136
#endif
5137
#ifdef __Pyx_StopAsyncIteration_USED
5138
if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5139
#endif
5140
/*--- Library function declarations ---*/
5141
/*--- Threads initialization code ---*/
5142
#if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
5143
#ifdef WITH_THREAD /* Python build with threading support? */
5144
PyEval_InitThreads();
5145
#endif
5146
#endif
5147
/*--- Module creation code ---*/
5148
#if PY_MAJOR_VERSION < 3
5149
__pyx_m = Py_InitModule4("fast_twist", __pyx_methods, __pyx_k_File_fast_twist_pyx_starting_at, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
5150
#else
5151
__pyx_m = PyModule_Create(&__pyx_moduledef);
5152
#endif
5153
if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
5154
__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
5155
Py_INCREF(__pyx_d);
5156
__pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
5157
#if CYTHON_COMPILING_IN_PYPY
5158
Py_INCREF(__pyx_b);
5159
#endif
5160
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
5161
/*--- Initialize various global constants etc. ---*/
5162
if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5163
#if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
5164
if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5165
#endif
5166
if (__pyx_module_is_main_code__alex__psage__psage__ellcurve__lseries__fast_twist) {
5167
if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5168
}
5169
#if PY_MAJOR_VERSION >= 3
5170
{
5171
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
5172
if (!PyDict_GetItemString(modules, "code.alex.psage.psage.ellcurve.lseries.fast_twist")) {
5173
if (unlikely(PyDict_SetItemString(modules, "code.alex.psage.psage.ellcurve.lseries.fast_twist", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
5174
}
5175
}
5176
#endif
5177
/*--- Builtin init code ---*/
5178
if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5179
/*--- Constants init code ---*/
5180
if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5181
/*--- Global init code ---*/
5182
/*--- Variable export code ---*/
5183
/*--- Function export code ---*/
5184
/*--- Type init code ---*/
5185
if (PyType_Ready(&__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
5186
__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist.tp_print = 0;
5187
#if CYTHON_COMPILING_IN_CPYTHON
5188
{
5189
PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 26, __pyx_L1_error)
5190
if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
5191
__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
5192
__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist___init__.doc = __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist___init__;
5193
((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist___init__;
5194
}
5195
}
5196
#endif
5197
#if CYTHON_COMPILING_IN_CPYTHON
5198
{
5199
PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist, "__repr__"); if (unlikely(!wrapper)) __PYX_ERR(0, 26, __pyx_L1_error)
5200
if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
5201
__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_2__repr__ = *((PyWrapperDescrObject *)wrapper)->d_base;
5202
__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_2__repr__.doc = __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_2__repr__;
5203
((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_2__repr__;
5204
}
5205
}
5206
#endif
5207
#if CYTHON_COMPILING_IN_CPYTHON
5208
{
5209
PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist, "__getitem__"); if (unlikely(!wrapper)) __PYX_ERR(0, 26, __pyx_L1_error)
5210
if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
5211
__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_4__getitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
5212
__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_4__getitem__.doc = __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_4__getitem__;
5213
((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_6anlist_4__getitem__;
5214
}
5215
}
5216
#endif
5217
if (PyObject_SetAttrString(__pyx_m, "anlist", (PyObject *)&__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
5218
__pyx_ptype_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist = &__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_anlist;
5219
if (PyType_Ready(&__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists) < 0) __PYX_ERR(0, 103, __pyx_L1_error)
5220
__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists.tp_print = 0;
5221
#if CYTHON_COMPILING_IN_CPYTHON
5222
{
5223
PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 103, __pyx_L1_error)
5224
if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
5225
__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
5226
__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists___init__.doc = __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists___init__;
5227
((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists___init__;
5228
}
5229
}
5230
#endif
5231
#if CYTHON_COMPILING_IN_CPYTHON
5232
{
5233
PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists, "__repr__"); if (unlikely(!wrapper)) __PYX_ERR(0, 103, __pyx_L1_error)
5234
if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
5235
__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_2__repr__ = *((PyWrapperDescrObject *)wrapper)->d_base;
5236
__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_2__repr__.doc = __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_2__repr__;
5237
((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_17FastHeegnerTwists_2__repr__;
5238
}
5239
}
5240
#endif
5241
if (PyObject_SetAttrString(__pyx_m, "FastHeegnerTwists", (PyObject *)&__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists) < 0) __PYX_ERR(0, 103, __pyx_L1_error)
5242
__pyx_ptype_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists = &__pyx_type_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_FastHeegnerTwists;
5243
/*--- Type import code ---*/
5244
__pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
5245
#if CYTHON_COMPILING_IN_PYPY
5246
sizeof(PyTypeObject),
5247
#else
5248
sizeof(PyHeapTypeObject),
5249
#endif
5250
0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(3, 9, __pyx_L1_error)
5251
__pyx_ptype_4sage_7finance_11time_series_TimeSeries = __Pyx_ImportType("sage.finance.time_series", "TimeSeries", sizeof(struct __pyx_obj_4sage_7finance_11time_series_TimeSeries), 1); if (unlikely(!__pyx_ptype_4sage_7finance_11time_series_TimeSeries)) __PYX_ERR(4, 1, __pyx_L1_error)
5252
__pyx_vtabptr_4sage_7finance_11time_series_TimeSeries = (struct __pyx_vtabstruct_4sage_7finance_11time_series_TimeSeries*)__Pyx_GetVtable(__pyx_ptype_4sage_7finance_11time_series_TimeSeries->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_7finance_11time_series_TimeSeries)) __PYX_ERR(4, 1, __pyx_L1_error)
5253
__pyx_ptype_4sage_5stats_7intlist_IntList = __Pyx_ImportType("sage.stats.intlist", "IntList", sizeof(struct __pyx_obj_4sage_5stats_7intlist_IntList), 1); if (unlikely(!__pyx_ptype_4sage_5stats_7intlist_IntList)) __PYX_ERR(5, 8, __pyx_L1_error)
5254
__pyx_vtabptr_4sage_5stats_7intlist_IntList = (struct __pyx_vtabstruct_4sage_5stats_7intlist_IntList*)__Pyx_GetVtable(__pyx_ptype_4sage_5stats_7intlist_IntList->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_5stats_7intlist_IntList)) __PYX_ERR(5, 8, __pyx_L1_error)
5255
/*--- Variable import code ---*/
5256
__pyx_t_1 = __Pyx_ImportModule("cysignals.signals"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
5257
if (__Pyx_ImportVoidPtr(__pyx_t_1, "cysigs", (void **)&__pyx_vp_9cysignals_7signals_cysigs, "cysigs_t") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5258
Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5259
/*--- Function import code ---*/
5260
/*--- Execution code ---*/
5261
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
5262
if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5263
#endif
5264
5265
/* "../../../../../../../sage/sage-7.5/local/lib/python2.7/site-packages/cysignals/signals.pxi":24
5266
* # This *must* be done for every module using interrupt functions
5267
* # otherwise you will get segmentation faults.
5268
* import_cysignals__signals() # <<<<<<<<<<<<<<
5269
*/
5270
__pyx_t_2 = import_cysignals__signals(); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(6, 24, __pyx_L1_error)
5271
5272
/* "../../../../../../../sage/sage-7.5/src/sage/ext/stdsage.pxi":24
5273
*
5274
* from sage.ext.stdsage cimport PY_NEW, HAS_DICTIONARY
5275
* from sage.ext.memory import init_memory_functions # <<<<<<<<<<<<<<
5276
*/
5277
__pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 24, __pyx_L1_error)
5278
__Pyx_GOTREF(__pyx_t_3);
5279
__Pyx_INCREF(__pyx_n_s_init_memory_functions);
5280
__Pyx_GIVEREF(__pyx_n_s_init_memory_functions);
5281
PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_init_memory_functions);
5282
__pyx_t_4 = __Pyx_Import(__pyx_n_s_sage_ext_memory, __pyx_t_3, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(7, 24, __pyx_L1_error)
5283
__Pyx_GOTREF(__pyx_t_4);
5284
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5285
__pyx_t_3 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_init_memory_functions); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 24, __pyx_L1_error)
5286
__Pyx_GOTREF(__pyx_t_3);
5287
if (PyDict_SetItem(__pyx_d, __pyx_n_s_init_memory_functions, __pyx_t_3) < 0) __PYX_ERR(7, 24, __pyx_L1_error)
5288
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5289
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5290
5291
/* "../../../../../../../sage/sage-7.5/src/sage/ext/interrupt.pxi":1
5292
* from sage.misc.superseded import deprecation # <<<<<<<<<<<<<<
5293
* deprecation(20002, '''import "cysignals/signals.pxi" instead of "sage/ext/interrupt.pxi"''')
5294
*
5295
*/
5296
__pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 1, __pyx_L1_error)
5297
__Pyx_GOTREF(__pyx_t_4);
5298
__Pyx_INCREF(__pyx_n_s_deprecation);
5299
__Pyx_GIVEREF(__pyx_n_s_deprecation);
5300
PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_deprecation);
5301
__pyx_t_3 = __Pyx_Import(__pyx_n_s_sage_misc_superseded, __pyx_t_4, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(8, 1, __pyx_L1_error)
5302
__Pyx_GOTREF(__pyx_t_3);
5303
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5304
__pyx_t_4 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_deprecation); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 1, __pyx_L1_error)
5305
__Pyx_GOTREF(__pyx_t_4);
5306
if (PyDict_SetItem(__pyx_d, __pyx_n_s_deprecation, __pyx_t_4) < 0) __PYX_ERR(8, 1, __pyx_L1_error)
5307
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5308
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5309
5310
/* "../../../../../../../sage/sage-7.5/src/sage/ext/interrupt.pxi":2
5311
* from sage.misc.superseded import deprecation
5312
* deprecation(20002, '''import "cysignals/signals.pxi" instead of "sage/ext/interrupt.pxi"''') # <<<<<<<<<<<<<<
5313
*
5314
* include "cysignals/signals.pxi"
5315
*/
5316
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_deprecation); if (unlikely(!__pyx_t_3)) __PYX_ERR(8, 2, __pyx_L1_error)
5317
__Pyx_GOTREF(__pyx_t_3);
5318
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 2, __pyx_L1_error)
5319
__Pyx_GOTREF(__pyx_t_4);
5320
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5321
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5322
5323
/* "../../../../../../../sage/sage-7.5/local/lib/python2.7/site-packages/cysignals/signals.pxi":24
5324
* # This *must* be done for every module using interrupt functions
5325
* # otherwise you will get segmentation faults.
5326
* import_cysignals__signals() # <<<<<<<<<<<<<<
5327
*/
5328
__pyx_t_2 = import_cysignals__signals(); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(6, 24, __pyx_L1_error)
5329
5330
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":9
5331
* include "interrupt.pxi"
5332
*
5333
* from sage.rings.all import ZZ # <<<<<<<<<<<<<<
5334
*
5335
* from psage.libs.smalljac.wrapper import SmallJac
5336
*/
5337
__pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9, __pyx_L1_error)
5338
__Pyx_GOTREF(__pyx_t_4);
5339
__Pyx_INCREF(__pyx_n_s_ZZ);
5340
__Pyx_GIVEREF(__pyx_n_s_ZZ);
5341
PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_ZZ);
5342
__pyx_t_3 = __Pyx_Import(__pyx_n_s_sage_rings_all, __pyx_t_4, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9, __pyx_L1_error)
5343
__Pyx_GOTREF(__pyx_t_3);
5344
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5345
__pyx_t_4 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_ZZ); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9, __pyx_L1_error)
5346
__Pyx_GOTREF(__pyx_t_4);
5347
if (PyDict_SetItem(__pyx_d, __pyx_n_s_ZZ, __pyx_t_4) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
5348
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5349
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5350
5351
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":11
5352
* from sage.rings.all import ZZ
5353
*
5354
* from psage.libs.smalljac.wrapper import SmallJac # <<<<<<<<<<<<<<
5355
*
5356
* from sage.finance.time_series cimport TimeSeries
5357
*/
5358
__pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error)
5359
__Pyx_GOTREF(__pyx_t_3);
5360
__Pyx_INCREF(__pyx_n_s_SmallJac);
5361
__Pyx_GIVEREF(__pyx_n_s_SmallJac);
5362
PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_SmallJac);
5363
__pyx_t_4 = __Pyx_Import(__pyx_n_s_psage_libs_smalljac_wrapper, __pyx_t_3, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 11, __pyx_L1_error)
5364
__Pyx_GOTREF(__pyx_t_4);
5365
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5366
__pyx_t_3 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_SmallJac); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error)
5367
__Pyx_GOTREF(__pyx_t_3);
5368
if (PyDict_SetItem(__pyx_d, __pyx_n_s_SmallJac, __pyx_t_3) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
5369
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5370
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5371
5372
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":24
5373
* cdef double gsl_sf_expint_E1(double)
5374
*
5375
* cdef double pi = 3.1415926535897932384626433833 # <<<<<<<<<<<<<<
5376
*
5377
* cdef class anlist:
5378
*/
5379
__pyx_v_4code_4alex_5psage_5psage_8ellcurve_7lseries_10fast_twist_pi = 3.1415926535897932384626433833;
5380
5381
/* "code/alex/psage/psage/ellcurve/lseries/fast_twist.pyx":1
5382
* """ # <<<<<<<<<<<<<<
5383
* Numerically computing L'(E/K,1) for E an elliptic curve over Q and K a
5384
* quadratic imaginary field satisfying the Heegner hypothesis.
5385
*/
5386
__pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
5387
__Pyx_GOTREF(__pyx_t_4);
5388
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_4) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5389
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5390
5391
/* "cysignals/signals.pxd":35
5392
* # (PyErr_Occurred() is non-NULL). To Cython, it will look like
5393
* # cython_check_exception() actually raised the exception.
5394
* cdef inline void cython_check_exception() nogil except *: # <<<<<<<<<<<<<<
5395
* pass
5396
*
5397
*/
5398
5399
/*--- Wrapped vars code ---*/
5400
5401
goto __pyx_L0;
5402
__pyx_L1_error:;
5403
__Pyx_XDECREF(__pyx_t_1);
5404
__Pyx_XDECREF(__pyx_t_3);
5405
__Pyx_XDECREF(__pyx_t_4);
5406
if (__pyx_m) {
5407
if (__pyx_d) {
5408
__Pyx_AddTraceback("init code.alex.psage.psage.ellcurve.lseries.fast_twist", __pyx_clineno, __pyx_lineno, __pyx_filename);
5409
}
5410
Py_DECREF(__pyx_m); __pyx_m = 0;
5411
} else if (!PyErr_Occurred()) {
5412
PyErr_SetString(PyExc_ImportError, "init code.alex.psage.psage.ellcurve.lseries.fast_twist");
5413
}
5414
__pyx_L0:;
5415
__Pyx_RefNannyFinishContext();
5416
#if PY_MAJOR_VERSION < 3
5417
return;
5418
#else
5419
return __pyx_m;
5420
#endif
5421
}
5422
5423
/* --- Runtime support code --- */
5424
/* Refnanny */
5425
#if CYTHON_REFNANNY
5426
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
5427
PyObject *m = NULL, *p = NULL;
5428
void *r = NULL;
5429
m = PyImport_ImportModule((char *)modname);
5430
if (!m) goto end;
5431
p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
5432
if (!p) goto end;
5433
r = PyLong_AsVoidPtr(p);
5434
end:
5435
Py_XDECREF(p);
5436
Py_XDECREF(m);
5437
return (__Pyx_RefNannyAPIStruct *)r;
5438
}
5439
#endif
5440
5441
/* GetBuiltinName */
5442
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
5443
PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
5444
if (unlikely(!result)) {
5445
PyErr_Format(PyExc_NameError,
5446
#if PY_MAJOR_VERSION >= 3
5447
"name '%U' is not defined", name);
5448
#else
5449
"name '%.200s' is not defined", PyString_AS_STRING(name));
5450
#endif
5451
}
5452
return result;
5453
}
5454
5455
/* RaiseArgTupleInvalid */
5456
static void __Pyx_RaiseArgtupleInvalid(
5457
const char* func_name,
5458
int exact,
5459
Py_ssize_t num_min,
5460
Py_ssize_t num_max,
5461
Py_ssize_t num_found)
5462
{
5463
Py_ssize_t num_expected;
5464
const char *more_or_less;
5465
if (num_found < num_min) {
5466
num_expected = num_min;
5467
more_or_less = "at least";
5468
} else {
5469
num_expected = num_max;
5470
more_or_less = "at most";
5471
}
5472
if (exact) {
5473
more_or_less = "exactly";
5474
}
5475
PyErr_Format(PyExc_TypeError,
5476
"%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
5477
func_name, more_or_less, num_expected,
5478
(num_expected == 1) ? "" : "s", num_found);
5479
}
5480
5481
/* RaiseDoubleKeywords */
5482
static void __Pyx_RaiseDoubleKeywordsError(
5483
const char* func_name,
5484
PyObject* kw_name)
5485
{
5486
PyErr_Format(PyExc_TypeError,
5487
#if PY_MAJOR_VERSION >= 3
5488
"%s() got multiple values for keyword argument '%U'", func_name, kw_name);
5489
#else
5490
"%s() got multiple values for keyword argument '%s'", func_name,
5491
PyString_AsString(kw_name));
5492
#endif
5493
}
5494
5495
/* ParseKeywords */
5496
static int __Pyx_ParseOptionalKeywords(
5497
PyObject *kwds,
5498
PyObject **argnames[],
5499
PyObject *kwds2,
5500
PyObject *values[],
5501
Py_ssize_t num_pos_args,
5502
const char* function_name)
5503
{
5504
PyObject *key = 0, *value = 0;
5505
Py_ssize_t pos = 0;
5506
PyObject*** name;
5507
PyObject*** first_kw_arg = argnames + num_pos_args;
5508
while (PyDict_Next(kwds, &pos, &key, &value)) {
5509
name = first_kw_arg;
5510
while (*name && (**name != key)) name++;
5511
if (*name) {
5512
values[name-argnames] = value;
5513
continue;
5514
}
5515
name = first_kw_arg;
5516
#if PY_MAJOR_VERSION < 3
5517
if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
5518
while (*name) {
5519
if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
5520
&& _PyString_Eq(**name, key)) {
5521
values[name-argnames] = value;
5522
break;
5523
}
5524
name++;
5525
}
5526
if (*name) continue;
5527
else {
5528
PyObject*** argname = argnames;
5529
while (argname != first_kw_arg) {
5530
if ((**argname == key) || (
5531
(CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
5532
&& _PyString_Eq(**argname, key))) {
5533
goto arg_passed_twice;
5534
}
5535
argname++;
5536
}
5537
}
5538
} else
5539
#endif
5540
if (likely(PyUnicode_Check(key))) {
5541
while (*name) {
5542
int cmp = (**name == key) ? 0 :
5543
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
5544
(PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
5545
#endif
5546
PyUnicode_Compare(**name, key);
5547
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
5548
if (cmp == 0) {
5549
values[name-argnames] = value;
5550
break;
5551
}
5552
name++;
5553
}
5554
if (*name) continue;
5555
else {
5556
PyObject*** argname = argnames;
5557
while (argname != first_kw_arg) {
5558
int cmp = (**argname == key) ? 0 :
5559
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
5560
(PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
5561
#endif
5562
PyUnicode_Compare(**argname, key);
5563
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
5564
if (cmp == 0) goto arg_passed_twice;
5565
argname++;
5566
}
5567
}
5568
} else
5569
goto invalid_keyword_type;
5570
if (kwds2) {
5571
if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
5572
} else {
5573
goto invalid_keyword;
5574
}
5575
}
5576
return 0;
5577
arg_passed_twice:
5578
__Pyx_RaiseDoubleKeywordsError(function_name, key);
5579
goto bad;
5580
invalid_keyword_type:
5581
PyErr_Format(PyExc_TypeError,
5582
"%.200s() keywords must be strings", function_name);
5583
goto bad;
5584
invalid_keyword:
5585
PyErr_Format(PyExc_TypeError,
5586
#if PY_MAJOR_VERSION < 3
5587
"%.200s() got an unexpected keyword argument '%.200s'",
5588
function_name, PyString_AsString(key));
5589
#else
5590
"%s() got an unexpected keyword argument '%U'",
5591
function_name, key);
5592
#endif
5593
bad:
5594
return -1;
5595
}
5596
5597
/* PyObjectCall */
5598
#if CYTHON_COMPILING_IN_CPYTHON
5599
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
5600
PyObject *result;
5601
ternaryfunc call = func->ob_type->tp_call;
5602
if (unlikely(!call))
5603
return PyObject_Call(func, arg, kw);
5604
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
5605
return NULL;
5606
result = (*call)(func, arg, kw);
5607
Py_LeaveRecursiveCall();
5608
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
5609
PyErr_SetString(
5610
PyExc_SystemError,
5611
"NULL result without error in PyObject_Call");
5612
}
5613
return result;
5614
}
5615
#endif
5616
5617
/* PyCFunctionFastCall */
5618
#if CYTHON_FAST_PYCCALL
5619
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
5620
PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
5621
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
5622
PyObject *self = PyCFunction_GET_SELF(func);
5623
assert(PyCFunction_Check(func));
5624
assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)));
5625
assert(nargs >= 0);
5626
assert(nargs == 0 || args != NULL);
5627
/* _PyCFunction_FastCallDict() must not be called with an exception set,
5628
because it may clear it (directly or indirectly) and so the
5629
caller loses its exception */
5630
assert(!PyErr_Occurred());
5631
return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
5632
}
5633
#endif // CYTHON_FAST_PYCCALL
5634
5635
/* PyFunctionFastCall */
5636
#if CYTHON_FAST_PYCALL
5637
#include "frameobject.h"
5638
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
5639
PyObject *globals) {
5640
PyFrameObject *f;
5641
PyThreadState *tstate = PyThreadState_GET();
5642
PyObject **fastlocals;
5643
Py_ssize_t i;
5644
PyObject *result;
5645
assert(globals != NULL);
5646
/* XXX Perhaps we should create a specialized
5647
PyFrame_New() that doesn't take locals, but does
5648
take builtins without sanity checking them.
5649
*/
5650
assert(tstate != NULL);
5651
f = PyFrame_New(tstate, co, globals, NULL);
5652
if (f == NULL) {
5653
return NULL;
5654
}
5655
fastlocals = f->f_localsplus;
5656
for (i = 0; i < na; i++) {
5657
Py_INCREF(*args);
5658
fastlocals[i] = *args++;
5659
}
5660
result = PyEval_EvalFrameEx(f,0);
5661
++tstate->recursion_depth;
5662
Py_DECREF(f);
5663
--tstate->recursion_depth;
5664
return result;
5665
}
5666
#if 1 || PY_VERSION_HEX < 0x030600B1
5667
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
5668
PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
5669
PyObject *globals = PyFunction_GET_GLOBALS(func);
5670
PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
5671
PyObject *closure;
5672
#if PY_MAJOR_VERSION >= 3
5673
PyObject *kwdefs;
5674
#endif
5675
PyObject *kwtuple, **k;
5676
PyObject **d;
5677
Py_ssize_t nd;
5678
Py_ssize_t nk;
5679
PyObject *result;
5680
assert(kwargs == NULL || PyDict_Check(kwargs));
5681
nk = kwargs ? PyDict_Size(kwargs) : 0;
5682
if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
5683
return NULL;
5684
}
5685
if (
5686
#if PY_MAJOR_VERSION >= 3
5687
co->co_kwonlyargcount == 0 &&
5688
#endif
5689
likely(kwargs == NULL || nk == 0) &&
5690
co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
5691
if (argdefs == NULL && co->co_argcount == nargs) {
5692
result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
5693
goto done;
5694
}
5695
else if (nargs == 0 && argdefs != NULL
5696
&& co->co_argcount == Py_SIZE(argdefs)) {
5697
/* function called with no arguments, but all parameters have
5698
a default value: use default values as arguments .*/
5699
args = &PyTuple_GET_ITEM(argdefs, 0);
5700
result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
5701
goto done;
5702
}
5703
}
5704
if (kwargs != NULL) {
5705
Py_ssize_t pos, i;
5706
kwtuple = PyTuple_New(2 * nk);
5707
if (kwtuple == NULL) {
5708
result = NULL;
5709
goto done;
5710
}
5711
k = &PyTuple_GET_ITEM(kwtuple, 0);
5712
pos = i = 0;
5713
while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
5714
Py_INCREF(k[i]);
5715
Py_INCREF(k[i+1]);
5716
i += 2;
5717
}
5718
nk = i / 2;
5719
}
5720
else {
5721
kwtuple = NULL;
5722
k = NULL;
5723
}
5724
closure = PyFunction_GET_CLOSURE(func);
5725
#if PY_MAJOR_VERSION >= 3
5726
kwdefs = PyFunction_GET_KW_DEFAULTS(func);
5727
#endif
5728
if (argdefs != NULL) {
5729
d = &PyTuple_GET_ITEM(argdefs, 0);
5730
nd = Py_SIZE(argdefs);
5731
}
5732
else {
5733
d = NULL;
5734
nd = 0;
5735
}
5736
#if PY_MAJOR_VERSION >= 3
5737
result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
5738
args, nargs,
5739
k, (int)nk,
5740
d, (int)nd, kwdefs, closure);
5741
#else
5742
result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
5743
args, nargs,
5744
k, (int)nk,
5745
d, (int)nd, closure);
5746
#endif
5747
Py_XDECREF(kwtuple);
5748
done:
5749
Py_LeaveRecursiveCall();
5750
return result;
5751
}
5752
#endif // CPython < 3.6
5753
#endif // CYTHON_FAST_PYCALL
5754
5755
/* PyObjectCallMethO */
5756
#if CYTHON_COMPILING_IN_CPYTHON
5757
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
5758
PyObject *self, *result;
5759
PyCFunction cfunc;
5760
cfunc = PyCFunction_GET_FUNCTION(func);
5761
self = PyCFunction_GET_SELF(func);
5762
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
5763
return NULL;
5764
result = cfunc(self, arg);
5765
Py_LeaveRecursiveCall();
5766
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
5767
PyErr_SetString(
5768
PyExc_SystemError,
5769
"NULL result without error in PyObject_Call");
5770
}
5771
return result;
5772
}
5773
#endif
5774
5775
/* PyObjectCallOneArg */
5776
#if CYTHON_COMPILING_IN_CPYTHON
5777
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5778
PyObject *result;
5779
PyObject *args = PyTuple_New(1);
5780
if (unlikely(!args)) return NULL;
5781
Py_INCREF(arg);
5782
PyTuple_SET_ITEM(args, 0, arg);
5783
result = __Pyx_PyObject_Call(func, args, NULL);
5784
Py_DECREF(args);
5785
return result;
5786
}
5787
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5788
#if CYTHON_FAST_PYCALL
5789
if (PyFunction_Check(func)) {
5790
return __Pyx_PyFunction_FastCall(func, &arg, 1);
5791
}
5792
#endif
5793
#ifdef __Pyx_CyFunction_USED
5794
if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
5795
#else
5796
if (likely(PyCFunction_Check(func))) {
5797
#endif
5798
if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
5799
return __Pyx_PyObject_CallMethO(func, arg);
5800
#if CYTHON_FAST_PYCCALL
5801
} else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
5802
return __Pyx_PyCFunction_FastCall(func, &arg, 1);
5803
#endif
5804
}
5805
}
5806
return __Pyx__PyObject_CallOneArg(func, arg);
5807
}
5808
#else
5809
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5810
PyObject *result;
5811
PyObject *args = PyTuple_Pack(1, arg);
5812
if (unlikely(!args)) return NULL;
5813
result = __Pyx_PyObject_Call(func, args, NULL);
5814
Py_DECREF(args);
5815
return result;
5816
}
5817
#endif
5818
5819
/* PyObjectCallNoArg */
5820
#if CYTHON_COMPILING_IN_CPYTHON
5821
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
5822
#if CYTHON_FAST_PYCALL
5823
if (PyFunction_Check(func)) {
5824
return __Pyx_PyFunction_FastCall(func, NULL, 0);
5825
}
5826
#endif
5827
#ifdef __Pyx_CyFunction_USED
5828
if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
5829
#else
5830
if (likely(PyCFunction_Check(func))) {
5831
#endif
5832
if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
5833
return __Pyx_PyObject_CallMethO(func, NULL);
5834
}
5835
}
5836
return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
5837
}
5838
#endif
5839
5840
/* RaiseTooManyValuesToUnpack */
5841
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
5842
PyErr_Format(PyExc_ValueError,
5843
"too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
5844
}
5845
5846
/* RaiseNeedMoreValuesToUnpack */
5847
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
5848
PyErr_Format(PyExc_ValueError,
5849
"need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
5850
index, (index == 1) ? "" : "s");
5851
}
5852
5853
/* IterFinish */
5854
static CYTHON_INLINE int __Pyx_IterFinish(void) {
5855
#if CYTHON_FAST_THREAD_STATE
5856
PyThreadState *tstate = PyThreadState_GET();
5857
PyObject* exc_type = tstate->curexc_type;
5858
if (unlikely(exc_type)) {
5859
if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
5860
PyObject *exc_value, *exc_tb;
5861
exc_value = tstate->curexc_value;
5862
exc_tb = tstate->curexc_traceback;
5863
tstate->curexc_type = 0;
5864
tstate->curexc_value = 0;
5865
tstate->curexc_traceback = 0;
5866
Py_DECREF(exc_type);
5867
Py_XDECREF(exc_value);
5868
Py_XDECREF(exc_tb);
5869
return 0;
5870
} else {
5871
return -1;
5872
}
5873
}
5874
return 0;
5875
#else
5876
if (unlikely(PyErr_Occurred())) {
5877
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
5878
PyErr_Clear();
5879
return 0;
5880
} else {
5881
return -1;
5882
}
5883
}
5884
return 0;
5885
#endif
5886
}
5887
5888
/* UnpackItemEndCheck */
5889
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
5890
if (unlikely(retval)) {
5891
Py_DECREF(retval);
5892
__Pyx_RaiseTooManyValuesError(expected);
5893
return -1;
5894
} else {
5895
return __Pyx_IterFinish();
5896
}
5897
return 0;
5898
}
5899
5900
/* GetModuleGlobalName */
5901
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
5902
PyObject *result;
5903
#if !CYTHON_AVOID_BORROWED_REFS
5904
result = PyDict_GetItem(__pyx_d, name);
5905
if (likely(result)) {
5906
Py_INCREF(result);
5907
} else {
5908
#else
5909
result = PyObject_GetItem(__pyx_d, name);
5910
if (!result) {
5911
PyErr_Clear();
5912
#endif
5913
result = __Pyx_GetBuiltinName(name);
5914
}
5915
return result;
5916
}
5917
5918
/* PyObjectCallMethod0 */
5919
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
5920
PyObject *method, *result = NULL;
5921
method = __Pyx_PyObject_GetAttrStr(obj, method_name);
5922
if (unlikely(!method)) goto bad;
5923
#if CYTHON_UNPACK_METHODS
5924
if (likely(PyMethod_Check(method))) {
5925
PyObject *self = PyMethod_GET_SELF(method);
5926
if (likely(self)) {
5927
PyObject *function = PyMethod_GET_FUNCTION(method);
5928
result = __Pyx_PyObject_CallOneArg(function, self);
5929
Py_DECREF(method);
5930
return result;
5931
}
5932
}
5933
#endif
5934
result = __Pyx_PyObject_CallNoArg(method);
5935
Py_DECREF(method);
5936
bad:
5937
return result;
5938
}
5939
5940
/* RaiseNoneIterError */
5941
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
5942
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
5943
}
5944
5945
/* UnpackTupleError */
5946
static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
5947
if (t == Py_None) {
5948
__Pyx_RaiseNoneNotIterableError();
5949
} else if (PyTuple_GET_SIZE(t) < index) {
5950
__Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
5951
} else {
5952
__Pyx_RaiseTooManyValuesError(index);
5953
}
5954
}
5955
5956
/* UnpackTuple2 */
5957
static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
5958
int is_tuple, int has_known_size, int decref_tuple) {
5959
Py_ssize_t index;
5960
PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
5961
if (!is_tuple && unlikely(!PyTuple_Check(tuple))) {
5962
iternextfunc iternext;
5963
iter = PyObject_GetIter(tuple);
5964
if (unlikely(!iter)) goto bad;
5965
if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
5966
iternext = Py_TYPE(iter)->tp_iternext;
5967
value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
5968
value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
5969
if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
5970
Py_DECREF(iter);
5971
} else {
5972
if (!has_known_size && unlikely(PyTuple_GET_SIZE(tuple) != 2)) {
5973
__Pyx_UnpackTupleError(tuple, 2);
5974
goto bad;
5975
}
5976
#if CYTHON_COMPILING_IN_PYPY
5977
value1 = PySequence_ITEM(tuple, 0);
5978
if (unlikely(!value1)) goto bad;
5979
value2 = PySequence_ITEM(tuple, 1);
5980
if (unlikely(!value2)) goto bad;
5981
#else
5982
value1 = PyTuple_GET_ITEM(tuple, 0);
5983
value2 = PyTuple_GET_ITEM(tuple, 1);
5984
Py_INCREF(value1);
5985
Py_INCREF(value2);
5986
#endif
5987
if (decref_tuple) { Py_DECREF(tuple); }
5988
}
5989
*pvalue1 = value1;
5990
*pvalue2 = value2;
5991
return 0;
5992
unpacking_failed:
5993
if (!has_known_size && __Pyx_IterFinish() == 0)
5994
__Pyx_RaiseNeedMoreValuesError(index);
5995
bad:
5996
Py_XDECREF(iter);
5997
Py_XDECREF(value1);
5998
Py_XDECREF(value2);
5999
if (decref_tuple) { Py_XDECREF(tuple); }
6000
return -1;
6001
}
6002
6003
/* dict_iter */
6004
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
6005
Py_ssize_t* p_orig_length, int* p_source_is_dict) {
6006
is_dict = is_dict || likely(PyDict_CheckExact(iterable));
6007
*p_source_is_dict = is_dict;
6008
#if !CYTHON_COMPILING_IN_PYPY
6009
if (is_dict) {
6010
*p_orig_length = PyDict_Size(iterable);
6011
Py_INCREF(iterable);
6012
return iterable;
6013
}
6014
#endif
6015
*p_orig_length = 0;
6016
if (method_name) {
6017
PyObject* iter;
6018
iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
6019
if (!iterable)
6020
return NULL;
6021
#if !CYTHON_COMPILING_IN_PYPY
6022
if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
6023
return iterable;
6024
#endif
6025
iter = PyObject_GetIter(iterable);
6026
Py_DECREF(iterable);
6027
return iter;
6028
}
6029
return PyObject_GetIter(iterable);
6030
}
6031
static CYTHON_INLINE int __Pyx_dict_iter_next(
6032
PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
6033
PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
6034
PyObject* next_item;
6035
#if !CYTHON_COMPILING_IN_PYPY
6036
if (source_is_dict) {
6037
PyObject *key, *value;
6038
if (unlikely(orig_length != PyDict_Size(iter_obj))) {
6039
PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
6040
return -1;
6041
}
6042
if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
6043
return 0;
6044
}
6045
if (pitem) {
6046
PyObject* tuple = PyTuple_New(2);
6047
if (unlikely(!tuple)) {
6048
return -1;
6049
}
6050
Py_INCREF(key);
6051
Py_INCREF(value);
6052
PyTuple_SET_ITEM(tuple, 0, key);
6053
PyTuple_SET_ITEM(tuple, 1, value);
6054
*pitem = tuple;
6055
} else {
6056
if (pkey) {
6057
Py_INCREF(key);
6058
*pkey = key;
6059
}
6060
if (pvalue) {
6061
Py_INCREF(value);
6062
*pvalue = value;
6063
}
6064
}
6065
return 1;
6066
} else if (PyTuple_CheckExact(iter_obj)) {
6067
Py_ssize_t pos = *ppos;
6068
if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
6069
*ppos = pos + 1;
6070
next_item = PyTuple_GET_ITEM(iter_obj, pos);
6071
Py_INCREF(next_item);
6072
} else if (PyList_CheckExact(iter_obj)) {
6073
Py_ssize_t pos = *ppos;
6074
if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
6075
*ppos = pos + 1;
6076
next_item = PyList_GET_ITEM(iter_obj, pos);
6077
Py_INCREF(next_item);
6078
} else
6079
#endif
6080
{
6081
next_item = PyIter_Next(iter_obj);
6082
if (unlikely(!next_item)) {
6083
return __Pyx_IterFinish();
6084
}
6085
}
6086
if (pitem) {
6087
*pitem = next_item;
6088
} else if (pkey && pvalue) {
6089
if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
6090
return -1;
6091
} else if (pkey) {
6092
*pkey = next_item;
6093
} else {
6094
*pvalue = next_item;
6095
}
6096
return 1;
6097
}
6098
6099
/* None */
6100
static CYTHON_INLINE Py_ssize_t __Pyx_mod_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
6101
Py_ssize_t r = a % b;
6102
r += ((r != 0) & ((r ^ b) < 0)) * b;
6103
return r;
6104
}
6105
6106
/* None */
6107
static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
6108
Py_ssize_t q = a / b;
6109
Py_ssize_t r = a - q*b;
6110
q -= ((r != 0) & ((r ^ b) < 0));
6111
return q;
6112
}
6113
6114
/* GetItemInt */
6115
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
6116
PyObject *r;
6117
if (!j) return NULL;
6118
r = PyObject_GetItem(o, j);
6119
Py_DECREF(j);
6120
return r;
6121
}
6122
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
6123
CYTHON_NCP_UNUSED int wraparound,
6124
CYTHON_NCP_UNUSED int boundscheck) {
6125
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6126
if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
6127
if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
6128
PyObject *r = PyList_GET_ITEM(o, i);
6129
Py_INCREF(r);
6130
return r;
6131
}
6132
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
6133
#else
6134
return PySequence_GetItem(o, i);
6135
#endif
6136
}
6137
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
6138
CYTHON_NCP_UNUSED int wraparound,
6139
CYTHON_NCP_UNUSED int boundscheck) {
6140
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6141
if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
6142
if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
6143
PyObject *r = PyTuple_GET_ITEM(o, i);
6144
Py_INCREF(r);
6145
return r;
6146
}
6147
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
6148
#else
6149
return PySequence_GetItem(o, i);
6150
#endif
6151
}
6152
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
6153
CYTHON_NCP_UNUSED int wraparound,
6154
CYTHON_NCP_UNUSED int boundscheck) {
6155
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
6156
if (is_list || PyList_CheckExact(o)) {
6157
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
6158
if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
6159
PyObject *r = PyList_GET_ITEM(o, n);
6160
Py_INCREF(r);
6161
return r;
6162
}
6163
}
6164
else if (PyTuple_CheckExact(o)) {
6165
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
6166
if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
6167
PyObject *r = PyTuple_GET_ITEM(o, n);
6168
Py_INCREF(r);
6169
return r;
6170
}
6171
} else {
6172
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
6173
if (likely(m && m->sq_item)) {
6174
if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
6175
Py_ssize_t l = m->sq_length(o);
6176
if (likely(l >= 0)) {
6177
i += l;
6178
} else {
6179
if (!PyErr_ExceptionMatches(PyExc_OverflowError))
6180
return NULL;
6181
PyErr_Clear();
6182
}
6183
}
6184
return m->sq_item(o, i);
6185
}
6186
}
6187
#else
6188
if (is_list || PySequence_Check(o)) {
6189
return PySequence_GetItem(o, i);
6190
}
6191
#endif
6192
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
6193
}
6194
6195
/* SetItemInt */
6196
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
6197
int r;
6198
if (!j) return -1;
6199
r = PyObject_SetItem(o, j, v);
6200
Py_DECREF(j);
6201
return r;
6202
}
6203
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
6204
CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
6205
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
6206
if (is_list || PyList_CheckExact(o)) {
6207
Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
6208
if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
6209
PyObject* old = PyList_GET_ITEM(o, n);
6210
Py_INCREF(v);
6211
PyList_SET_ITEM(o, n, v);
6212
Py_DECREF(old);
6213
return 1;
6214
}
6215
} else {
6216
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
6217
if (likely(m && m->sq_ass_item)) {
6218
if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
6219
Py_ssize_t l = m->sq_length(o);
6220
if (likely(l >= 0)) {
6221
i += l;
6222
} else {
6223
if (!PyErr_ExceptionMatches(PyExc_OverflowError))
6224
return -1;
6225
PyErr_Clear();
6226
}
6227
}
6228
return m->sq_ass_item(o, i, v);
6229
}
6230
}
6231
#else
6232
#if CYTHON_COMPILING_IN_PYPY
6233
if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
6234
#else
6235
if (is_list || PySequence_Check(o)) {
6236
#endif
6237
return PySequence_SetItem(o, i, v);
6238
}
6239
#endif
6240
return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
6241
}
6242
6243
/* PyErrFetchRestore */
6244
#if CYTHON_FAST_THREAD_STATE
6245
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
6246
PyObject *tmp_type, *tmp_value, *tmp_tb;
6247
tmp_type = tstate->curexc_type;
6248
tmp_value = tstate->curexc_value;
6249
tmp_tb = tstate->curexc_traceback;
6250
tstate->curexc_type = type;
6251
tstate->curexc_value = value;
6252
tstate->curexc_traceback = tb;
6253
Py_XDECREF(tmp_type);
6254
Py_XDECREF(tmp_value);
6255
Py_XDECREF(tmp_tb);
6256
}
6257
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
6258
*type = tstate->curexc_type;
6259
*value = tstate->curexc_value;
6260
*tb = tstate->curexc_traceback;
6261
tstate->curexc_type = 0;
6262
tstate->curexc_value = 0;
6263
tstate->curexc_traceback = 0;
6264
}
6265
#endif
6266
6267
/* RaiseException */
6268
#if PY_MAJOR_VERSION < 3
6269
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
6270
CYTHON_UNUSED PyObject *cause) {
6271
__Pyx_PyThreadState_declare
6272
Py_XINCREF(type);
6273
if (!value || value == Py_None)
6274
value = NULL;
6275
else
6276
Py_INCREF(value);
6277
if (!tb || tb == Py_None)
6278
tb = NULL;
6279
else {
6280
Py_INCREF(tb);
6281
if (!PyTraceBack_Check(tb)) {
6282
PyErr_SetString(PyExc_TypeError,
6283
"raise: arg 3 must be a traceback or None");
6284
goto raise_error;
6285
}
6286
}
6287
if (PyType_Check(type)) {
6288
#if CYTHON_COMPILING_IN_PYPY
6289
if (!value) {
6290
Py_INCREF(Py_None);
6291
value = Py_None;
6292
}
6293
#endif
6294
PyErr_NormalizeException(&type, &value, &tb);
6295
} else {
6296
if (value) {
6297
PyErr_SetString(PyExc_TypeError,
6298
"instance exception may not have a separate value");
6299
goto raise_error;
6300
}
6301
value = type;
6302
type = (PyObject*) Py_TYPE(type);
6303
Py_INCREF(type);
6304
if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
6305
PyErr_SetString(PyExc_TypeError,
6306
"raise: exception class must be a subclass of BaseException");
6307
goto raise_error;
6308
}
6309
}
6310
__Pyx_PyThreadState_assign
6311
__Pyx_ErrRestore(type, value, tb);
6312
return;
6313
raise_error:
6314
Py_XDECREF(value);
6315
Py_XDECREF(type);
6316
Py_XDECREF(tb);
6317
return;
6318
}
6319
#else
6320
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
6321
PyObject* owned_instance = NULL;
6322
if (tb == Py_None) {
6323
tb = 0;
6324
} else if (tb && !PyTraceBack_Check(tb)) {
6325
PyErr_SetString(PyExc_TypeError,
6326
"raise: arg 3 must be a traceback or None");
6327
goto bad;
6328
}
6329
if (value == Py_None)
6330
value = 0;
6331
if (PyExceptionInstance_Check(type)) {
6332
if (value) {
6333
PyErr_SetString(PyExc_TypeError,
6334
"instance exception may not have a separate value");
6335
goto bad;
6336
}
6337
value = type;
6338
type = (PyObject*) Py_TYPE(value);
6339
} else if (PyExceptionClass_Check(type)) {
6340
PyObject *instance_class = NULL;
6341
if (value && PyExceptionInstance_Check(value)) {
6342
instance_class = (PyObject*) Py_TYPE(value);
6343
if (instance_class != type) {
6344
int is_subclass = PyObject_IsSubclass(instance_class, type);
6345
if (!is_subclass) {
6346
instance_class = NULL;
6347
} else if (unlikely(is_subclass == -1)) {
6348
goto bad;
6349
} else {
6350
type = instance_class;
6351
}
6352
}
6353
}
6354
if (!instance_class) {
6355
PyObject *args;
6356
if (!value)
6357
args = PyTuple_New(0);
6358
else if (PyTuple_Check(value)) {
6359
Py_INCREF(value);
6360
args = value;
6361
} else
6362
args = PyTuple_Pack(1, value);
6363
if (!args)
6364
goto bad;
6365
owned_instance = PyObject_Call(type, args, NULL);
6366
Py_DECREF(args);
6367
if (!owned_instance)
6368
goto bad;
6369
value = owned_instance;
6370
if (!PyExceptionInstance_Check(value)) {
6371
PyErr_Format(PyExc_TypeError,
6372
"calling %R should have returned an instance of "
6373
"BaseException, not %R",
6374
type, Py_TYPE(value));
6375
goto bad;
6376
}
6377
}
6378
} else {
6379
PyErr_SetString(PyExc_TypeError,
6380
"raise: exception class must be a subclass of BaseException");
6381
goto bad;
6382
}
6383
#if PY_VERSION_HEX >= 0x03030000
6384
if (cause) {
6385
#else
6386
if (cause && cause != Py_None) {
6387
#endif
6388
PyObject *fixed_cause;
6389
if (cause == Py_None) {
6390
fixed_cause = NULL;
6391
} else if (PyExceptionClass_Check(cause)) {
6392
fixed_cause = PyObject_CallObject(cause, NULL);
6393
if (fixed_cause == NULL)
6394
goto bad;
6395
} else if (PyExceptionInstance_Check(cause)) {
6396
fixed_cause = cause;
6397
Py_INCREF(fixed_cause);
6398
} else {
6399
PyErr_SetString(PyExc_TypeError,
6400
"exception causes must derive from "
6401
"BaseException");
6402
goto bad;
6403
}
6404
PyException_SetCause(value, fixed_cause);
6405
}
6406
PyErr_SetObject(type, value);
6407
if (tb) {
6408
#if CYTHON_COMPILING_IN_PYPY
6409
PyObject *tmp_type, *tmp_value, *tmp_tb;
6410
PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
6411
Py_INCREF(tb);
6412
PyErr_Restore(tmp_type, tmp_value, tb);
6413
Py_XDECREF(tmp_tb);
6414
#else
6415
PyThreadState *tstate = PyThreadState_GET();
6416
PyObject* tmp_tb = tstate->curexc_traceback;
6417
if (tb != tmp_tb) {
6418
Py_INCREF(tb);
6419
tstate->curexc_traceback = tb;
6420
Py_XDECREF(tmp_tb);
6421
}
6422
#endif
6423
}
6424
bad:
6425
Py_XDECREF(owned_instance);
6426
return;
6427
}
6428
#endif
6429
6430
/* None */
6431
static CYTHON_INLINE long __Pyx_mod_long(long a, long b) {
6432
long r = a % b;
6433
r += ((r != 0) & ((r ^ b) < 0)) * b;
6434
return r;
6435
}
6436
6437
/* GetVTable */
6438
static void* __Pyx_GetVtable(PyObject *dict) {
6439
void* ptr;
6440
PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
6441
if (!ob)
6442
goto bad;
6443
#if PY_VERSION_HEX >= 0x02070000
6444
ptr = PyCapsule_GetPointer(ob, 0);
6445
#else
6446
ptr = PyCObject_AsVoidPtr(ob);
6447
#endif
6448
if (!ptr && !PyErr_Occurred())
6449
PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
6450
Py_DECREF(ob);
6451
return ptr;
6452
bad:
6453
Py_XDECREF(ob);
6454
return NULL;
6455
}
6456
6457
/* Import */
6458
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
6459
PyObject *empty_list = 0;
6460
PyObject *module = 0;
6461
PyObject *global_dict = 0;
6462
PyObject *empty_dict = 0;
6463
PyObject *list;
6464
#if PY_VERSION_HEX < 0x03030000
6465
PyObject *py_import;
6466
py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
6467
if (!py_import)
6468
goto bad;
6469
#endif
6470
if (from_list)
6471
list = from_list;
6472
else {
6473
empty_list = PyList_New(0);
6474
if (!empty_list)
6475
goto bad;
6476
list = empty_list;
6477
}
6478
global_dict = PyModule_GetDict(__pyx_m);
6479
if (!global_dict)
6480
goto bad;
6481
empty_dict = PyDict_New();
6482
if (!empty_dict)
6483
goto bad;
6484
{
6485
#if PY_MAJOR_VERSION >= 3
6486
if (level == -1) {
6487
if (strchr(__Pyx_MODULE_NAME, '.')) {
6488
#if PY_VERSION_HEX < 0x03030000
6489
PyObject *py_level = PyInt_FromLong(1);
6490
if (!py_level)
6491
goto bad;
6492
module = PyObject_CallFunctionObjArgs(py_import,
6493
name, global_dict, empty_dict, list, py_level, NULL);
6494
Py_DECREF(py_level);
6495
#else
6496
module = PyImport_ImportModuleLevelObject(
6497
name, global_dict, empty_dict, list, 1);
6498
#endif
6499
if (!module) {
6500
if (!PyErr_ExceptionMatches(PyExc_ImportError))
6501
goto bad;
6502
PyErr_Clear();
6503
}
6504
}
6505
level = 0;
6506
}
6507
#endif
6508
if (!module) {
6509
#if PY_VERSION_HEX < 0x03030000
6510
PyObject *py_level = PyInt_FromLong(level);
6511
if (!py_level)
6512
goto bad;
6513
module = PyObject_CallFunctionObjArgs(py_import,
6514
name, global_dict, empty_dict, list, py_level, NULL);
6515
Py_DECREF(py_level);
6516
#else
6517
module = PyImport_ImportModuleLevelObject(
6518
name, global_dict, empty_dict, list, level);
6519
#endif
6520
}
6521
}
6522
bad:
6523
#if PY_VERSION_HEX < 0x03030000
6524
Py_XDECREF(py_import);
6525
#endif
6526
Py_XDECREF(empty_list);
6527
Py_XDECREF(empty_dict);
6528
return module;
6529
}
6530
6531
/* ImportFrom */
6532
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
6533
PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
6534
if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
6535
PyErr_Format(PyExc_ImportError,
6536
#if PY_MAJOR_VERSION < 3
6537
"cannot import name %.230s", PyString_AS_STRING(name));
6538
#else
6539
"cannot import name %S", name);
6540
#endif
6541
}
6542
return value;
6543
}
6544
6545
/* CodeObjectCache */
6546
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
6547
int start = 0, mid = 0, end = count - 1;
6548
if (end >= 0 && code_line > entries[end].code_line) {
6549
return count;
6550
}
6551
while (start < end) {
6552
mid = start + (end - start) / 2;
6553
if (code_line < entries[mid].code_line) {
6554
end = mid;
6555
} else if (code_line > entries[mid].code_line) {
6556
start = mid + 1;
6557
} else {
6558
return mid;
6559
}
6560
}
6561
if (code_line <= entries[mid].code_line) {
6562
return mid;
6563
} else {
6564
return mid + 1;
6565
}
6566
}
6567
static PyCodeObject *__pyx_find_code_object(int code_line) {
6568
PyCodeObject* code_object;
6569
int pos;
6570
if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
6571
return NULL;
6572
}
6573
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
6574
if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
6575
return NULL;
6576
}
6577
code_object = __pyx_code_cache.entries[pos].code_object;
6578
Py_INCREF(code_object);
6579
return code_object;
6580
}
6581
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
6582
int pos, i;
6583
__Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
6584
if (unlikely(!code_line)) {
6585
return;
6586
}
6587
if (unlikely(!entries)) {
6588
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
6589
if (likely(entries)) {
6590
__pyx_code_cache.entries = entries;
6591
__pyx_code_cache.max_count = 64;
6592
__pyx_code_cache.count = 1;
6593
entries[0].code_line = code_line;
6594
entries[0].code_object = code_object;
6595
Py_INCREF(code_object);
6596
}
6597
return;
6598
}
6599
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
6600
if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
6601
PyCodeObject* tmp = entries[pos].code_object;
6602
entries[pos].code_object = code_object;
6603
Py_DECREF(tmp);
6604
return;
6605
}
6606
if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
6607
int new_max = __pyx_code_cache.max_count + 64;
6608
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
6609
__pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
6610
if (unlikely(!entries)) {
6611
return;
6612
}
6613
__pyx_code_cache.entries = entries;
6614
__pyx_code_cache.max_count = new_max;
6615
}
6616
for (i=__pyx_code_cache.count; i>pos; i--) {
6617
entries[i] = entries[i-1];
6618
}
6619
entries[pos].code_line = code_line;
6620
entries[pos].code_object = code_object;
6621
__pyx_code_cache.count++;
6622
Py_INCREF(code_object);
6623
}
6624
6625
/* AddTraceback */
6626
#include "compile.h"
6627
#include "frameobject.h"
6628
#include "traceback.h"
6629
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
6630
const char *funcname, int c_line,
6631
int py_line, const char *filename) {
6632
PyCodeObject *py_code = 0;
6633
PyObject *py_srcfile = 0;
6634
PyObject *py_funcname = 0;
6635
#if PY_MAJOR_VERSION < 3
6636
py_srcfile = PyString_FromString(filename);
6637
#else
6638
py_srcfile = PyUnicode_FromString(filename);
6639
#endif
6640
if (!py_srcfile) goto bad;
6641
if (c_line) {
6642
#if PY_MAJOR_VERSION < 3
6643
py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
6644
#else
6645
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
6646
#endif
6647
}
6648
else {
6649
#if PY_MAJOR_VERSION < 3
6650
py_funcname = PyString_FromString(funcname);
6651
#else
6652
py_funcname = PyUnicode_FromString(funcname);
6653
#endif
6654
}
6655
if (!py_funcname) goto bad;
6656
py_code = __Pyx_PyCode_New(
6657
0,
6658
0,
6659
0,
6660
0,
6661
0,
6662
__pyx_empty_bytes, /*PyObject *code,*/
6663
__pyx_empty_tuple, /*PyObject *consts,*/
6664
__pyx_empty_tuple, /*PyObject *names,*/
6665
__pyx_empty_tuple, /*PyObject *varnames,*/
6666
__pyx_empty_tuple, /*PyObject *freevars,*/
6667
__pyx_empty_tuple, /*PyObject *cellvars,*/
6668
py_srcfile, /*PyObject *filename,*/
6669
py_funcname, /*PyObject *name,*/
6670
py_line,
6671
__pyx_empty_bytes /*PyObject *lnotab*/
6672
);
6673
Py_DECREF(py_srcfile);
6674
Py_DECREF(py_funcname);
6675
return py_code;
6676
bad:
6677
Py_XDECREF(py_srcfile);
6678
Py_XDECREF(py_funcname);
6679
return NULL;
6680
}
6681
static void __Pyx_AddTraceback(const char *funcname, int c_line,
6682
int py_line, const char *filename) {
6683
PyCodeObject *py_code = 0;
6684
PyFrameObject *py_frame = 0;
6685
py_code = __pyx_find_code_object(c_line ? c_line : py_line);
6686
if (!py_code) {
6687
py_code = __Pyx_CreateCodeObjectForTraceback(
6688
funcname, c_line, py_line, filename);
6689
if (!py_code) goto bad;
6690
__pyx_insert_code_object(c_line ? c_line : py_line, py_code);
6691
}
6692
py_frame = PyFrame_New(
6693
PyThreadState_GET(), /*PyThreadState *tstate,*/
6694
py_code, /*PyCodeObject *code,*/
6695
__pyx_d, /*PyObject *globals,*/
6696
0 /*PyObject *locals*/
6697
);
6698
if (!py_frame) goto bad;
6699
__Pyx_PyFrame_SetLineNumber(py_frame, py_line);
6700
PyTraceBack_Here(py_frame);
6701
bad:
6702
Py_XDECREF(py_code);
6703
Py_XDECREF(py_frame);
6704
}
6705
6706
/* CIntFromPyVerify */
6707
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
6708
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
6709
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
6710
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
6711
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
6712
{\
6713
func_type value = func_value;\
6714
if (sizeof(target_type) < sizeof(func_type)) {\
6715
if (unlikely(value != (func_type) (target_type) value)) {\
6716
func_type zero = 0;\
6717
if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
6718
return (target_type) -1;\
6719
if (is_unsigned && unlikely(value < zero))\
6720
goto raise_neg_overflow;\
6721
else\
6722
goto raise_overflow;\
6723
}\
6724
}\
6725
return (target_type) value;\
6726
}
6727
6728
/* CIntToPy */
6729
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
6730
const long neg_one = (long) -1, const_zero = (long) 0;
6731
const int is_unsigned = neg_one > const_zero;
6732
if (is_unsigned) {
6733
if (sizeof(long) < sizeof(long)) {
6734
return PyInt_FromLong((long) value);
6735
} else if (sizeof(long) <= sizeof(unsigned long)) {
6736
return PyLong_FromUnsignedLong((unsigned long) value);
6737
#ifdef HAVE_LONG_LONG
6738
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
6739
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
6740
#endif
6741
}
6742
} else {
6743
if (sizeof(long) <= sizeof(long)) {
6744
return PyInt_FromLong((long) value);
6745
#ifdef HAVE_LONG_LONG
6746
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
6747
return PyLong_FromLongLong((PY_LONG_LONG) value);
6748
#endif
6749
}
6750
}
6751
{
6752
int one = 1; int little = (int)*(unsigned char *)&one;
6753
unsigned char *bytes = (unsigned char *)&value;
6754
return _PyLong_FromByteArray(bytes, sizeof(long),
6755
little, !is_unsigned);
6756
}
6757
}
6758
6759
/* CIntToPy */
6760
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
6761
const int neg_one = (int) -1, const_zero = (int) 0;
6762
const int is_unsigned = neg_one > const_zero;
6763
if (is_unsigned) {
6764
if (sizeof(int) < sizeof(long)) {
6765
return PyInt_FromLong((long) value);
6766
} else if (sizeof(int) <= sizeof(unsigned long)) {
6767
return PyLong_FromUnsignedLong((unsigned long) value);
6768
#ifdef HAVE_LONG_LONG
6769
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
6770
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
6771
#endif
6772
}
6773
} else {
6774
if (sizeof(int) <= sizeof(long)) {
6775
return PyInt_FromLong((long) value);
6776
#ifdef HAVE_LONG_LONG
6777
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
6778
return PyLong_FromLongLong((PY_LONG_LONG) value);
6779
#endif
6780
}
6781
}
6782
{
6783
int one = 1; int little = (int)*(unsigned char *)&one;
6784
unsigned char *bytes = (unsigned char *)&value;
6785
return _PyLong_FromByteArray(bytes, sizeof(int),
6786
little, !is_unsigned);
6787
}
6788
}
6789
6790
/* CIntFromPy */
6791
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
6792
const long neg_one = (long) -1, const_zero = (long) 0;
6793
const int is_unsigned = neg_one > const_zero;
6794
#if PY_MAJOR_VERSION < 3
6795
if (likely(PyInt_Check(x))) {
6796
if (sizeof(long) < sizeof(long)) {
6797
__PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
6798
} else {
6799
long val = PyInt_AS_LONG(x);
6800
if (is_unsigned && unlikely(val < 0)) {
6801
goto raise_neg_overflow;
6802
}
6803
return (long) val;
6804
}
6805
} else
6806
#endif
6807
if (likely(PyLong_Check(x))) {
6808
if (is_unsigned) {
6809
#if CYTHON_USE_PYLONG_INTERNALS
6810
const digit* digits = ((PyLongObject*)x)->ob_digit;
6811
switch (Py_SIZE(x)) {
6812
case 0: return (long) 0;
6813
case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
6814
case 2:
6815
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
6816
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6817
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6818
} else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
6819
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
6820
}
6821
}
6822
break;
6823
case 3:
6824
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
6825
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6826
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6827
} else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
6828
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
6829
}
6830
}
6831
break;
6832
case 4:
6833
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
6834
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6835
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6836
} else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
6837
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
6838
}
6839
}
6840
break;
6841
}
6842
#endif
6843
#if CYTHON_COMPILING_IN_CPYTHON
6844
if (unlikely(Py_SIZE(x) < 0)) {
6845
goto raise_neg_overflow;
6846
}
6847
#else
6848
{
6849
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
6850
if (unlikely(result < 0))
6851
return (long) -1;
6852
if (unlikely(result == 1))
6853
goto raise_neg_overflow;
6854
}
6855
#endif
6856
if (sizeof(long) <= sizeof(unsigned long)) {
6857
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
6858
#ifdef HAVE_LONG_LONG
6859
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
6860
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
6861
#endif
6862
}
6863
} else {
6864
#if CYTHON_USE_PYLONG_INTERNALS
6865
const digit* digits = ((PyLongObject*)x)->ob_digit;
6866
switch (Py_SIZE(x)) {
6867
case 0: return (long) 0;
6868
case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
6869
case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
6870
case -2:
6871
if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
6872
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6873
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6874
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6875
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6876
}
6877
}
6878
break;
6879
case 2:
6880
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
6881
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6882
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6883
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6884
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6885
}
6886
}
6887
break;
6888
case -3:
6889
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6890
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6891
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6892
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6893
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6894
}
6895
}
6896
break;
6897
case 3:
6898
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
6899
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6900
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6901
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6902
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6903
}
6904
}
6905
break;
6906
case -4:
6907
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6908
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6909
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6910
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
6911
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6912
}
6913
}
6914
break;
6915
case 4:
6916
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
6917
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6918
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6919
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
6920
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6921
}
6922
}
6923
break;
6924
}
6925
#endif
6926
if (sizeof(long) <= sizeof(long)) {
6927
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
6928
#ifdef HAVE_LONG_LONG
6929
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
6930
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
6931
#endif
6932
}
6933
}
6934
{
6935
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
6936
PyErr_SetString(PyExc_RuntimeError,
6937
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
6938
#else
6939
long val;
6940
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
6941
#if PY_MAJOR_VERSION < 3
6942
if (likely(v) && !PyLong_Check(v)) {
6943
PyObject *tmp = v;
6944
v = PyNumber_Long(tmp);
6945
Py_DECREF(tmp);
6946
}
6947
#endif
6948
if (likely(v)) {
6949
int one = 1; int is_little = (int)*(unsigned char *)&one;
6950
unsigned char *bytes = (unsigned char *)&val;
6951
int ret = _PyLong_AsByteArray((PyLongObject *)v,
6952
bytes, sizeof(val),
6953
is_little, !is_unsigned);
6954
Py_DECREF(v);
6955
if (likely(!ret))
6956
return val;
6957
}
6958
#endif
6959
return (long) -1;
6960
}
6961
} else {
6962
long val;
6963
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
6964
if (!tmp) return (long) -1;
6965
val = __Pyx_PyInt_As_long(tmp);
6966
Py_DECREF(tmp);
6967
return val;
6968
}
6969
raise_overflow:
6970
PyErr_SetString(PyExc_OverflowError,
6971
"value too large to convert to long");
6972
return (long) -1;
6973
raise_neg_overflow:
6974
PyErr_SetString(PyExc_OverflowError,
6975
"can't convert negative value to long");
6976
return (long) -1;
6977
}
6978
6979
/* CIntFromPy */
6980
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
6981
const int neg_one = (int) -1, const_zero = (int) 0;
6982
const int is_unsigned = neg_one > const_zero;
6983
#if PY_MAJOR_VERSION < 3
6984
if (likely(PyInt_Check(x))) {
6985
if (sizeof(int) < sizeof(long)) {
6986
__PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
6987
} else {
6988
long val = PyInt_AS_LONG(x);
6989
if (is_unsigned && unlikely(val < 0)) {
6990
goto raise_neg_overflow;
6991
}
6992
return (int) val;
6993
}
6994
} else
6995
#endif
6996
if (likely(PyLong_Check(x))) {
6997
if (is_unsigned) {
6998
#if CYTHON_USE_PYLONG_INTERNALS
6999
const digit* digits = ((PyLongObject*)x)->ob_digit;
7000
switch (Py_SIZE(x)) {
7001
case 0: return (int) 0;
7002
case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
7003
case 2:
7004
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
7005
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7006
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7007
} else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
7008
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7009
}
7010
}
7011
break;
7012
case 3:
7013
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
7014
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7015
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7016
} else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
7017
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7018
}
7019
}
7020
break;
7021
case 4:
7022
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
7023
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7024
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7025
} else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
7026
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7027
}
7028
}
7029
break;
7030
}
7031
#endif
7032
#if CYTHON_COMPILING_IN_CPYTHON
7033
if (unlikely(Py_SIZE(x) < 0)) {
7034
goto raise_neg_overflow;
7035
}
7036
#else
7037
{
7038
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
7039
if (unlikely(result < 0))
7040
return (int) -1;
7041
if (unlikely(result == 1))
7042
goto raise_neg_overflow;
7043
}
7044
#endif
7045
if (sizeof(int) <= sizeof(unsigned long)) {
7046
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
7047
#ifdef HAVE_LONG_LONG
7048
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
7049
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
7050
#endif
7051
}
7052
} else {
7053
#if CYTHON_USE_PYLONG_INTERNALS
7054
const digit* digits = ((PyLongObject*)x)->ob_digit;
7055
switch (Py_SIZE(x)) {
7056
case 0: return (int) 0;
7057
case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
7058
case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
7059
case -2:
7060
if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
7061
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7062
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7063
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7064
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7065
}
7066
}
7067
break;
7068
case 2:
7069
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
7070
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7071
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7072
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7073
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7074
}
7075
}
7076
break;
7077
case -3:
7078
if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7079
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7080
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7081
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7082
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7083
}
7084
}
7085
break;
7086
case 3:
7087
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
7088
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7089
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7090
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7091
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7092
}
7093
}
7094
break;
7095
case -4:
7096
if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7097
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7098
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7099
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
7100
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7101
}
7102
}
7103
break;
7104
case 4:
7105
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
7106
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7107
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7108
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
7109
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7110
}
7111
}
7112
break;
7113
}
7114
#endif
7115
if (sizeof(int) <= sizeof(long)) {
7116
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
7117
#ifdef HAVE_LONG_LONG
7118
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
7119
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
7120
#endif
7121
}
7122
}
7123
{
7124
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
7125
PyErr_SetString(PyExc_RuntimeError,
7126
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
7127
#else
7128
int val;
7129
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
7130
#if PY_MAJOR_VERSION < 3
7131
if (likely(v) && !PyLong_Check(v)) {
7132
PyObject *tmp = v;
7133
v = PyNumber_Long(tmp);
7134
Py_DECREF(tmp);
7135
}
7136
#endif
7137
if (likely(v)) {
7138
int one = 1; int is_little = (int)*(unsigned char *)&one;
7139
unsigned char *bytes = (unsigned char *)&val;
7140
int ret = _PyLong_AsByteArray((PyLongObject *)v,
7141
bytes, sizeof(val),
7142
is_little, !is_unsigned);
7143
Py_DECREF(v);
7144
if (likely(!ret))
7145
return val;
7146
}
7147
#endif
7148
return (int) -1;
7149
}
7150
} else {
7151
int val;
7152
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
7153
if (!tmp) return (int) -1;
7154
val = __Pyx_PyInt_As_int(tmp);
7155
Py_DECREF(tmp);
7156
return val;
7157
}
7158
raise_overflow:
7159
PyErr_SetString(PyExc_OverflowError,
7160
"value too large to convert to int");
7161
return (int) -1;
7162
raise_neg_overflow:
7163
PyErr_SetString(PyExc_OverflowError,
7164
"can't convert negative value to int");
7165
return (int) -1;
7166
}
7167
7168
/* CheckBinaryVersion */
7169
static int __Pyx_check_binary_version(void) {
7170
char ctversion[4], rtversion[4];
7171
PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
7172
PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
7173
if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
7174
char message[200];
7175
PyOS_snprintf(message, sizeof(message),
7176
"compiletime version %s of module '%.100s' "
7177
"does not match runtime version %s",
7178
ctversion, __Pyx_MODULE_NAME, rtversion);
7179
return PyErr_WarnEx(NULL, message, 1);
7180
}
7181
return 0;
7182
}
7183
7184
/* ModuleImport */
7185
#ifndef __PYX_HAVE_RT_ImportModule
7186
#define __PYX_HAVE_RT_ImportModule
7187
static PyObject *__Pyx_ImportModule(const char *name) {
7188
PyObject *py_name = 0;
7189
PyObject *py_module = 0;
7190
py_name = __Pyx_PyIdentifier_FromString(name);
7191
if (!py_name)
7192
goto bad;
7193
py_module = PyImport_Import(py_name);
7194
Py_DECREF(py_name);
7195
return py_module;
7196
bad:
7197
Py_XDECREF(py_name);
7198
return 0;
7199
}
7200
#endif
7201
7202
/* TypeImport */
7203
#ifndef __PYX_HAVE_RT_ImportType
7204
#define __PYX_HAVE_RT_ImportType
7205
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
7206
size_t size, int strict)
7207
{
7208
PyObject *py_module = 0;
7209
PyObject *result = 0;
7210
PyObject *py_name = 0;
7211
char warning[200];
7212
Py_ssize_t basicsize;
7213
#ifdef Py_LIMITED_API
7214
PyObject *py_basicsize;
7215
#endif
7216
py_module = __Pyx_ImportModule(module_name);
7217
if (!py_module)
7218
goto bad;
7219
py_name = __Pyx_PyIdentifier_FromString(class_name);
7220
if (!py_name)
7221
goto bad;
7222
result = PyObject_GetAttr(py_module, py_name);
7223
Py_DECREF(py_name);
7224
py_name = 0;
7225
Py_DECREF(py_module);
7226
py_module = 0;
7227
if (!result)
7228
goto bad;
7229
if (!PyType_Check(result)) {
7230
PyErr_Format(PyExc_TypeError,
7231
"%.200s.%.200s is not a type object",
7232
module_name, class_name);
7233
goto bad;
7234
}
7235
#ifndef Py_LIMITED_API
7236
basicsize = ((PyTypeObject *)result)->tp_basicsize;
7237
#else
7238
py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
7239
if (!py_basicsize)
7240
goto bad;
7241
basicsize = PyLong_AsSsize_t(py_basicsize);
7242
Py_DECREF(py_basicsize);
7243
py_basicsize = 0;
7244
if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
7245
goto bad;
7246
#endif
7247
if (!strict && (size_t)basicsize > size) {
7248
PyOS_snprintf(warning, sizeof(warning),
7249
"%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
7250
module_name, class_name, basicsize, size);
7251
if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
7252
}
7253
else if ((size_t)basicsize != size) {
7254
PyErr_Format(PyExc_ValueError,
7255
"%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
7256
module_name, class_name, basicsize, size);
7257
goto bad;
7258
}
7259
return (PyTypeObject *)result;
7260
bad:
7261
Py_XDECREF(py_module);
7262
Py_XDECREF(result);
7263
return NULL;
7264
}
7265
#endif
7266
7267
/* VoidPtrImport */
7268
#ifndef __PYX_HAVE_RT_ImportVoidPtr
7269
#define __PYX_HAVE_RT_ImportVoidPtr
7270
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
7271
PyObject *d = 0;
7272
PyObject *cobj = 0;
7273
d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
7274
if (!d)
7275
goto bad;
7276
cobj = PyDict_GetItemString(d, name);
7277
if (!cobj) {
7278
PyErr_Format(PyExc_ImportError,
7279
"%.200s does not export expected C variable %.200s",
7280
PyModule_GetName(module), name);
7281
goto bad;
7282
}
7283
#if PY_VERSION_HEX >= 0x02070000
7284
if (!PyCapsule_IsValid(cobj, sig)) {
7285
PyErr_Format(PyExc_TypeError,
7286
"C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
7287
PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
7288
goto bad;
7289
}
7290
*p = PyCapsule_GetPointer(cobj, sig);
7291
#else
7292
{const char *desc, *s1, *s2;
7293
desc = (const char *)PyCObject_GetDesc(cobj);
7294
if (!desc)
7295
goto bad;
7296
s1 = desc; s2 = sig;
7297
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
7298
if (*s1 != *s2) {
7299
PyErr_Format(PyExc_TypeError,
7300
"C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
7301
PyModule_GetName(module), name, sig, desc);
7302
goto bad;
7303
}
7304
*p = PyCObject_AsVoidPtr(cobj);}
7305
#endif
7306
if (!(*p))
7307
goto bad;
7308
Py_DECREF(d);
7309
return 0;
7310
bad:
7311
Py_XDECREF(d);
7312
return -1;
7313
}
7314
#endif
7315
7316
/* InitStrings */
7317
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
7318
while (t->p) {
7319
#if PY_MAJOR_VERSION < 3
7320
if (t->is_unicode) {
7321
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
7322
} else if (t->intern) {
7323
*t->p = PyString_InternFromString(t->s);
7324
} else {
7325
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
7326
}
7327
#else
7328
if (t->is_unicode | t->is_str) {
7329
if (t->intern) {
7330
*t->p = PyUnicode_InternFromString(t->s);
7331
} else if (t->encoding) {
7332
*t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
7333
} else {
7334
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
7335
}
7336
} else {
7337
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
7338
}
7339
#endif
7340
if (!*t->p)
7341
return -1;
7342
++t;
7343
}
7344
return 0;
7345
}
7346
7347
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
7348
return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
7349
}
7350
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
7351
Py_ssize_t ignore;
7352
return __Pyx_PyObject_AsStringAndSize(o, &ignore);
7353
}
7354
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
7355
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
7356
if (
7357
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
7358
__Pyx_sys_getdefaultencoding_not_ascii &&
7359
#endif
7360
PyUnicode_Check(o)) {
7361
#if PY_VERSION_HEX < 0x03030000
7362
char* defenc_c;
7363
PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
7364
if (!defenc) return NULL;
7365
defenc_c = PyBytes_AS_STRING(defenc);
7366
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
7367
{
7368
char* end = defenc_c + PyBytes_GET_SIZE(defenc);
7369
char* c;
7370
for (c = defenc_c; c < end; c++) {
7371
if ((unsigned char) (*c) >= 128) {
7372
PyUnicode_AsASCIIString(o);
7373
return NULL;
7374
}
7375
}
7376
}
7377
#endif
7378
*length = PyBytes_GET_SIZE(defenc);
7379
return defenc_c;
7380
#else
7381
if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
7382
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
7383
if (PyUnicode_IS_ASCII(o)) {
7384
*length = PyUnicode_GET_LENGTH(o);
7385
return PyUnicode_AsUTF8(o);
7386
} else {
7387
PyUnicode_AsASCIIString(o);
7388
return NULL;
7389
}
7390
#else
7391
return PyUnicode_AsUTF8AndSize(o, length);
7392
#endif
7393
#endif
7394
} else
7395
#endif
7396
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
7397
if (PyByteArray_Check(o)) {
7398
*length = PyByteArray_GET_SIZE(o);
7399
return PyByteArray_AS_STRING(o);
7400
} else
7401
#endif
7402
{
7403
char* result;
7404
int r = PyBytes_AsStringAndSize(o, &result, length);
7405
if (unlikely(r < 0)) {
7406
return NULL;
7407
} else {
7408
return result;
7409
}
7410
}
7411
}
7412
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
7413
int is_true = x == Py_True;
7414
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
7415
else return PyObject_IsTrue(x);
7416
}
7417
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
7418
#if CYTHON_USE_TYPE_SLOTS
7419
PyNumberMethods *m;
7420
#endif
7421
const char *name = NULL;
7422
PyObject *res = NULL;
7423
#if PY_MAJOR_VERSION < 3
7424
if (PyInt_Check(x) || PyLong_Check(x))
7425
#else
7426
if (PyLong_Check(x))
7427
#endif
7428
return __Pyx_NewRef(x);
7429
#if CYTHON_USE_TYPE_SLOTS
7430
m = Py_TYPE(x)->tp_as_number;
7431
#if PY_MAJOR_VERSION < 3
7432
if (m && m->nb_int) {
7433
name = "int";
7434
res = PyNumber_Int(x);
7435
}
7436
else if (m && m->nb_long) {
7437
name = "long";
7438
res = PyNumber_Long(x);
7439
}
7440
#else
7441
if (m && m->nb_int) {
7442
name = "int";
7443
res = PyNumber_Long(x);
7444
}
7445
#endif
7446
#else
7447
res = PyNumber_Int(x);
7448
#endif
7449
if (res) {
7450
#if PY_MAJOR_VERSION < 3
7451
if (!PyInt_Check(res) && !PyLong_Check(res)) {
7452
#else
7453
if (!PyLong_Check(res)) {
7454
#endif
7455
PyErr_Format(PyExc_TypeError,
7456
"__%.4s__ returned non-%.4s (type %.200s)",
7457
name, name, Py_TYPE(res)->tp_name);
7458
Py_DECREF(res);
7459
return NULL;
7460
}
7461
}
7462
else if (!PyErr_Occurred()) {
7463
PyErr_SetString(PyExc_TypeError,
7464
"an integer is required");
7465
}
7466
return res;
7467
}
7468
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
7469
Py_ssize_t ival;
7470
PyObject *x;
7471
#if PY_MAJOR_VERSION < 3
7472
if (likely(PyInt_CheckExact(b))) {
7473
if (sizeof(Py_ssize_t) >= sizeof(long))
7474
return PyInt_AS_LONG(b);
7475
else
7476
return PyInt_AsSsize_t(x);
7477
}
7478
#endif
7479
if (likely(PyLong_CheckExact(b))) {
7480
#if CYTHON_USE_PYLONG_INTERNALS
7481
const digit* digits = ((PyLongObject*)b)->ob_digit;
7482
const Py_ssize_t size = Py_SIZE(b);
7483
if (likely(__Pyx_sst_abs(size) <= 1)) {
7484
ival = likely(size) ? digits[0] : 0;
7485
if (size == -1) ival = -ival;
7486
return ival;
7487
} else {
7488
switch (size) {
7489
case 2:
7490
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
7491
return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
7492
}
7493
break;
7494
case -2:
7495
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
7496
return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
7497
}
7498
break;
7499
case 3:
7500
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
7501
return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
7502
}
7503
break;
7504
case -3:
7505
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
7506
return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
7507
}
7508
break;
7509
case 4:
7510
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
7511
return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
7512
}
7513
break;
7514
case -4:
7515
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
7516
return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
7517
}
7518
break;
7519
}
7520
}
7521
#endif
7522
return PyLong_AsSsize_t(b);
7523
}
7524
x = PyNumber_Index(b);
7525
if (!x) return -1;
7526
ival = PyInt_AsSsize_t(x);
7527
Py_DECREF(x);
7528
return ival;
7529
}
7530
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
7531
return PyInt_FromSize_t(ival);
7532
}
7533
7534
7535
#endif /* Py_PYTHON_H */
7536
7537