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__helper
431
#define __PYX_HAVE_API__code__alex__psage__psage__ellcurve__lseries__helper
432
#ifdef _OPENMP
433
#include <omp.h>
434
#endif /* _OPENMP */
435
436
#ifdef PYREX_WITHOUT_ASSERTIONS
437
#define CYTHON_WITHOUT_ASSERTIONS
438
#endif
439
440
typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
441
const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
442
443
#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
444
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
445
#define __PYX_DEFAULT_STRING_ENCODING ""
446
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
447
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
448
#define __Pyx_uchar_cast(c) ((unsigned char)c)
449
#define __Pyx_long_cast(x) ((long)x)
450
#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
451
(sizeof(type) < sizeof(Py_ssize_t)) ||\
452
(sizeof(type) > sizeof(Py_ssize_t) &&\
453
likely(v < (type)PY_SSIZE_T_MAX ||\
454
v == (type)PY_SSIZE_T_MAX) &&\
455
(!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
456
v == (type)PY_SSIZE_T_MIN))) ||\
457
(sizeof(type) == sizeof(Py_ssize_t) &&\
458
(is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
459
v == (type)PY_SSIZE_T_MAX))) )
460
#if defined (__cplusplus) && __cplusplus >= 201103L
461
#include <cstdlib>
462
#define __Pyx_sst_abs(value) std::abs(value)
463
#elif SIZEOF_INT >= SIZEOF_SIZE_T
464
#define __Pyx_sst_abs(value) abs(value)
465
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
466
#define __Pyx_sst_abs(value) labs(value)
467
#elif defined (_MSC_VER) && defined (_M_X64)
468
#define __Pyx_sst_abs(value) _abs64(value)
469
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
470
#define __Pyx_sst_abs(value) llabs(value)
471
#elif defined (__GNUC__)
472
#define __Pyx_sst_abs(value) __builtin_llabs(value)
473
#else
474
#define __Pyx_sst_abs(value) ((value<0) ? -value : value)
475
#endif
476
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
477
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
478
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
479
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
480
#define __Pyx_PyBytes_FromString PyBytes_FromString
481
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
482
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
483
#if PY_MAJOR_VERSION < 3
484
#define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
485
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
486
#else
487
#define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
488
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
489
#endif
490
#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
491
#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
492
#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
493
#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
494
#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
495
#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
496
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
497
#if PY_MAJOR_VERSION < 3
498
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
499
{
500
const Py_UNICODE *u_end = u;
501
while (*u_end++) ;
502
return (size_t)(u_end - u - 1);
503
}
504
#else
505
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
506
#endif
507
#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
508
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
509
#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
510
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
511
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
512
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
513
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
514
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
515
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
516
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
517
#if CYTHON_ASSUME_SAFE_MACROS
518
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
519
#else
520
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
521
#endif
522
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
523
#if PY_MAJOR_VERSION >= 3
524
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
525
#else
526
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
527
#endif
528
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
529
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
530
static int __Pyx_sys_getdefaultencoding_not_ascii;
531
static int __Pyx_init_sys_getdefaultencoding_params(void) {
532
PyObject* sys;
533
PyObject* default_encoding = NULL;
534
PyObject* ascii_chars_u = NULL;
535
PyObject* ascii_chars_b = NULL;
536
const char* default_encoding_c;
537
sys = PyImport_ImportModule("sys");
538
if (!sys) goto bad;
539
default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
540
Py_DECREF(sys);
541
if (!default_encoding) goto bad;
542
default_encoding_c = PyBytes_AsString(default_encoding);
543
if (!default_encoding_c) goto bad;
544
if (strcmp(default_encoding_c, "ascii") == 0) {
545
__Pyx_sys_getdefaultencoding_not_ascii = 0;
546
} else {
547
char ascii_chars[128];
548
int c;
549
for (c = 0; c < 128; c++) {
550
ascii_chars[c] = c;
551
}
552
__Pyx_sys_getdefaultencoding_not_ascii = 1;
553
ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
554
if (!ascii_chars_u) goto bad;
555
ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
556
if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
557
PyErr_Format(
558
PyExc_ValueError,
559
"This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
560
default_encoding_c);
561
goto bad;
562
}
563
Py_DECREF(ascii_chars_u);
564
Py_DECREF(ascii_chars_b);
565
}
566
Py_DECREF(default_encoding);
567
return 0;
568
bad:
569
Py_XDECREF(default_encoding);
570
Py_XDECREF(ascii_chars_u);
571
Py_XDECREF(ascii_chars_b);
572
return -1;
573
}
574
#endif
575
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
576
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
577
#else
578
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
579
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
580
static char* __PYX_DEFAULT_STRING_ENCODING;
581
static int __Pyx_init_sys_getdefaultencoding_params(void) {
582
PyObject* sys;
583
PyObject* default_encoding = NULL;
584
char* default_encoding_c;
585
sys = PyImport_ImportModule("sys");
586
if (!sys) goto bad;
587
default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
588
Py_DECREF(sys);
589
if (!default_encoding) goto bad;
590
default_encoding_c = PyBytes_AsString(default_encoding);
591
if (!default_encoding_c) goto bad;
592
__PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
593
if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
594
strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
595
Py_DECREF(default_encoding);
596
return 0;
597
bad:
598
Py_XDECREF(default_encoding);
599
return -1;
600
}
601
#endif
602
#endif
603
604
605
/* Test for GCC > 2.95 */
606
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
607
#define likely(x) __builtin_expect(!!(x), 1)
608
#define unlikely(x) __builtin_expect(!!(x), 0)
609
#else /* !__GNUC__ or GCC < 2.95 */
610
#define likely(x) (x)
611
#define unlikely(x) (x)
612
#endif /* __GNUC__ */
613
614
static PyObject *__pyx_m;
615
static PyObject *__pyx_d;
616
static PyObject *__pyx_b;
617
static PyObject *__pyx_empty_tuple;
618
static PyObject *__pyx_empty_bytes;
619
static PyObject *__pyx_empty_unicode;
620
static int __pyx_lineno;
621
static int __pyx_clineno = 0;
622
static const char * __pyx_cfilenm= __FILE__;
623
static const char *__pyx_filename;
624
625
626
static const char *__pyx_f[] = {
627
"code/alex/psage/psage/ellcurve/lseries/helper.pyx",
628
"intlist.pxd",
629
};
630
631
/*--- Type declarations ---*/
632
struct __pyx_obj_4sage_5stats_7intlist_IntList;
633
634
/* "sage/stats/intlist.pxd":8
635
* #############################################################################
636
*
637
* cdef class IntList: # <<<<<<<<<<<<<<
638
* cdef int* _values
639
* cdef Py_ssize_t _length
640
*/
641
struct __pyx_obj_4sage_5stats_7intlist_IntList {
642
PyObject_HEAD
643
struct __pyx_vtabstruct_4sage_5stats_7intlist_IntList *__pyx_vtab;
644
int *_values;
645
Py_ssize_t _length;
646
};
647
648
649
650
struct __pyx_vtabstruct_4sage_5stats_7intlist_IntList {
651
int (*prod)(struct __pyx_obj_4sage_5stats_7intlist_IntList *, int __pyx_skip_dispatch);
652
int (*sum)(struct __pyx_obj_4sage_5stats_7intlist_IntList *, int __pyx_skip_dispatch);
653
};
654
static struct __pyx_vtabstruct_4sage_5stats_7intlist_IntList *__pyx_vtabptr_4sage_5stats_7intlist_IntList;
655
656
/* --- Runtime support code (head) --- */
657
/* Refnanny.proto */
658
#ifndef CYTHON_REFNANNY
659
#define CYTHON_REFNANNY 0
660
#endif
661
#if CYTHON_REFNANNY
662
typedef struct {
663
void (*INCREF)(void*, PyObject*, int);
664
void (*DECREF)(void*, PyObject*, int);
665
void (*GOTREF)(void*, PyObject*, int);
666
void (*GIVEREF)(void*, PyObject*, int);
667
void* (*SetupContext)(const char*, int, const char*);
668
void (*FinishContext)(void**);
669
} __Pyx_RefNannyAPIStruct;
670
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
671
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
672
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
673
#ifdef WITH_THREAD
674
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
675
if (acquire_gil) {\
676
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
677
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
678
PyGILState_Release(__pyx_gilstate_save);\
679
} else {\
680
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
681
}
682
#else
683
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
684
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
685
#endif
686
#define __Pyx_RefNannyFinishContext()\
687
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
688
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
689
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
690
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
691
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
692
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
693
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
694
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
695
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
696
#else
697
#define __Pyx_RefNannyDeclarations
698
#define __Pyx_RefNannySetupContext(name, acquire_gil)
699
#define __Pyx_RefNannyFinishContext()
700
#define __Pyx_INCREF(r) Py_INCREF(r)
701
#define __Pyx_DECREF(r) Py_DECREF(r)
702
#define __Pyx_GOTREF(r)
703
#define __Pyx_GIVEREF(r)
704
#define __Pyx_XINCREF(r) Py_XINCREF(r)
705
#define __Pyx_XDECREF(r) Py_XDECREF(r)
706
#define __Pyx_XGOTREF(r)
707
#define __Pyx_XGIVEREF(r)
708
#endif
709
#define __Pyx_XDECREF_SET(r, v) do {\
710
PyObject *tmp = (PyObject *) r;\
711
r = v; __Pyx_XDECREF(tmp);\
712
} while (0)
713
#define __Pyx_DECREF_SET(r, v) do {\
714
PyObject *tmp = (PyObject *) r;\
715
r = v; __Pyx_DECREF(tmp);\
716
} while (0)
717
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
718
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
719
720
/* PyObjectGetAttrStr.proto */
721
#if CYTHON_USE_TYPE_SLOTS
722
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
723
PyTypeObject* tp = Py_TYPE(obj);
724
if (likely(tp->tp_getattro))
725
return tp->tp_getattro(obj, attr_name);
726
#if PY_MAJOR_VERSION < 3
727
if (likely(tp->tp_getattr))
728
return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
729
#endif
730
return PyObject_GetAttr(obj, attr_name);
731
}
732
#else
733
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
734
#endif
735
736
/* GetBuiltinName.proto */
737
static PyObject *__Pyx_GetBuiltinName(PyObject *name);
738
739
/* GetModuleGlobalName.proto */
740
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
741
742
/* PyObjectCall.proto */
743
#if CYTHON_COMPILING_IN_CPYTHON
744
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
745
#else
746
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
747
#endif
748
749
/* SetItemInt.proto */
750
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
751
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
752
__Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
753
(is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
754
__Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
755
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
756
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
757
int is_list, int wraparound, int boundscheck);
758
759
/* SliceObject.proto */
760
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
761
PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
762
PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
763
int has_cstart, int has_cstop, int wraparound);
764
765
/* ArgTypeTest.proto */
766
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
767
const char *name, int exact);
768
769
/* PyCFunctionFastCall.proto */
770
#if CYTHON_FAST_PYCCALL
771
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
772
#else
773
#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
774
#endif
775
776
/* PyFunctionFastCall.proto */
777
#if CYTHON_FAST_PYCALL
778
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
779
__Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
780
#if 1 || PY_VERSION_HEX < 0x030600B1
781
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
782
#else
783
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
784
#endif
785
#endif
786
787
/* PyObjectCallMethO.proto */
788
#if CYTHON_COMPILING_IN_CPYTHON
789
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
790
#endif
791
792
/* PyObjectCallOneArg.proto */
793
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
794
795
/* RaiseTooManyValuesToUnpack.proto */
796
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
797
798
/* RaiseNeedMoreValuesToUnpack.proto */
799
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
800
801
/* IterFinish.proto */
802
static CYTHON_INLINE int __Pyx_IterFinish(void);
803
804
/* UnpackItemEndCheck.proto */
805
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
806
807
/* ExtTypeTest.proto */
808
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
809
810
/* GetItemInt.proto */
811
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
812
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
813
__Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
814
(is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
815
__Pyx_GetItemInt_Generic(o, to_py_func(i))))
816
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
817
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
818
__Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
819
(PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
820
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
821
int wraparound, int boundscheck);
822
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
823
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
824
__Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
825
(PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
826
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
827
int wraparound, int boundscheck);
828
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
829
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
830
int is_list, int wraparound, int boundscheck);
831
832
/* None.proto */
833
static CYTHON_INLINE int __Pyx_mod_int(int, int);
834
835
/* GetVTable.proto */
836
static void* __Pyx_GetVtable(PyObject *dict);
837
838
/* Import.proto */
839
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
840
841
/* ImportFrom.proto */
842
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
843
844
/* CodeObjectCache.proto */
845
typedef struct {
846
PyCodeObject* code_object;
847
int code_line;
848
} __Pyx_CodeObjectCacheEntry;
849
struct __Pyx_CodeObjectCache {
850
int count;
851
int max_count;
852
__Pyx_CodeObjectCacheEntry* entries;
853
};
854
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
855
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
856
static PyCodeObject *__pyx_find_code_object(int code_line);
857
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
858
859
/* AddTraceback.proto */
860
static void __Pyx_AddTraceback(const char *funcname, int c_line,
861
int py_line, const char *filename);
862
863
/* CIntToPy.proto */
864
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
865
866
/* CIntToPy.proto */
867
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
868
869
/* CIntFromPy.proto */
870
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
871
872
/* CIntFromPy.proto */
873
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
874
875
/* CheckBinaryVersion.proto */
876
static int __Pyx_check_binary_version(void);
877
878
/* PyIdentifierFromString.proto */
879
#if !defined(__Pyx_PyIdentifier_FromString)
880
#if PY_MAJOR_VERSION < 3
881
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
882
#else
883
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
884
#endif
885
#endif
886
887
/* ModuleImport.proto */
888
static PyObject *__Pyx_ImportModule(const char *name);
889
890
/* TypeImport.proto */
891
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
892
893
/* InitStrings.proto */
894
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
895
896
897
/* Module declarations from 'sage.stats.intlist' */
898
static PyTypeObject *__pyx_ptype_4sage_5stats_7intlist_IntList = 0;
899
900
/* Module declarations from 'code.alex.psage.psage.ellcurve.lseries.helper' */
901
#define __Pyx_MODULE_NAME "code.alex.psage.psage.ellcurve.lseries.helper"
902
int __pyx_module_is_main_code__alex__psage__psage__ellcurve__lseries__helper = 0;
903
904
/* Implementation of 'code.alex.psage.psage.ellcurve.lseries.helper' */
905
static PyObject *__pyx_builtin_range;
906
static const char __pyx_k_B[] = "B";
907
static const char __pyx_k_P[] = "P";
908
static const char __pyx_k_a[] = "a";
909
static const char __pyx_k_i[] = "i";
910
static const char __pyx_k_k[] = "k";
911
static const char __pyx_k_n[] = "n";
912
static const char __pyx_k_p[] = "p";
913
static const char __pyx_k_q[] = "q";
914
static const char __pyx_k_v[] = "v";
915
static const char __pyx_k_w[] = "w";
916
static const char __pyx_k_P0[] = "P0";
917
static const char __pyx_k_pp[] = "pp";
918
static const char __pyx_k_w0[] = "w0";
919
static const char __pyx_k_main[] = "__main__";
920
static const char __pyx_k_test[] = "__test__";
921
static const char __pyx_k_known[] = "known";
922
static const char __pyx_k_range[] = "range";
923
static const char __pyx_k_import[] = "__import__";
924
static const char __pyx_k_py_ints[] = "py_ints";
925
static const char __pyx_k_sage_all[] = "sage.all";
926
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
927
static const char __pyx_k_prime_range[] = "prime_range";
928
static const char __pyx_k_prime_powers_intlist[] = "prime_powers_intlist";
929
static const char __pyx_k_extend_multiplicatively[] = "extend_multiplicatively";
930
static const char __pyx_k_extend_multiplicatively_generic[] = "extend_multiplicatively_generic";
931
static const char __pyx_k_projects_68c8b2b8_03ba_44d4_a0d[] = "/projects/68c8b2b8-03ba-44d4-a0d1-5d771c8cb465/code/alex/psage/psage/ellcurve/lseries/helper.pyx";
932
static const char __pyx_k_File_helper_pyx_starting_at_line[] = "File: helper.pyx (starting at line 2)";
933
static const char __pyx_k_code_alex_psage_psage_ellcurve_l[] = "code.alex.psage.psage.ellcurve.lseries.helper";
934
static PyObject *__pyx_n_s_B;
935
static PyObject *__pyx_n_s_P;
936
static PyObject *__pyx_n_s_P0;
937
static PyObject *__pyx_n_s_a;
938
static PyObject *__pyx_n_s_code_alex_psage_psage_ellcurve_l;
939
static PyObject *__pyx_n_s_extend_multiplicatively;
940
static PyObject *__pyx_n_s_extend_multiplicatively_generic;
941
static PyObject *__pyx_n_s_i;
942
static PyObject *__pyx_n_s_import;
943
static PyObject *__pyx_n_s_k;
944
static PyObject *__pyx_n_s_known;
945
static PyObject *__pyx_n_s_main;
946
static PyObject *__pyx_n_s_n;
947
static PyObject *__pyx_n_s_p;
948
static PyObject *__pyx_n_s_pp;
949
static PyObject *__pyx_n_s_prime_powers_intlist;
950
static PyObject *__pyx_n_s_prime_range;
951
static PyObject *__pyx_kp_s_projects_68c8b2b8_03ba_44d4_a0d;
952
static PyObject *__pyx_n_s_py_ints;
953
static PyObject *__pyx_n_s_pyx_vtable;
954
static PyObject *__pyx_n_s_q;
955
static PyObject *__pyx_n_s_range;
956
static PyObject *__pyx_n_s_sage_all;
957
static PyObject *__pyx_n_s_test;
958
static PyObject *__pyx_n_s_v;
959
static PyObject *__pyx_n_s_w;
960
static PyObject *__pyx_n_s_w0;
961
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_prime_powers_intlist(CYTHON_UNUSED PyObject *__pyx_self, Py_ssize_t __pyx_v_B); /* proto */
962
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_2extend_multiplicatively(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4sage_5stats_7intlist_IntList *__pyx_v_a); /* proto */
963
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_4extend_multiplicatively_generic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a); /* proto */
964
static PyObject *__pyx_int_1;
965
static PyObject *__pyx_tuple_;
966
static PyObject *__pyx_tuple__3;
967
static PyObject *__pyx_tuple__5;
968
static PyObject *__pyx_codeobj__2;
969
static PyObject *__pyx_codeobj__4;
970
static PyObject *__pyx_codeobj__6;
971
972
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":6
973
* from sage.all import prime_range
974
*
975
* def prime_powers_intlist(Py_ssize_t B): # <<<<<<<<<<<<<<
976
* """
977
* Return IntList of the prime powers and corresponding primes, up to
978
*/
979
980
/* Python wrapper */
981
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_1prime_powers_intlist(PyObject *__pyx_self, PyObject *__pyx_arg_B); /*proto*/
982
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_prime_powers_intlist[] = "File: helper.pyx (starting at line 6)\n\n Return IntList of the prime powers and corresponding primes, up to\n B. The list is *not* in the usual order; instead the order is like\n this: 2,4,8,...,3,9,27,..., 5,25,..., etc.\n\n INPUT:\n\n - B -- positive integer\n\n EXAMPLES::\n \n sage: from psage.ellcurve.lseries.helper import prime_powers_intlist\n sage: prime_powers_intlist(10)\n ([1, 2, 4, 8, 3, 9, 5, 7], [1, 2, 2, 2, 3, 3, 5, 7])\n sage: prime_powers_intlist(10)\n ([1, 2, 4, 8, 3, 9, 5, 7], [1, 2, 2, 2, 3, 3, 5, 7])\n sage: prime_powers_intlist(20)\n ([1, 2, 4, 8, 16 ... 7, 11, 13, 17, 19], [1, 2, 2, 2, 2 ... 7, 11, 13, 17, 19])\n sage: list(sorted(prime_powers_intlist(10^6)[0])) == prime_powers(10^6)\n True\n sage: set(prime_powers_intlist(10^6)[1][1:]) == set(primes(10^6))\n True\n ";
983
static PyMethodDef __pyx_mdef_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_1prime_powers_intlist = {"prime_powers_intlist", (PyCFunction)__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_1prime_powers_intlist, METH_O, __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_prime_powers_intlist};
984
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_1prime_powers_intlist(PyObject *__pyx_self, PyObject *__pyx_arg_B) {
985
Py_ssize_t __pyx_v_B;
986
PyObject *__pyx_r = 0;
987
__Pyx_RefNannyDeclarations
988
__Pyx_RefNannySetupContext("prime_powers_intlist (wrapper)", 0);
989
assert(__pyx_arg_B); {
990
__pyx_v_B = __Pyx_PyIndex_AsSsize_t(__pyx_arg_B); if (unlikely((__pyx_v_B == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 6, __pyx_L3_error)
991
}
992
goto __pyx_L4_argument_unpacking_done;
993
__pyx_L3_error:;
994
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.helper.prime_powers_intlist", __pyx_clineno, __pyx_lineno, __pyx_filename);
995
__Pyx_RefNannyFinishContext();
996
return NULL;
997
__pyx_L4_argument_unpacking_done:;
998
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_prime_powers_intlist(__pyx_self, ((Py_ssize_t)__pyx_v_B));
999
1000
/* function exit code */
1001
__Pyx_RefNannyFinishContext();
1002
return __pyx_r;
1003
}
1004
1005
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_prime_powers_intlist(CYTHON_UNUSED PyObject *__pyx_self, Py_ssize_t __pyx_v_B) {
1006
PyObject *__pyx_v_v = NULL;
1007
struct __pyx_obj_4sage_5stats_7intlist_IntList *__pyx_v_w = 0;
1008
struct __pyx_obj_4sage_5stats_7intlist_IntList *__pyx_v_w0 = 0;
1009
Py_ssize_t __pyx_v_i;
1010
int __pyx_v_p;
1011
PY_LONG_LONG __pyx_v_q;
1012
PyObject *__pyx_r = NULL;
1013
__Pyx_RefNannyDeclarations
1014
PyObject *__pyx_t_1 = NULL;
1015
PyObject *__pyx_t_2 = NULL;
1016
PyObject *__pyx_t_3 = NULL;
1017
PyObject *__pyx_t_4 = NULL;
1018
Py_ssize_t __pyx_t_5;
1019
PyObject *(*__pyx_t_6)(PyObject *);
1020
int __pyx_t_7;
1021
int __pyx_t_8;
1022
__Pyx_RefNannySetupContext("prime_powers_intlist", 0);
1023
1024
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":30
1025
* True
1026
* """
1027
* v = prime_range(B, py_ints=True) # <<<<<<<<<<<<<<
1028
* cdef IntList w = IntList(len(v)*2), w0 = IntList(len(v)*2)
1029
* w[0] = 1
1030
*/
1031
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_prime_range); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
1032
__Pyx_GOTREF(__pyx_t_1);
1033
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_B); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
1034
__Pyx_GOTREF(__pyx_t_2);
1035
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 30, __pyx_L1_error)
1036
__Pyx_GOTREF(__pyx_t_3);
1037
__Pyx_GIVEREF(__pyx_t_2);
1038
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
1039
__pyx_t_2 = 0;
1040
__pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
1041
__Pyx_GOTREF(__pyx_t_2);
1042
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_py_ints, Py_True) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
1043
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 30, __pyx_L1_error)
1044
__Pyx_GOTREF(__pyx_t_4);
1045
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1046
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1047
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1048
__pyx_v_v = __pyx_t_4;
1049
__pyx_t_4 = 0;
1050
1051
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":31
1052
* """
1053
* v = prime_range(B, py_ints=True)
1054
* cdef IntList w = IntList(len(v)*2), w0 = IntList(len(v)*2) # <<<<<<<<<<<<<<
1055
* w[0] = 1
1056
* w0[0] = 1
1057
*/
1058
__pyx_t_5 = PyObject_Length(__pyx_v_v); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 31, __pyx_L1_error)
1059
__pyx_t_4 = PyInt_FromSsize_t((__pyx_t_5 * 2)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 31, __pyx_L1_error)
1060
__Pyx_GOTREF(__pyx_t_4);
1061
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
1062
__Pyx_GOTREF(__pyx_t_2);
1063
__Pyx_GIVEREF(__pyx_t_4);
1064
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
1065
__pyx_t_4 = 0;
1066
__pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4sage_5stats_7intlist_IntList), __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 31, __pyx_L1_error)
1067
__Pyx_GOTREF(__pyx_t_4);
1068
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1069
__pyx_v_w = ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)__pyx_t_4);
1070
__pyx_t_4 = 0;
1071
__pyx_t_5 = PyObject_Length(__pyx_v_v); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 31, __pyx_L1_error)
1072
__pyx_t_4 = PyInt_FromSsize_t((__pyx_t_5 * 2)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 31, __pyx_L1_error)
1073
__Pyx_GOTREF(__pyx_t_4);
1074
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
1075
__Pyx_GOTREF(__pyx_t_2);
1076
__Pyx_GIVEREF(__pyx_t_4);
1077
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
1078
__pyx_t_4 = 0;
1079
__pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4sage_5stats_7intlist_IntList), __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 31, __pyx_L1_error)
1080
__Pyx_GOTREF(__pyx_t_4);
1081
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1082
__pyx_v_w0 = ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)__pyx_t_4);
1083
__pyx_t_4 = 0;
1084
1085
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":32
1086
* v = prime_range(B, py_ints=True)
1087
* cdef IntList w = IntList(len(v)*2), w0 = IntList(len(v)*2)
1088
* w[0] = 1 # <<<<<<<<<<<<<<
1089
* w0[0] = 1
1090
* # Now fill in prime powers
1091
*/
1092
if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_v_w), 0, __pyx_int_1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 32, __pyx_L1_error)
1093
1094
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":33
1095
* cdef IntList w = IntList(len(v)*2), w0 = IntList(len(v)*2)
1096
* w[0] = 1
1097
* w0[0] = 1 # <<<<<<<<<<<<<<
1098
* # Now fill in prime powers
1099
* cdef Py_ssize_t i=1
1100
*/
1101
if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_v_w0), 0, __pyx_int_1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 33, __pyx_L1_error)
1102
1103
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":35
1104
* w0[0] = 1
1105
* # Now fill in prime powers
1106
* cdef Py_ssize_t i=1 # <<<<<<<<<<<<<<
1107
* cdef int p
1108
* cdef long long q # so that the "q < B" test doesn't fail due to overflow.
1109
*/
1110
__pyx_v_i = 1;
1111
1112
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":38
1113
* cdef int p
1114
* cdef long long q # so that the "q < B" test doesn't fail due to overflow.
1115
* for p in v: # <<<<<<<<<<<<<<
1116
* q = p
1117
* while q < B:
1118
*/
1119
if (likely(PyList_CheckExact(__pyx_v_v)) || PyTuple_CheckExact(__pyx_v_v)) {
1120
__pyx_t_4 = __pyx_v_v; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
1121
__pyx_t_6 = NULL;
1122
} else {
1123
__pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_v); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 38, __pyx_L1_error)
1124
__Pyx_GOTREF(__pyx_t_4);
1125
__pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 38, __pyx_L1_error)
1126
}
1127
for (;;) {
1128
if (likely(!__pyx_t_6)) {
1129
if (likely(PyList_CheckExact(__pyx_t_4))) {
1130
if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
1131
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1132
__pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 38, __pyx_L1_error)
1133
#else
1134
__pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
1135
__Pyx_GOTREF(__pyx_t_2);
1136
#endif
1137
} else {
1138
if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
1139
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1140
__pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 38, __pyx_L1_error)
1141
#else
1142
__pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
1143
__Pyx_GOTREF(__pyx_t_2);
1144
#endif
1145
}
1146
} else {
1147
__pyx_t_2 = __pyx_t_6(__pyx_t_4);
1148
if (unlikely(!__pyx_t_2)) {
1149
PyObject* exc_type = PyErr_Occurred();
1150
if (exc_type) {
1151
if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
1152
else __PYX_ERR(0, 38, __pyx_L1_error)
1153
}
1154
break;
1155
}
1156
__Pyx_GOTREF(__pyx_t_2);
1157
}
1158
__pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 38, __pyx_L1_error)
1159
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1160
__pyx_v_p = __pyx_t_7;
1161
1162
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":39
1163
* cdef long long q # so that the "q < B" test doesn't fail due to overflow.
1164
* for p in v:
1165
* q = p # <<<<<<<<<<<<<<
1166
* while q < B:
1167
* w._values[i] = q
1168
*/
1169
__pyx_v_q = __pyx_v_p;
1170
1171
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":40
1172
* for p in v:
1173
* q = p
1174
* while q < B: # <<<<<<<<<<<<<<
1175
* w._values[i] = q
1176
* w0._values[i] = p
1177
*/
1178
while (1) {
1179
__pyx_t_8 = ((__pyx_v_q < __pyx_v_B) != 0);
1180
if (!__pyx_t_8) break;
1181
1182
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":41
1183
* q = p
1184
* while q < B:
1185
* w._values[i] = q # <<<<<<<<<<<<<<
1186
* w0._values[i] = p
1187
* q *= p
1188
*/
1189
(__pyx_v_w->_values[__pyx_v_i]) = __pyx_v_q;
1190
1191
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":42
1192
* while q < B:
1193
* w._values[i] = q
1194
* w0._values[i] = p # <<<<<<<<<<<<<<
1195
* q *= p
1196
* i += 1
1197
*/
1198
(__pyx_v_w0->_values[__pyx_v_i]) = __pyx_v_p;
1199
1200
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":43
1201
* w._values[i] = q
1202
* w0._values[i] = p
1203
* q *= p # <<<<<<<<<<<<<<
1204
* i += 1
1205
* return w[:i], w0[:i]
1206
*/
1207
__pyx_v_q = (__pyx_v_q * __pyx_v_p);
1208
1209
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":44
1210
* w0._values[i] = p
1211
* q *= p
1212
* i += 1 # <<<<<<<<<<<<<<
1213
* return w[:i], w0[:i]
1214
*
1215
*/
1216
__pyx_v_i = (__pyx_v_i + 1);
1217
}
1218
1219
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":38
1220
* cdef int p
1221
* cdef long long q # so that the "q < B" test doesn't fail due to overflow.
1222
* for p in v: # <<<<<<<<<<<<<<
1223
* q = p
1224
* while q < B:
1225
*/
1226
}
1227
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1228
1229
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":45
1230
* q *= p
1231
* i += 1
1232
* return w[:i], w0[:i] # <<<<<<<<<<<<<<
1233
*
1234
* def extend_multiplicatively(IntList a):
1235
*/
1236
__Pyx_XDECREF(__pyx_r);
1237
__pyx_t_4 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_w), 0, __pyx_v_i, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 45, __pyx_L1_error)
1238
__Pyx_GOTREF(__pyx_t_4);
1239
__pyx_t_2 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_w0), 0, __pyx_v_i, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
1240
__Pyx_GOTREF(__pyx_t_2);
1241
__pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error)
1242
__Pyx_GOTREF(__pyx_t_3);
1243
__Pyx_GIVEREF(__pyx_t_4);
1244
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
1245
__Pyx_GIVEREF(__pyx_t_2);
1246
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
1247
__pyx_t_4 = 0;
1248
__pyx_t_2 = 0;
1249
__pyx_r = __pyx_t_3;
1250
__pyx_t_3 = 0;
1251
goto __pyx_L0;
1252
1253
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":6
1254
* from sage.all import prime_range
1255
*
1256
* def prime_powers_intlist(Py_ssize_t B): # <<<<<<<<<<<<<<
1257
* """
1258
* Return IntList of the prime powers and corresponding primes, up to
1259
*/
1260
1261
/* function exit code */
1262
__pyx_L1_error:;
1263
__Pyx_XDECREF(__pyx_t_1);
1264
__Pyx_XDECREF(__pyx_t_2);
1265
__Pyx_XDECREF(__pyx_t_3);
1266
__Pyx_XDECREF(__pyx_t_4);
1267
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.helper.prime_powers_intlist", __pyx_clineno, __pyx_lineno, __pyx_filename);
1268
__pyx_r = NULL;
1269
__pyx_L0:;
1270
__Pyx_XDECREF(__pyx_v_v);
1271
__Pyx_XDECREF((PyObject *)__pyx_v_w);
1272
__Pyx_XDECREF((PyObject *)__pyx_v_w0);
1273
__Pyx_XGIVEREF(__pyx_r);
1274
__Pyx_RefNannyFinishContext();
1275
return __pyx_r;
1276
}
1277
1278
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":47
1279
* return w[:i], w0[:i]
1280
*
1281
* def extend_multiplicatively(IntList a): # <<<<<<<<<<<<<<
1282
* """
1283
* Given an IntList a such that the a[p^r] is filled in, for all
1284
*/
1285
1286
/* Python wrapper */
1287
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_3extend_multiplicatively(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
1288
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_2extend_multiplicatively[] = "File: helper.pyx (starting at line 47)\n\n Given an IntList a such that the a[p^r] is filled in, for all\n prime powers p^r, fill in all the other a[n] multiplicatively.\n\n INPUT:\n - a -- IntList with prime-power-index entries set; all other\n entries are ignored\n\n OUTPUT:\n - the input object a is modified to have all entries set\n via multiplicativity.\n\n EXAMPLES::\n\n sage: from psage.ellcurve.lseries.helper import extend_multiplicatively\n sage: B = 10^5; E = EllipticCurve('389a'); an = stats.IntList(B)\n sage: for pp in prime_powers(B):\n ... an[pp] = E.an(pp)\n ...\n sage: extend_multiplicatively(an)\n sage: list(an) == E.anlist(len(an))[:len(an)]\n True\n ";
1289
static PyMethodDef __pyx_mdef_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_3extend_multiplicatively = {"extend_multiplicatively", (PyCFunction)__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_3extend_multiplicatively, METH_O, __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_2extend_multiplicatively};
1290
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_3extend_multiplicatively(PyObject *__pyx_self, PyObject *__pyx_v_a) {
1291
PyObject *__pyx_r = 0;
1292
__Pyx_RefNannyDeclarations
1293
__Pyx_RefNannySetupContext("extend_multiplicatively (wrapper)", 0);
1294
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4sage_5stats_7intlist_IntList, 1, "a", 0))) __PYX_ERR(0, 47, __pyx_L1_error)
1295
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_2extend_multiplicatively(__pyx_self, ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)__pyx_v_a));
1296
1297
/* function exit code */
1298
goto __pyx_L0;
1299
__pyx_L1_error:;
1300
__pyx_r = NULL;
1301
__pyx_L0:;
1302
__Pyx_RefNannyFinishContext();
1303
return __pyx_r;
1304
}
1305
1306
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_2extend_multiplicatively(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4sage_5stats_7intlist_IntList *__pyx_v_a) {
1307
Py_ssize_t __pyx_v_i;
1308
Py_ssize_t __pyx_v_B;
1309
struct __pyx_obj_4sage_5stats_7intlist_IntList *__pyx_v_P = 0;
1310
struct __pyx_obj_4sage_5stats_7intlist_IntList *__pyx_v_P0 = 0;
1311
struct __pyx_obj_4sage_5stats_7intlist_IntList *__pyx_v_known = 0;
1312
int __pyx_v_k;
1313
int __pyx_v_pp;
1314
int __pyx_v_p;
1315
int __pyx_v_n;
1316
PyObject *__pyx_r = NULL;
1317
__Pyx_RefNannyDeclarations
1318
Py_ssize_t __pyx_t_1;
1319
PyObject *__pyx_t_2 = NULL;
1320
PyObject *__pyx_t_3 = NULL;
1321
PyObject *__pyx_t_4 = NULL;
1322
PyObject *__pyx_t_5 = NULL;
1323
PyObject *__pyx_t_6 = NULL;
1324
PyObject *(*__pyx_t_7)(PyObject *);
1325
Py_ssize_t __pyx_t_8;
1326
Py_ssize_t __pyx_t_9;
1327
int __pyx_t_10;
1328
int __pyx_t_11;
1329
__Pyx_RefNannySetupContext("extend_multiplicatively", 0);
1330
1331
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":71
1332
* True
1333
* """
1334
* cdef Py_ssize_t i, B = len(a) # <<<<<<<<<<<<<<
1335
* cdef IntList P, P0
1336
* P, P0 = prime_powers_intlist(B)
1337
*/
1338
__pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_a)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 71, __pyx_L1_error)
1339
__pyx_v_B = __pyx_t_1;
1340
1341
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":73
1342
* cdef Py_ssize_t i, B = len(a)
1343
* cdef IntList P, P0
1344
* P, P0 = prime_powers_intlist(B) # <<<<<<<<<<<<<<
1345
*
1346
* # Known[n] = 1 if a[n] is set. We use this separate array
1347
*/
1348
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_prime_powers_intlist); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L1_error)
1349
__Pyx_GOTREF(__pyx_t_3);
1350
__pyx_t_4 = PyInt_FromSsize_t(__pyx_v_B); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 73, __pyx_L1_error)
1351
__Pyx_GOTREF(__pyx_t_4);
1352
__pyx_t_5 = NULL;
1353
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
1354
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
1355
if (likely(__pyx_t_5)) {
1356
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1357
__Pyx_INCREF(__pyx_t_5);
1358
__Pyx_INCREF(function);
1359
__Pyx_DECREF_SET(__pyx_t_3, function);
1360
}
1361
}
1362
if (!__pyx_t_5) {
1363
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
1364
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1365
__Pyx_GOTREF(__pyx_t_2);
1366
} else {
1367
#if CYTHON_FAST_PYCALL
1368
if (PyFunction_Check(__pyx_t_3)) {
1369
PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
1370
__pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
1371
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
1372
__Pyx_GOTREF(__pyx_t_2);
1373
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1374
} else
1375
#endif
1376
#if CYTHON_FAST_PYCCALL
1377
if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
1378
PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
1379
__pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
1380
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
1381
__Pyx_GOTREF(__pyx_t_2);
1382
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1383
} else
1384
#endif
1385
{
1386
__pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 73, __pyx_L1_error)
1387
__Pyx_GOTREF(__pyx_t_6);
1388
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
1389
__Pyx_GIVEREF(__pyx_t_4);
1390
PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
1391
__pyx_t_4 = 0;
1392
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
1393
__Pyx_GOTREF(__pyx_t_2);
1394
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1395
}
1396
}
1397
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1398
if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
1399
PyObject* sequence = __pyx_t_2;
1400
#if !CYTHON_COMPILING_IN_PYPY
1401
Py_ssize_t size = Py_SIZE(sequence);
1402
#else
1403
Py_ssize_t size = PySequence_Size(sequence);
1404
#endif
1405
if (unlikely(size != 2)) {
1406
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
1407
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
1408
__PYX_ERR(0, 73, __pyx_L1_error)
1409
}
1410
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1411
if (likely(PyTuple_CheckExact(sequence))) {
1412
__pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
1413
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
1414
} else {
1415
__pyx_t_3 = PyList_GET_ITEM(sequence, 0);
1416
__pyx_t_6 = PyList_GET_ITEM(sequence, 1);
1417
}
1418
__Pyx_INCREF(__pyx_t_3);
1419
__Pyx_INCREF(__pyx_t_6);
1420
#else
1421
__pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L1_error)
1422
__Pyx_GOTREF(__pyx_t_3);
1423
__pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 73, __pyx_L1_error)
1424
__Pyx_GOTREF(__pyx_t_6);
1425
#endif
1426
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1427
} else {
1428
Py_ssize_t index = -1;
1429
__pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 73, __pyx_L1_error)
1430
__Pyx_GOTREF(__pyx_t_4);
1431
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1432
__pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext;
1433
index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
1434
__Pyx_GOTREF(__pyx_t_3);
1435
index = 1; __pyx_t_6 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L3_unpacking_failed;
1436
__Pyx_GOTREF(__pyx_t_6);
1437
if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_4), 2) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
1438
__pyx_t_7 = NULL;
1439
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1440
goto __pyx_L4_unpacking_done;
1441
__pyx_L3_unpacking_failed:;
1442
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1443
__pyx_t_7 = NULL;
1444
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
1445
__PYX_ERR(0, 73, __pyx_L1_error)
1446
__pyx_L4_unpacking_done:;
1447
}
1448
if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4sage_5stats_7intlist_IntList))))) __PYX_ERR(0, 73, __pyx_L1_error)
1449
if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4sage_5stats_7intlist_IntList))))) __PYX_ERR(0, 73, __pyx_L1_error)
1450
__pyx_v_P = ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)__pyx_t_3);
1451
__pyx_t_3 = 0;
1452
__pyx_v_P0 = ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)__pyx_t_6);
1453
__pyx_t_6 = 0;
1454
1455
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":77
1456
* # Known[n] = 1 if a[n] is set. We use this separate array
1457
* # to avoid using a sentinel value in a.
1458
* cdef IntList known = IntList(B) # <<<<<<<<<<<<<<
1459
* for i in range(len(P)):
1460
* known._values[P[i]] = 1
1461
*/
1462
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_B); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
1463
__Pyx_GOTREF(__pyx_t_2);
1464
__pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 77, __pyx_L1_error)
1465
__Pyx_GOTREF(__pyx_t_6);
1466
__Pyx_GIVEREF(__pyx_t_2);
1467
PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
1468
__pyx_t_2 = 0;
1469
__pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4sage_5stats_7intlist_IntList), __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
1470
__Pyx_GOTREF(__pyx_t_2);
1471
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1472
__pyx_v_known = ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)__pyx_t_2);
1473
__pyx_t_2 = 0;
1474
1475
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":78
1476
* # to avoid using a sentinel value in a.
1477
* cdef IntList known = IntList(B)
1478
* for i in range(len(P)): # <<<<<<<<<<<<<<
1479
* known._values[P[i]] = 1
1480
*
1481
*/
1482
__pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_P)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 78, __pyx_L1_error)
1483
for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) {
1484
__pyx_v_i = __pyx_t_8;
1485
1486
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":79
1487
* cdef IntList known = IntList(B)
1488
* for i in range(len(P)):
1489
* known._values[P[i]] = 1 # <<<<<<<<<<<<<<
1490
*
1491
* cdef int k, pp, p, n
1492
*/
1493
__pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_P), __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)
1494
__Pyx_GOTREF(__pyx_t_2);
1495
__pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 79, __pyx_L1_error)
1496
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1497
(__pyx_v_known->_values[__pyx_t_9]) = 1;
1498
}
1499
1500
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":83
1501
* cdef int k, pp, p, n
1502
* # fill in the multiples of pp = prime power
1503
* for i in range(len(P)): # <<<<<<<<<<<<<<
1504
* pp = P._values[i]; p = P0._values[i]
1505
* k = 2
1506
*/
1507
__pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_P)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 83, __pyx_L1_error)
1508
for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) {
1509
__pyx_v_i = __pyx_t_8;
1510
1511
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":84
1512
* # fill in the multiples of pp = prime power
1513
* for i in range(len(P)):
1514
* pp = P._values[i]; p = P0._values[i] # <<<<<<<<<<<<<<
1515
* k = 2
1516
* n = k*pp
1517
*/
1518
__pyx_v_pp = (__pyx_v_P->_values[__pyx_v_i]);
1519
__pyx_v_p = (__pyx_v_P0->_values[__pyx_v_i]);
1520
1521
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":85
1522
* for i in range(len(P)):
1523
* pp = P._values[i]; p = P0._values[i]
1524
* k = 2 # <<<<<<<<<<<<<<
1525
* n = k*pp
1526
* while n < B:
1527
*/
1528
__pyx_v_k = 2;
1529
1530
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":86
1531
* pp = P._values[i]; p = P0._values[i]
1532
* k = 2
1533
* n = k*pp # <<<<<<<<<<<<<<
1534
* while n < B:
1535
* # only consider n exactly divisible by pp
1536
*/
1537
__pyx_v_n = (__pyx_v_k * __pyx_v_pp);
1538
1539
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":87
1540
* k = 2
1541
* n = k*pp
1542
* while n < B: # <<<<<<<<<<<<<<
1543
* # only consider n exactly divisible by pp
1544
* if k % p and known._values[k]:
1545
*/
1546
while (1) {
1547
__pyx_t_10 = ((__pyx_v_n < __pyx_v_B) != 0);
1548
if (!__pyx_t_10) break;
1549
1550
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":89
1551
* while n < B:
1552
* # only consider n exactly divisible by pp
1553
* if k % p and known._values[k]: # <<<<<<<<<<<<<<
1554
* a._values[n] = a._values[k] * a._values[pp]
1555
* known._values[n] = 1
1556
*/
1557
if (unlikely(__pyx_v_p == 0)) {
1558
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
1559
__PYX_ERR(0, 89, __pyx_L1_error)
1560
}
1561
__pyx_t_11 = (__Pyx_mod_int(__pyx_v_k, __pyx_v_p) != 0);
1562
if (__pyx_t_11) {
1563
} else {
1564
__pyx_t_10 = __pyx_t_11;
1565
goto __pyx_L12_bool_binop_done;
1566
}
1567
__pyx_t_11 = ((__pyx_v_known->_values[__pyx_v_k]) != 0);
1568
__pyx_t_10 = __pyx_t_11;
1569
__pyx_L12_bool_binop_done:;
1570
if (__pyx_t_10) {
1571
1572
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":90
1573
* # only consider n exactly divisible by pp
1574
* if k % p and known._values[k]:
1575
* a._values[n] = a._values[k] * a._values[pp] # <<<<<<<<<<<<<<
1576
* known._values[n] = 1
1577
* n += pp
1578
*/
1579
(__pyx_v_a->_values[__pyx_v_n]) = ((__pyx_v_a->_values[__pyx_v_k]) * (__pyx_v_a->_values[__pyx_v_pp]));
1580
1581
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":91
1582
* if k % p and known._values[k]:
1583
* a._values[n] = a._values[k] * a._values[pp]
1584
* known._values[n] = 1 # <<<<<<<<<<<<<<
1585
* n += pp
1586
* k += 1
1587
*/
1588
(__pyx_v_known->_values[__pyx_v_n]) = 1;
1589
1590
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":89
1591
* while n < B:
1592
* # only consider n exactly divisible by pp
1593
* if k % p and known._values[k]: # <<<<<<<<<<<<<<
1594
* a._values[n] = a._values[k] * a._values[pp]
1595
* known._values[n] = 1
1596
*/
1597
}
1598
1599
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":92
1600
* a._values[n] = a._values[k] * a._values[pp]
1601
* known._values[n] = 1
1602
* n += pp # <<<<<<<<<<<<<<
1603
* k += 1
1604
*
1605
*/
1606
__pyx_v_n = (__pyx_v_n + __pyx_v_pp);
1607
1608
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":93
1609
* known._values[n] = 1
1610
* n += pp
1611
* k += 1 # <<<<<<<<<<<<<<
1612
*
1613
*
1614
*/
1615
__pyx_v_k = (__pyx_v_k + 1);
1616
}
1617
}
1618
1619
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":47
1620
* return w[:i], w0[:i]
1621
*
1622
* def extend_multiplicatively(IntList a): # <<<<<<<<<<<<<<
1623
* """
1624
* Given an IntList a such that the a[p^r] is filled in, for all
1625
*/
1626
1627
/* function exit code */
1628
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
1629
goto __pyx_L0;
1630
__pyx_L1_error:;
1631
__Pyx_XDECREF(__pyx_t_2);
1632
__Pyx_XDECREF(__pyx_t_3);
1633
__Pyx_XDECREF(__pyx_t_4);
1634
__Pyx_XDECREF(__pyx_t_5);
1635
__Pyx_XDECREF(__pyx_t_6);
1636
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.helper.extend_multiplicatively", __pyx_clineno, __pyx_lineno, __pyx_filename);
1637
__pyx_r = NULL;
1638
__pyx_L0:;
1639
__Pyx_XDECREF((PyObject *)__pyx_v_P);
1640
__Pyx_XDECREF((PyObject *)__pyx_v_P0);
1641
__Pyx_XDECREF((PyObject *)__pyx_v_known);
1642
__Pyx_XGIVEREF(__pyx_r);
1643
__Pyx_RefNannyFinishContext();
1644
return __pyx_r;
1645
}
1646
1647
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":96
1648
*
1649
*
1650
* def extend_multiplicatively_generic(list a): # <<<<<<<<<<<<<<
1651
* """
1652
* Given a list a of numbers such that the a[p^r] is filled in, for
1653
*/
1654
1655
/* Python wrapper */
1656
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_5extend_multiplicatively_generic(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
1657
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_4extend_multiplicatively_generic[] = "File: helper.pyx (starting at line 96)\n\n Given a list a of numbers such that the a[p^r] is filled in, for\n all prime powers p^r, fill in all the other a[n] multiplicatively.\n\n INPUT:\n - a -- list with prime-power-index entries set; all other\n entries are ignored\n\n OUTPUT:\n - the input object a is modified to have all entries set\n via multiplicativity.\n\n EXAMPLES::\n\n sage: from psage.ellcurve.lseries.helper import extend_multiplicatively_generic\n sage: B = 10^5; E = EllipticCurve('389a'); an = [0]*B\n sage: for pp in prime_powers(B):\n ... an[pp] = E.an(pp)\n ...\n sage: extend_multiplicatively_generic(an)\n sage: list(an) == E.anlist(len(an))[:len(an)]\n True\n\n\n A test using large integers::\n \n sage: v = [0, 1, 2**100, 3**100, 4, 5, 0]\n sage: extend_multiplicatively_generic(v)\n sage: v\n [0, 1, 1267650600228229401496703205376, 515377520732011331036461129765621272702107522001, 4, 5, 653318623500070906096690267158057820537143710472954871543071966369497141477376]\n sage: v[-1] == v[2]*v[3]\n True\n\n A test using variables::\n\n sage: v = list(var(' '.join('x%s'%i for i in [0..30]))); v\n [x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x30]\n sage: extend_multiplicatively_generic(v)\n sage: v\n [x0, x1, x2, x3, x4, x5, x2*x3, x7, x8, x9, x2*x5, x11, x3*x4, x13, x2*x7, x3*x5, x16, x17, x2*x9, x19, x4*x5, x3*x7, x11*x2, x23, x3*x8, x25, x13*x2, x27, x4*x7, x29, x2*x3*x5]\n ";
1658
static PyMethodDef __pyx_mdef_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_5extend_multiplicatively_generic = {"extend_multiplicatively_generic", (PyCFunction)__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_5extend_multiplicatively_generic, METH_O, __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_4extend_multiplicatively_generic};
1659
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_5extend_multiplicatively_generic(PyObject *__pyx_self, PyObject *__pyx_v_a) {
1660
PyObject *__pyx_r = 0;
1661
__Pyx_RefNannyDeclarations
1662
__Pyx_RefNannySetupContext("extend_multiplicatively_generic (wrapper)", 0);
1663
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), (&PyList_Type), 1, "a", 1))) __PYX_ERR(0, 96, __pyx_L1_error)
1664
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_4extend_multiplicatively_generic(__pyx_self, ((PyObject*)__pyx_v_a));
1665
1666
/* function exit code */
1667
goto __pyx_L0;
1668
__pyx_L1_error:;
1669
__pyx_r = NULL;
1670
__pyx_L0:;
1671
__Pyx_RefNannyFinishContext();
1672
return __pyx_r;
1673
}
1674
1675
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_4extend_multiplicatively_generic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a) {
1676
Py_ssize_t __pyx_v_i;
1677
Py_ssize_t __pyx_v_B;
1678
struct __pyx_obj_4sage_5stats_7intlist_IntList *__pyx_v_P = 0;
1679
struct __pyx_obj_4sage_5stats_7intlist_IntList *__pyx_v_P0 = 0;
1680
struct __pyx_obj_4sage_5stats_7intlist_IntList *__pyx_v_known = 0;
1681
int __pyx_v_k;
1682
int __pyx_v_pp;
1683
int __pyx_v_p;
1684
int __pyx_v_n;
1685
PyObject *__pyx_r = NULL;
1686
__Pyx_RefNannyDeclarations
1687
Py_ssize_t __pyx_t_1;
1688
PyObject *__pyx_t_2 = NULL;
1689
PyObject *__pyx_t_3 = NULL;
1690
PyObject *__pyx_t_4 = NULL;
1691
PyObject *__pyx_t_5 = NULL;
1692
PyObject *__pyx_t_6 = NULL;
1693
PyObject *(*__pyx_t_7)(PyObject *);
1694
Py_ssize_t __pyx_t_8;
1695
Py_ssize_t __pyx_t_9;
1696
int __pyx_t_10;
1697
int __pyx_t_11;
1698
__Pyx_RefNannySetupContext("extend_multiplicatively_generic", 0);
1699
1700
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":138
1701
* [x0, x1, x2, x3, x4, x5, x2*x3, x7, x8, x9, x2*x5, x11, x3*x4, x13, x2*x7, x3*x5, x16, x17, x2*x9, x19, x4*x5, x3*x7, x11*x2, x23, x3*x8, x25, x13*x2, x27, x4*x7, x29, x2*x3*x5]
1702
* """
1703
* cdef Py_ssize_t i, B = len(a) # <<<<<<<<<<<<<<
1704
* cdef IntList P, P0
1705
* P, P0 = prime_powers_intlist(B)
1706
*/
1707
if (unlikely(__pyx_v_a == Py_None)) {
1708
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
1709
__PYX_ERR(0, 138, __pyx_L1_error)
1710
}
1711
__pyx_t_1 = PyList_GET_SIZE(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 138, __pyx_L1_error)
1712
__pyx_v_B = __pyx_t_1;
1713
1714
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":140
1715
* cdef Py_ssize_t i, B = len(a)
1716
* cdef IntList P, P0
1717
* P, P0 = prime_powers_intlist(B) # <<<<<<<<<<<<<<
1718
*
1719
* # Known[n] = 1 if a[n] is set. We use this separate array
1720
*/
1721
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_prime_powers_intlist); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
1722
__Pyx_GOTREF(__pyx_t_3);
1723
__pyx_t_4 = PyInt_FromSsize_t(__pyx_v_B); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
1724
__Pyx_GOTREF(__pyx_t_4);
1725
__pyx_t_5 = NULL;
1726
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
1727
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
1728
if (likely(__pyx_t_5)) {
1729
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1730
__Pyx_INCREF(__pyx_t_5);
1731
__Pyx_INCREF(function);
1732
__Pyx_DECREF_SET(__pyx_t_3, function);
1733
}
1734
}
1735
if (!__pyx_t_5) {
1736
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
1737
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1738
__Pyx_GOTREF(__pyx_t_2);
1739
} else {
1740
#if CYTHON_FAST_PYCALL
1741
if (PyFunction_Check(__pyx_t_3)) {
1742
PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
1743
__pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
1744
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
1745
__Pyx_GOTREF(__pyx_t_2);
1746
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1747
} else
1748
#endif
1749
#if CYTHON_FAST_PYCCALL
1750
if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
1751
PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
1752
__pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
1753
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
1754
__Pyx_GOTREF(__pyx_t_2);
1755
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1756
} else
1757
#endif
1758
{
1759
__pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 140, __pyx_L1_error)
1760
__Pyx_GOTREF(__pyx_t_6);
1761
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
1762
__Pyx_GIVEREF(__pyx_t_4);
1763
PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
1764
__pyx_t_4 = 0;
1765
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
1766
__Pyx_GOTREF(__pyx_t_2);
1767
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1768
}
1769
}
1770
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1771
if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
1772
PyObject* sequence = __pyx_t_2;
1773
#if !CYTHON_COMPILING_IN_PYPY
1774
Py_ssize_t size = Py_SIZE(sequence);
1775
#else
1776
Py_ssize_t size = PySequence_Size(sequence);
1777
#endif
1778
if (unlikely(size != 2)) {
1779
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
1780
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
1781
__PYX_ERR(0, 140, __pyx_L1_error)
1782
}
1783
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1784
if (likely(PyTuple_CheckExact(sequence))) {
1785
__pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
1786
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
1787
} else {
1788
__pyx_t_3 = PyList_GET_ITEM(sequence, 0);
1789
__pyx_t_6 = PyList_GET_ITEM(sequence, 1);
1790
}
1791
__Pyx_INCREF(__pyx_t_3);
1792
__Pyx_INCREF(__pyx_t_6);
1793
#else
1794
__pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
1795
__Pyx_GOTREF(__pyx_t_3);
1796
__pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 140, __pyx_L1_error)
1797
__Pyx_GOTREF(__pyx_t_6);
1798
#endif
1799
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1800
} else {
1801
Py_ssize_t index = -1;
1802
__pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
1803
__Pyx_GOTREF(__pyx_t_4);
1804
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1805
__pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext;
1806
index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
1807
__Pyx_GOTREF(__pyx_t_3);
1808
index = 1; __pyx_t_6 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L3_unpacking_failed;
1809
__Pyx_GOTREF(__pyx_t_6);
1810
if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_4), 2) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
1811
__pyx_t_7 = NULL;
1812
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1813
goto __pyx_L4_unpacking_done;
1814
__pyx_L3_unpacking_failed:;
1815
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1816
__pyx_t_7 = NULL;
1817
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
1818
__PYX_ERR(0, 140, __pyx_L1_error)
1819
__pyx_L4_unpacking_done:;
1820
}
1821
if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4sage_5stats_7intlist_IntList))))) __PYX_ERR(0, 140, __pyx_L1_error)
1822
if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4sage_5stats_7intlist_IntList))))) __PYX_ERR(0, 140, __pyx_L1_error)
1823
__pyx_v_P = ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)__pyx_t_3);
1824
__pyx_t_3 = 0;
1825
__pyx_v_P0 = ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)__pyx_t_6);
1826
__pyx_t_6 = 0;
1827
1828
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":144
1829
* # Known[n] = 1 if a[n] is set. We use this separate array
1830
* # to avoid using a sentinel value in a.
1831
* cdef IntList known = IntList(B) # <<<<<<<<<<<<<<
1832
* for i in range(len(P)):
1833
* known._values[P[i]] = 1
1834
*/
1835
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_B); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
1836
__Pyx_GOTREF(__pyx_t_2);
1837
__pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 144, __pyx_L1_error)
1838
__Pyx_GOTREF(__pyx_t_6);
1839
__Pyx_GIVEREF(__pyx_t_2);
1840
PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
1841
__pyx_t_2 = 0;
1842
__pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4sage_5stats_7intlist_IntList), __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
1843
__Pyx_GOTREF(__pyx_t_2);
1844
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1845
__pyx_v_known = ((struct __pyx_obj_4sage_5stats_7intlist_IntList *)__pyx_t_2);
1846
__pyx_t_2 = 0;
1847
1848
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":145
1849
* # to avoid using a sentinel value in a.
1850
* cdef IntList known = IntList(B)
1851
* for i in range(len(P)): # <<<<<<<<<<<<<<
1852
* known._values[P[i]] = 1
1853
*
1854
*/
1855
__pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_P)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 145, __pyx_L1_error)
1856
for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) {
1857
__pyx_v_i = __pyx_t_8;
1858
1859
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":146
1860
* cdef IntList known = IntList(B)
1861
* for i in range(len(P)):
1862
* known._values[P[i]] = 1 # <<<<<<<<<<<<<<
1863
*
1864
* cdef int k, pp, p, n
1865
*/
1866
__pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_P), __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error)
1867
__Pyx_GOTREF(__pyx_t_2);
1868
__pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 146, __pyx_L1_error)
1869
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1870
(__pyx_v_known->_values[__pyx_t_9]) = 1;
1871
}
1872
1873
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":150
1874
* cdef int k, pp, p, n
1875
* # fill in the multiples of pp = prime power
1876
* for i in range(len(P)): # <<<<<<<<<<<<<<
1877
* pp = P._values[i]; p = P0._values[i]
1878
* k = 2
1879
*/
1880
__pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_P)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 150, __pyx_L1_error)
1881
for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) {
1882
__pyx_v_i = __pyx_t_8;
1883
1884
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":151
1885
* # fill in the multiples of pp = prime power
1886
* for i in range(len(P)):
1887
* pp = P._values[i]; p = P0._values[i] # <<<<<<<<<<<<<<
1888
* k = 2
1889
* n = k*pp
1890
*/
1891
__pyx_v_pp = (__pyx_v_P->_values[__pyx_v_i]);
1892
__pyx_v_p = (__pyx_v_P0->_values[__pyx_v_i]);
1893
1894
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":152
1895
* for i in range(len(P)):
1896
* pp = P._values[i]; p = P0._values[i]
1897
* k = 2 # <<<<<<<<<<<<<<
1898
* n = k*pp
1899
* while n < B:
1900
*/
1901
__pyx_v_k = 2;
1902
1903
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":153
1904
* pp = P._values[i]; p = P0._values[i]
1905
* k = 2
1906
* n = k*pp # <<<<<<<<<<<<<<
1907
* while n < B:
1908
* # only consider n exactly divisible by pp
1909
*/
1910
__pyx_v_n = (__pyx_v_k * __pyx_v_pp);
1911
1912
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":154
1913
* k = 2
1914
* n = k*pp
1915
* while n < B: # <<<<<<<<<<<<<<
1916
* # only consider n exactly divisible by pp
1917
* if k % p and known._values[k]:
1918
*/
1919
while (1) {
1920
__pyx_t_10 = ((__pyx_v_n < __pyx_v_B) != 0);
1921
if (!__pyx_t_10) break;
1922
1923
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":156
1924
* while n < B:
1925
* # only consider n exactly divisible by pp
1926
* if k % p and known._values[k]: # <<<<<<<<<<<<<<
1927
* a[n] = a[k] * a[pp]
1928
* known._values[n] = 1
1929
*/
1930
if (unlikely(__pyx_v_p == 0)) {
1931
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
1932
__PYX_ERR(0, 156, __pyx_L1_error)
1933
}
1934
__pyx_t_11 = (__Pyx_mod_int(__pyx_v_k, __pyx_v_p) != 0);
1935
if (__pyx_t_11) {
1936
} else {
1937
__pyx_t_10 = __pyx_t_11;
1938
goto __pyx_L12_bool_binop_done;
1939
}
1940
__pyx_t_11 = ((__pyx_v_known->_values[__pyx_v_k]) != 0);
1941
__pyx_t_10 = __pyx_t_11;
1942
__pyx_L12_bool_binop_done:;
1943
if (__pyx_t_10) {
1944
1945
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":157
1946
* # only consider n exactly divisible by pp
1947
* if k % p and known._values[k]:
1948
* a[n] = a[k] * a[pp] # <<<<<<<<<<<<<<
1949
* known._values[n] = 1
1950
* n += pp
1951
*/
1952
if (unlikely(__pyx_v_a == Py_None)) {
1953
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
1954
__PYX_ERR(0, 157, __pyx_L1_error)
1955
}
1956
__pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_a, __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error)
1957
__Pyx_GOTREF(__pyx_t_2);
1958
if (unlikely(__pyx_v_a == Py_None)) {
1959
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
1960
__PYX_ERR(0, 157, __pyx_L1_error)
1961
}
1962
__pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_a, __pyx_v_pp, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 157, __pyx_L1_error)
1963
__Pyx_GOTREF(__pyx_t_6);
1964
__pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error)
1965
__Pyx_GOTREF(__pyx_t_3);
1966
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1967
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1968
if (unlikely(__pyx_v_a == Py_None)) {
1969
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
1970
__PYX_ERR(0, 157, __pyx_L1_error)
1971
}
1972
if (unlikely(__Pyx_SetItemInt(__pyx_v_a, __pyx_v_n, __pyx_t_3, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0)) __PYX_ERR(0, 157, __pyx_L1_error)
1973
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1974
1975
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":158
1976
* if k % p and known._values[k]:
1977
* a[n] = a[k] * a[pp]
1978
* known._values[n] = 1 # <<<<<<<<<<<<<<
1979
* n += pp
1980
* k += 1
1981
*/
1982
(__pyx_v_known->_values[__pyx_v_n]) = 1;
1983
1984
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":156
1985
* while n < B:
1986
* # only consider n exactly divisible by pp
1987
* if k % p and known._values[k]: # <<<<<<<<<<<<<<
1988
* a[n] = a[k] * a[pp]
1989
* known._values[n] = 1
1990
*/
1991
}
1992
1993
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":159
1994
* a[n] = a[k] * a[pp]
1995
* known._values[n] = 1
1996
* n += pp # <<<<<<<<<<<<<<
1997
* k += 1
1998
*
1999
*/
2000
__pyx_v_n = (__pyx_v_n + __pyx_v_pp);
2001
2002
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":160
2003
* known._values[n] = 1
2004
* n += pp
2005
* k += 1 # <<<<<<<<<<<<<<
2006
*
2007
*
2008
*/
2009
__pyx_v_k = (__pyx_v_k + 1);
2010
}
2011
}
2012
2013
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":96
2014
*
2015
*
2016
* def extend_multiplicatively_generic(list a): # <<<<<<<<<<<<<<
2017
* """
2018
* Given a list a of numbers such that the a[p^r] is filled in, for
2019
*/
2020
2021
/* function exit code */
2022
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
2023
goto __pyx_L0;
2024
__pyx_L1_error:;
2025
__Pyx_XDECREF(__pyx_t_2);
2026
__Pyx_XDECREF(__pyx_t_3);
2027
__Pyx_XDECREF(__pyx_t_4);
2028
__Pyx_XDECREF(__pyx_t_5);
2029
__Pyx_XDECREF(__pyx_t_6);
2030
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.lseries.helper.extend_multiplicatively_generic", __pyx_clineno, __pyx_lineno, __pyx_filename);
2031
__pyx_r = NULL;
2032
__pyx_L0:;
2033
__Pyx_XDECREF((PyObject *)__pyx_v_P);
2034
__Pyx_XDECREF((PyObject *)__pyx_v_P0);
2035
__Pyx_XDECREF((PyObject *)__pyx_v_known);
2036
__Pyx_XGIVEREF(__pyx_r);
2037
__Pyx_RefNannyFinishContext();
2038
return __pyx_r;
2039
}
2040
2041
static PyMethodDef __pyx_methods[] = {
2042
{0, 0, 0, 0}
2043
};
2044
2045
#if PY_MAJOR_VERSION >= 3
2046
static struct PyModuleDef __pyx_moduledef = {
2047
#if PY_VERSION_HEX < 0x03020000
2048
{ PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
2049
#else
2050
PyModuleDef_HEAD_INIT,
2051
#endif
2052
"helper",
2053
__pyx_k_File_helper_pyx_starting_at_line, /* m_doc */
2054
-1, /* m_size */
2055
__pyx_methods /* m_methods */,
2056
NULL, /* m_reload */
2057
NULL, /* m_traverse */
2058
NULL, /* m_clear */
2059
NULL /* m_free */
2060
};
2061
#endif
2062
2063
static __Pyx_StringTabEntry __pyx_string_tab[] = {
2064
{&__pyx_n_s_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 0, 1, 1},
2065
{&__pyx_n_s_P, __pyx_k_P, sizeof(__pyx_k_P), 0, 0, 1, 1},
2066
{&__pyx_n_s_P0, __pyx_k_P0, sizeof(__pyx_k_P0), 0, 0, 1, 1},
2067
{&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
2068
{&__pyx_n_s_code_alex_psage_psage_ellcurve_l, __pyx_k_code_alex_psage_psage_ellcurve_l, sizeof(__pyx_k_code_alex_psage_psage_ellcurve_l), 0, 0, 1, 1},
2069
{&__pyx_n_s_extend_multiplicatively, __pyx_k_extend_multiplicatively, sizeof(__pyx_k_extend_multiplicatively), 0, 0, 1, 1},
2070
{&__pyx_n_s_extend_multiplicatively_generic, __pyx_k_extend_multiplicatively_generic, sizeof(__pyx_k_extend_multiplicatively_generic), 0, 0, 1, 1},
2071
{&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
2072
{&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
2073
{&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
2074
{&__pyx_n_s_known, __pyx_k_known, sizeof(__pyx_k_known), 0, 0, 1, 1},
2075
{&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
2076
{&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
2077
{&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1},
2078
{&__pyx_n_s_pp, __pyx_k_pp, sizeof(__pyx_k_pp), 0, 0, 1, 1},
2079
{&__pyx_n_s_prime_powers_intlist, __pyx_k_prime_powers_intlist, sizeof(__pyx_k_prime_powers_intlist), 0, 0, 1, 1},
2080
{&__pyx_n_s_prime_range, __pyx_k_prime_range, sizeof(__pyx_k_prime_range), 0, 0, 1, 1},
2081
{&__pyx_kp_s_projects_68c8b2b8_03ba_44d4_a0d, __pyx_k_projects_68c8b2b8_03ba_44d4_a0d, sizeof(__pyx_k_projects_68c8b2b8_03ba_44d4_a0d), 0, 0, 1, 0},
2082
{&__pyx_n_s_py_ints, __pyx_k_py_ints, sizeof(__pyx_k_py_ints), 0, 0, 1, 1},
2083
{&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
2084
{&__pyx_n_s_q, __pyx_k_q, sizeof(__pyx_k_q), 0, 0, 1, 1},
2085
{&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
2086
{&__pyx_n_s_sage_all, __pyx_k_sage_all, sizeof(__pyx_k_sage_all), 0, 0, 1, 1},
2087
{&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
2088
{&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
2089
{&__pyx_n_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1},
2090
{&__pyx_n_s_w0, __pyx_k_w0, sizeof(__pyx_k_w0), 0, 0, 1, 1},
2091
{0, 0, 0, 0, 0, 0, 0}
2092
};
2093
static int __Pyx_InitCachedBuiltins(void) {
2094
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 78, __pyx_L1_error)
2095
return 0;
2096
__pyx_L1_error:;
2097
return -1;
2098
}
2099
2100
static int __Pyx_InitCachedConstants(void) {
2101
__Pyx_RefNannyDeclarations
2102
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
2103
2104
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":6
2105
* from sage.all import prime_range
2106
*
2107
* def prime_powers_intlist(Py_ssize_t B): # <<<<<<<<<<<<<<
2108
* """
2109
* Return IntList of the prime powers and corresponding primes, up to
2110
*/
2111
__pyx_tuple_ = PyTuple_Pack(8, __pyx_n_s_B, __pyx_n_s_B, __pyx_n_s_v, __pyx_n_s_w, __pyx_n_s_w0, __pyx_n_s_i, __pyx_n_s_p, __pyx_n_s_q); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 6, __pyx_L1_error)
2112
__Pyx_GOTREF(__pyx_tuple_);
2113
__Pyx_GIVEREF(__pyx_tuple_);
2114
__pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_projects_68c8b2b8_03ba_44d4_a0d, __pyx_n_s_prime_powers_intlist, 6, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 6, __pyx_L1_error)
2115
2116
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":47
2117
* return w[:i], w0[:i]
2118
*
2119
* def extend_multiplicatively(IntList a): # <<<<<<<<<<<<<<
2120
* """
2121
* Given an IntList a such that the a[p^r] is filled in, for all
2122
*/
2123
__pyx_tuple__3 = PyTuple_Pack(10, __pyx_n_s_a, __pyx_n_s_i, __pyx_n_s_B, __pyx_n_s_P, __pyx_n_s_P0, __pyx_n_s_known, __pyx_n_s_k, __pyx_n_s_pp, __pyx_n_s_p, __pyx_n_s_n); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 47, __pyx_L1_error)
2124
__Pyx_GOTREF(__pyx_tuple__3);
2125
__Pyx_GIVEREF(__pyx_tuple__3);
2126
__pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_projects_68c8b2b8_03ba_44d4_a0d, __pyx_n_s_extend_multiplicatively, 47, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 47, __pyx_L1_error)
2127
2128
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":96
2129
*
2130
*
2131
* def extend_multiplicatively_generic(list a): # <<<<<<<<<<<<<<
2132
* """
2133
* Given a list a of numbers such that the a[p^r] is filled in, for
2134
*/
2135
__pyx_tuple__5 = PyTuple_Pack(10, __pyx_n_s_a, __pyx_n_s_i, __pyx_n_s_B, __pyx_n_s_P, __pyx_n_s_P0, __pyx_n_s_known, __pyx_n_s_k, __pyx_n_s_pp, __pyx_n_s_p, __pyx_n_s_n); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 96, __pyx_L1_error)
2136
__Pyx_GOTREF(__pyx_tuple__5);
2137
__Pyx_GIVEREF(__pyx_tuple__5);
2138
__pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_projects_68c8b2b8_03ba_44d4_a0d, __pyx_n_s_extend_multiplicatively_generic, 96, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 96, __pyx_L1_error)
2139
__Pyx_RefNannyFinishContext();
2140
return 0;
2141
__pyx_L1_error:;
2142
__Pyx_RefNannyFinishContext();
2143
return -1;
2144
}
2145
2146
static int __Pyx_InitGlobals(void) {
2147
if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 2, __pyx_L1_error);
2148
__pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 2, __pyx_L1_error)
2149
return 0;
2150
__pyx_L1_error:;
2151
return -1;
2152
}
2153
2154
#if PY_MAJOR_VERSION < 3
2155
PyMODINIT_FUNC inithelper(void); /*proto*/
2156
PyMODINIT_FUNC inithelper(void)
2157
#else
2158
PyMODINIT_FUNC PyInit_helper(void); /*proto*/
2159
PyMODINIT_FUNC PyInit_helper(void)
2160
#endif
2161
{
2162
PyObject *__pyx_t_1 = NULL;
2163
PyObject *__pyx_t_2 = NULL;
2164
__Pyx_RefNannyDeclarations
2165
#if CYTHON_REFNANNY
2166
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
2167
if (!__Pyx_RefNanny) {
2168
PyErr_Clear();
2169
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
2170
if (!__Pyx_RefNanny)
2171
Py_FatalError("failed to import 'refnanny' module");
2172
}
2173
#endif
2174
__Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_helper(void)", 0);
2175
if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2176
__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 2, __pyx_L1_error)
2177
__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 2, __pyx_L1_error)
2178
__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 2, __pyx_L1_error)
2179
#ifdef __Pyx_CyFunction_USED
2180
if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2181
#endif
2182
#ifdef __Pyx_FusedFunction_USED
2183
if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2184
#endif
2185
#ifdef __Pyx_Coroutine_USED
2186
if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2187
#endif
2188
#ifdef __Pyx_Generator_USED
2189
if (__pyx_Generator_init() < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2190
#endif
2191
#ifdef __Pyx_StopAsyncIteration_USED
2192
if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2193
#endif
2194
/*--- Library function declarations ---*/
2195
/*--- Threads initialization code ---*/
2196
#if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
2197
#ifdef WITH_THREAD /* Python build with threading support? */
2198
PyEval_InitThreads();
2199
#endif
2200
#endif
2201
/*--- Module creation code ---*/
2202
#if PY_MAJOR_VERSION < 3
2203
__pyx_m = Py_InitModule4("helper", __pyx_methods, __pyx_k_File_helper_pyx_starting_at_line, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
2204
#else
2205
__pyx_m = PyModule_Create(&__pyx_moduledef);
2206
#endif
2207
if (unlikely(!__pyx_m)) __PYX_ERR(0, 2, __pyx_L1_error)
2208
__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 2, __pyx_L1_error)
2209
Py_INCREF(__pyx_d);
2210
__pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 2, __pyx_L1_error)
2211
#if CYTHON_COMPILING_IN_PYPY
2212
Py_INCREF(__pyx_b);
2213
#endif
2214
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 2, __pyx_L1_error);
2215
/*--- Initialize various global constants etc. ---*/
2216
if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2217
#if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
2218
if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2219
#endif
2220
if (__pyx_module_is_main_code__alex__psage__psage__ellcurve__lseries__helper) {
2221
if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2222
}
2223
#if PY_MAJOR_VERSION >= 3
2224
{
2225
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 2, __pyx_L1_error)
2226
if (!PyDict_GetItemString(modules, "code.alex.psage.psage.ellcurve.lseries.helper")) {
2227
if (unlikely(PyDict_SetItemString(modules, "code.alex.psage.psage.ellcurve.lseries.helper", __pyx_m) < 0)) __PYX_ERR(0, 2, __pyx_L1_error)
2228
}
2229
}
2230
#endif
2231
/*--- Builtin init code ---*/
2232
if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2233
/*--- Constants init code ---*/
2234
if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2235
/*--- Global init code ---*/
2236
/*--- Variable export code ---*/
2237
/*--- Function export code ---*/
2238
/*--- Type init code ---*/
2239
/*--- Type import code ---*/
2240
__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(1, 8, __pyx_L1_error)
2241
__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(1, 8, __pyx_L1_error)
2242
/*--- Variable import code ---*/
2243
/*--- Function import code ---*/
2244
/*--- Execution code ---*/
2245
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
2246
if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2247
#endif
2248
2249
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":4
2250
* from sage.stats.intlist cimport IntList
2251
*
2252
* from sage.all import prime_range # <<<<<<<<<<<<<<
2253
*
2254
* def prime_powers_intlist(Py_ssize_t B):
2255
*/
2256
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
2257
__Pyx_GOTREF(__pyx_t_1);
2258
__Pyx_INCREF(__pyx_n_s_prime_range);
2259
__Pyx_GIVEREF(__pyx_n_s_prime_range);
2260
PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_prime_range);
2261
__pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_all, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error)
2262
__Pyx_GOTREF(__pyx_t_2);
2263
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2264
__pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_prime_range); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
2265
__Pyx_GOTREF(__pyx_t_1);
2266
if (PyDict_SetItem(__pyx_d, __pyx_n_s_prime_range, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
2267
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2268
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2269
2270
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":6
2271
* from sage.all import prime_range
2272
*
2273
* def prime_powers_intlist(Py_ssize_t B): # <<<<<<<<<<<<<<
2274
* """
2275
* Return IntList of the prime powers and corresponding primes, up to
2276
*/
2277
__pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_1prime_powers_intlist, NULL, __pyx_n_s_code_alex_psage_psage_ellcurve_l); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error)
2278
__Pyx_GOTREF(__pyx_t_2);
2279
if (PyDict_SetItem(__pyx_d, __pyx_n_s_prime_powers_intlist, __pyx_t_2) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
2280
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2281
2282
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":47
2283
* return w[:i], w0[:i]
2284
*
2285
* def extend_multiplicatively(IntList a): # <<<<<<<<<<<<<<
2286
* """
2287
* Given an IntList a such that the a[p^r] is filled in, for all
2288
*/
2289
__pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_3extend_multiplicatively, NULL, __pyx_n_s_code_alex_psage_psage_ellcurve_l); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error)
2290
__Pyx_GOTREF(__pyx_t_2);
2291
if (PyDict_SetItem(__pyx_d, __pyx_n_s_extend_multiplicatively, __pyx_t_2) < 0) __PYX_ERR(0, 47, __pyx_L1_error)
2292
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2293
2294
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":96
2295
*
2296
*
2297
* def extend_multiplicatively_generic(list a): # <<<<<<<<<<<<<<
2298
* """
2299
* Given a list a of numbers such that the a[p^r] is filled in, for
2300
*/
2301
__pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4code_4alex_5psage_5psage_8ellcurve_7lseries_6helper_5extend_multiplicatively_generic, NULL, __pyx_n_s_code_alex_psage_psage_ellcurve_l); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
2302
__Pyx_GOTREF(__pyx_t_2);
2303
if (PyDict_SetItem(__pyx_d, __pyx_n_s_extend_multiplicatively_generic, __pyx_t_2) < 0) __PYX_ERR(0, 96, __pyx_L1_error)
2304
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2305
2306
/* "code/alex/psage/psage/ellcurve/lseries/helper.pyx":2
2307
*
2308
* from sage.stats.intlist cimport IntList # <<<<<<<<<<<<<<
2309
*
2310
* from sage.all import prime_range
2311
*/
2312
__pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2, __pyx_L1_error)
2313
__Pyx_GOTREF(__pyx_t_2);
2314
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
2315
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2316
2317
/*--- Wrapped vars code ---*/
2318
2319
goto __pyx_L0;
2320
__pyx_L1_error:;
2321
__Pyx_XDECREF(__pyx_t_1);
2322
__Pyx_XDECREF(__pyx_t_2);
2323
if (__pyx_m) {
2324
if (__pyx_d) {
2325
__Pyx_AddTraceback("init code.alex.psage.psage.ellcurve.lseries.helper", __pyx_clineno, __pyx_lineno, __pyx_filename);
2326
}
2327
Py_DECREF(__pyx_m); __pyx_m = 0;
2328
} else if (!PyErr_Occurred()) {
2329
PyErr_SetString(PyExc_ImportError, "init code.alex.psage.psage.ellcurve.lseries.helper");
2330
}
2331
__pyx_L0:;
2332
__Pyx_RefNannyFinishContext();
2333
#if PY_MAJOR_VERSION < 3
2334
return;
2335
#else
2336
return __pyx_m;
2337
#endif
2338
}
2339
2340
/* --- Runtime support code --- */
2341
/* Refnanny */
2342
#if CYTHON_REFNANNY
2343
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
2344
PyObject *m = NULL, *p = NULL;
2345
void *r = NULL;
2346
m = PyImport_ImportModule((char *)modname);
2347
if (!m) goto end;
2348
p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
2349
if (!p) goto end;
2350
r = PyLong_AsVoidPtr(p);
2351
end:
2352
Py_XDECREF(p);
2353
Py_XDECREF(m);
2354
return (__Pyx_RefNannyAPIStruct *)r;
2355
}
2356
#endif
2357
2358
/* GetBuiltinName */
2359
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
2360
PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
2361
if (unlikely(!result)) {
2362
PyErr_Format(PyExc_NameError,
2363
#if PY_MAJOR_VERSION >= 3
2364
"name '%U' is not defined", name);
2365
#else
2366
"name '%.200s' is not defined", PyString_AS_STRING(name));
2367
#endif
2368
}
2369
return result;
2370
}
2371
2372
/* GetModuleGlobalName */
2373
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
2374
PyObject *result;
2375
#if !CYTHON_AVOID_BORROWED_REFS
2376
result = PyDict_GetItem(__pyx_d, name);
2377
if (likely(result)) {
2378
Py_INCREF(result);
2379
} else {
2380
#else
2381
result = PyObject_GetItem(__pyx_d, name);
2382
if (!result) {
2383
PyErr_Clear();
2384
#endif
2385
result = __Pyx_GetBuiltinName(name);
2386
}
2387
return result;
2388
}
2389
2390
/* PyObjectCall */
2391
#if CYTHON_COMPILING_IN_CPYTHON
2392
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
2393
PyObject *result;
2394
ternaryfunc call = func->ob_type->tp_call;
2395
if (unlikely(!call))
2396
return PyObject_Call(func, arg, kw);
2397
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
2398
return NULL;
2399
result = (*call)(func, arg, kw);
2400
Py_LeaveRecursiveCall();
2401
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2402
PyErr_SetString(
2403
PyExc_SystemError,
2404
"NULL result without error in PyObject_Call");
2405
}
2406
return result;
2407
}
2408
#endif
2409
2410
/* SetItemInt */
2411
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
2412
int r;
2413
if (!j) return -1;
2414
r = PyObject_SetItem(o, j, v);
2415
Py_DECREF(j);
2416
return r;
2417
}
2418
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
2419
CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
2420
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
2421
if (is_list || PyList_CheckExact(o)) {
2422
Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
2423
if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
2424
PyObject* old = PyList_GET_ITEM(o, n);
2425
Py_INCREF(v);
2426
PyList_SET_ITEM(o, n, v);
2427
Py_DECREF(old);
2428
return 1;
2429
}
2430
} else {
2431
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
2432
if (likely(m && m->sq_ass_item)) {
2433
if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
2434
Py_ssize_t l = m->sq_length(o);
2435
if (likely(l >= 0)) {
2436
i += l;
2437
} else {
2438
if (!PyErr_ExceptionMatches(PyExc_OverflowError))
2439
return -1;
2440
PyErr_Clear();
2441
}
2442
}
2443
return m->sq_ass_item(o, i, v);
2444
}
2445
}
2446
#else
2447
#if CYTHON_COMPILING_IN_PYPY
2448
if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
2449
#else
2450
if (is_list || PySequence_Check(o)) {
2451
#endif
2452
return PySequence_SetItem(o, i, v);
2453
}
2454
#endif
2455
return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
2456
}
2457
2458
/* SliceObject */
2459
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
2460
Py_ssize_t cstart, Py_ssize_t cstop,
2461
PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
2462
int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
2463
#if CYTHON_USE_TYPE_SLOTS
2464
PyMappingMethods* mp;
2465
#if PY_MAJOR_VERSION < 3
2466
PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
2467
if (likely(ms && ms->sq_slice)) {
2468
if (!has_cstart) {
2469
if (_py_start && (*_py_start != Py_None)) {
2470
cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
2471
if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
2472
} else
2473
cstart = 0;
2474
}
2475
if (!has_cstop) {
2476
if (_py_stop && (*_py_stop != Py_None)) {
2477
cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
2478
if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
2479
} else
2480
cstop = PY_SSIZE_T_MAX;
2481
}
2482
if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
2483
Py_ssize_t l = ms->sq_length(obj);
2484
if (likely(l >= 0)) {
2485
if (cstop < 0) {
2486
cstop += l;
2487
if (cstop < 0) cstop = 0;
2488
}
2489
if (cstart < 0) {
2490
cstart += l;
2491
if (cstart < 0) cstart = 0;
2492
}
2493
} else {
2494
if (!PyErr_ExceptionMatches(PyExc_OverflowError))
2495
goto bad;
2496
PyErr_Clear();
2497
}
2498
}
2499
return ms->sq_slice(obj, cstart, cstop);
2500
}
2501
#endif
2502
mp = Py_TYPE(obj)->tp_as_mapping;
2503
if (likely(mp && mp->mp_subscript))
2504
#endif
2505
{
2506
PyObject* result;
2507
PyObject *py_slice, *py_start, *py_stop;
2508
if (_py_slice) {
2509
py_slice = *_py_slice;
2510
} else {
2511
PyObject* owned_start = NULL;
2512
PyObject* owned_stop = NULL;
2513
if (_py_start) {
2514
py_start = *_py_start;
2515
} else {
2516
if (has_cstart) {
2517
owned_start = py_start = PyInt_FromSsize_t(cstart);
2518
if (unlikely(!py_start)) goto bad;
2519
} else
2520
py_start = Py_None;
2521
}
2522
if (_py_stop) {
2523
py_stop = *_py_stop;
2524
} else {
2525
if (has_cstop) {
2526
owned_stop = py_stop = PyInt_FromSsize_t(cstop);
2527
if (unlikely(!py_stop)) {
2528
Py_XDECREF(owned_start);
2529
goto bad;
2530
}
2531
} else
2532
py_stop = Py_None;
2533
}
2534
py_slice = PySlice_New(py_start, py_stop, Py_None);
2535
Py_XDECREF(owned_start);
2536
Py_XDECREF(owned_stop);
2537
if (unlikely(!py_slice)) goto bad;
2538
}
2539
#if CYTHON_USE_TYPE_SLOTS
2540
result = mp->mp_subscript(obj, py_slice);
2541
#else
2542
result = PyObject_GetItem(obj, py_slice);
2543
#endif
2544
if (!_py_slice) {
2545
Py_DECREF(py_slice);
2546
}
2547
return result;
2548
}
2549
PyErr_Format(PyExc_TypeError,
2550
"'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
2551
bad:
2552
return NULL;
2553
}
2554
2555
/* ArgTypeTest */
2556
static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
2557
PyErr_Format(PyExc_TypeError,
2558
"Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
2559
name, type->tp_name, Py_TYPE(obj)->tp_name);
2560
}
2561
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
2562
const char *name, int exact)
2563
{
2564
if (unlikely(!type)) {
2565
PyErr_SetString(PyExc_SystemError, "Missing type object");
2566
return 0;
2567
}
2568
if (none_allowed && obj == Py_None) return 1;
2569
else if (exact) {
2570
if (likely(Py_TYPE(obj) == type)) return 1;
2571
#if PY_MAJOR_VERSION == 2
2572
else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
2573
#endif
2574
}
2575
else {
2576
if (likely(PyObject_TypeCheck(obj, type))) return 1;
2577
}
2578
__Pyx_RaiseArgumentTypeInvalid(name, obj, type);
2579
return 0;
2580
}
2581
2582
/* PyCFunctionFastCall */
2583
#if CYTHON_FAST_PYCCALL
2584
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
2585
PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
2586
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
2587
PyObject *self = PyCFunction_GET_SELF(func);
2588
assert(PyCFunction_Check(func));
2589
assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)));
2590
assert(nargs >= 0);
2591
assert(nargs == 0 || args != NULL);
2592
/* _PyCFunction_FastCallDict() must not be called with an exception set,
2593
because it may clear it (directly or indirectly) and so the
2594
caller loses its exception */
2595
assert(!PyErr_Occurred());
2596
return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
2597
}
2598
#endif // CYTHON_FAST_PYCCALL
2599
2600
/* PyFunctionFastCall */
2601
#if CYTHON_FAST_PYCALL
2602
#include "frameobject.h"
2603
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
2604
PyObject *globals) {
2605
PyFrameObject *f;
2606
PyThreadState *tstate = PyThreadState_GET();
2607
PyObject **fastlocals;
2608
Py_ssize_t i;
2609
PyObject *result;
2610
assert(globals != NULL);
2611
/* XXX Perhaps we should create a specialized
2612
PyFrame_New() that doesn't take locals, but does
2613
take builtins without sanity checking them.
2614
*/
2615
assert(tstate != NULL);
2616
f = PyFrame_New(tstate, co, globals, NULL);
2617
if (f == NULL) {
2618
return NULL;
2619
}
2620
fastlocals = f->f_localsplus;
2621
for (i = 0; i < na; i++) {
2622
Py_INCREF(*args);
2623
fastlocals[i] = *args++;
2624
}
2625
result = PyEval_EvalFrameEx(f,0);
2626
++tstate->recursion_depth;
2627
Py_DECREF(f);
2628
--tstate->recursion_depth;
2629
return result;
2630
}
2631
#if 1 || PY_VERSION_HEX < 0x030600B1
2632
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
2633
PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
2634
PyObject *globals = PyFunction_GET_GLOBALS(func);
2635
PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
2636
PyObject *closure;
2637
#if PY_MAJOR_VERSION >= 3
2638
PyObject *kwdefs;
2639
#endif
2640
PyObject *kwtuple, **k;
2641
PyObject **d;
2642
Py_ssize_t nd;
2643
Py_ssize_t nk;
2644
PyObject *result;
2645
assert(kwargs == NULL || PyDict_Check(kwargs));
2646
nk = kwargs ? PyDict_Size(kwargs) : 0;
2647
if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
2648
return NULL;
2649
}
2650
if (
2651
#if PY_MAJOR_VERSION >= 3
2652
co->co_kwonlyargcount == 0 &&
2653
#endif
2654
likely(kwargs == NULL || nk == 0) &&
2655
co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
2656
if (argdefs == NULL && co->co_argcount == nargs) {
2657
result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
2658
goto done;
2659
}
2660
else if (nargs == 0 && argdefs != NULL
2661
&& co->co_argcount == Py_SIZE(argdefs)) {
2662
/* function called with no arguments, but all parameters have
2663
a default value: use default values as arguments .*/
2664
args = &PyTuple_GET_ITEM(argdefs, 0);
2665
result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
2666
goto done;
2667
}
2668
}
2669
if (kwargs != NULL) {
2670
Py_ssize_t pos, i;
2671
kwtuple = PyTuple_New(2 * nk);
2672
if (kwtuple == NULL) {
2673
result = NULL;
2674
goto done;
2675
}
2676
k = &PyTuple_GET_ITEM(kwtuple, 0);
2677
pos = i = 0;
2678
while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
2679
Py_INCREF(k[i]);
2680
Py_INCREF(k[i+1]);
2681
i += 2;
2682
}
2683
nk = i / 2;
2684
}
2685
else {
2686
kwtuple = NULL;
2687
k = NULL;
2688
}
2689
closure = PyFunction_GET_CLOSURE(func);
2690
#if PY_MAJOR_VERSION >= 3
2691
kwdefs = PyFunction_GET_KW_DEFAULTS(func);
2692
#endif
2693
if (argdefs != NULL) {
2694
d = &PyTuple_GET_ITEM(argdefs, 0);
2695
nd = Py_SIZE(argdefs);
2696
}
2697
else {
2698
d = NULL;
2699
nd = 0;
2700
}
2701
#if PY_MAJOR_VERSION >= 3
2702
result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
2703
args, nargs,
2704
k, (int)nk,
2705
d, (int)nd, kwdefs, closure);
2706
#else
2707
result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
2708
args, nargs,
2709
k, (int)nk,
2710
d, (int)nd, closure);
2711
#endif
2712
Py_XDECREF(kwtuple);
2713
done:
2714
Py_LeaveRecursiveCall();
2715
return result;
2716
}
2717
#endif // CPython < 3.6
2718
#endif // CYTHON_FAST_PYCALL
2719
2720
/* PyObjectCallMethO */
2721
#if CYTHON_COMPILING_IN_CPYTHON
2722
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
2723
PyObject *self, *result;
2724
PyCFunction cfunc;
2725
cfunc = PyCFunction_GET_FUNCTION(func);
2726
self = PyCFunction_GET_SELF(func);
2727
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
2728
return NULL;
2729
result = cfunc(self, arg);
2730
Py_LeaveRecursiveCall();
2731
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2732
PyErr_SetString(
2733
PyExc_SystemError,
2734
"NULL result without error in PyObject_Call");
2735
}
2736
return result;
2737
}
2738
#endif
2739
2740
/* PyObjectCallOneArg */
2741
#if CYTHON_COMPILING_IN_CPYTHON
2742
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2743
PyObject *result;
2744
PyObject *args = PyTuple_New(1);
2745
if (unlikely(!args)) return NULL;
2746
Py_INCREF(arg);
2747
PyTuple_SET_ITEM(args, 0, arg);
2748
result = __Pyx_PyObject_Call(func, args, NULL);
2749
Py_DECREF(args);
2750
return result;
2751
}
2752
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2753
#if CYTHON_FAST_PYCALL
2754
if (PyFunction_Check(func)) {
2755
return __Pyx_PyFunction_FastCall(func, &arg, 1);
2756
}
2757
#endif
2758
#ifdef __Pyx_CyFunction_USED
2759
if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
2760
#else
2761
if (likely(PyCFunction_Check(func))) {
2762
#endif
2763
if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
2764
return __Pyx_PyObject_CallMethO(func, arg);
2765
#if CYTHON_FAST_PYCCALL
2766
} else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
2767
return __Pyx_PyCFunction_FastCall(func, &arg, 1);
2768
#endif
2769
}
2770
}
2771
return __Pyx__PyObject_CallOneArg(func, arg);
2772
}
2773
#else
2774
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2775
PyObject *result;
2776
PyObject *args = PyTuple_Pack(1, arg);
2777
if (unlikely(!args)) return NULL;
2778
result = __Pyx_PyObject_Call(func, args, NULL);
2779
Py_DECREF(args);
2780
return result;
2781
}
2782
#endif
2783
2784
/* RaiseTooManyValuesToUnpack */
2785
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
2786
PyErr_Format(PyExc_ValueError,
2787
"too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
2788
}
2789
2790
/* RaiseNeedMoreValuesToUnpack */
2791
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
2792
PyErr_Format(PyExc_ValueError,
2793
"need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
2794
index, (index == 1) ? "" : "s");
2795
}
2796
2797
/* IterFinish */
2798
static CYTHON_INLINE int __Pyx_IterFinish(void) {
2799
#if CYTHON_FAST_THREAD_STATE
2800
PyThreadState *tstate = PyThreadState_GET();
2801
PyObject* exc_type = tstate->curexc_type;
2802
if (unlikely(exc_type)) {
2803
if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
2804
PyObject *exc_value, *exc_tb;
2805
exc_value = tstate->curexc_value;
2806
exc_tb = tstate->curexc_traceback;
2807
tstate->curexc_type = 0;
2808
tstate->curexc_value = 0;
2809
tstate->curexc_traceback = 0;
2810
Py_DECREF(exc_type);
2811
Py_XDECREF(exc_value);
2812
Py_XDECREF(exc_tb);
2813
return 0;
2814
} else {
2815
return -1;
2816
}
2817
}
2818
return 0;
2819
#else
2820
if (unlikely(PyErr_Occurred())) {
2821
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
2822
PyErr_Clear();
2823
return 0;
2824
} else {
2825
return -1;
2826
}
2827
}
2828
return 0;
2829
#endif
2830
}
2831
2832
/* UnpackItemEndCheck */
2833
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
2834
if (unlikely(retval)) {
2835
Py_DECREF(retval);
2836
__Pyx_RaiseTooManyValuesError(expected);
2837
return -1;
2838
} else {
2839
return __Pyx_IterFinish();
2840
}
2841
return 0;
2842
}
2843
2844
/* ExtTypeTest */
2845
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
2846
if (unlikely(!type)) {
2847
PyErr_SetString(PyExc_SystemError, "Missing type object");
2848
return 0;
2849
}
2850
if (likely(PyObject_TypeCheck(obj, type)))
2851
return 1;
2852
PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
2853
Py_TYPE(obj)->tp_name, type->tp_name);
2854
return 0;
2855
}
2856
2857
/* GetItemInt */
2858
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
2859
PyObject *r;
2860
if (!j) return NULL;
2861
r = PyObject_GetItem(o, j);
2862
Py_DECREF(j);
2863
return r;
2864
}
2865
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
2866
CYTHON_NCP_UNUSED int wraparound,
2867
CYTHON_NCP_UNUSED int boundscheck) {
2868
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2869
if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
2870
if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
2871
PyObject *r = PyList_GET_ITEM(o, i);
2872
Py_INCREF(r);
2873
return r;
2874
}
2875
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
2876
#else
2877
return PySequence_GetItem(o, i);
2878
#endif
2879
}
2880
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
2881
CYTHON_NCP_UNUSED int wraparound,
2882
CYTHON_NCP_UNUSED int boundscheck) {
2883
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2884
if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
2885
if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
2886
PyObject *r = PyTuple_GET_ITEM(o, i);
2887
Py_INCREF(r);
2888
return r;
2889
}
2890
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
2891
#else
2892
return PySequence_GetItem(o, i);
2893
#endif
2894
}
2895
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
2896
CYTHON_NCP_UNUSED int wraparound,
2897
CYTHON_NCP_UNUSED int boundscheck) {
2898
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
2899
if (is_list || PyList_CheckExact(o)) {
2900
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
2901
if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
2902
PyObject *r = PyList_GET_ITEM(o, n);
2903
Py_INCREF(r);
2904
return r;
2905
}
2906
}
2907
else if (PyTuple_CheckExact(o)) {
2908
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
2909
if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
2910
PyObject *r = PyTuple_GET_ITEM(o, n);
2911
Py_INCREF(r);
2912
return r;
2913
}
2914
} else {
2915
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
2916
if (likely(m && m->sq_item)) {
2917
if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
2918
Py_ssize_t l = m->sq_length(o);
2919
if (likely(l >= 0)) {
2920
i += l;
2921
} else {
2922
if (!PyErr_ExceptionMatches(PyExc_OverflowError))
2923
return NULL;
2924
PyErr_Clear();
2925
}
2926
}
2927
return m->sq_item(o, i);
2928
}
2929
}
2930
#else
2931
if (is_list || PySequence_Check(o)) {
2932
return PySequence_GetItem(o, i);
2933
}
2934
#endif
2935
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
2936
}
2937
2938
/* None */
2939
static CYTHON_INLINE int __Pyx_mod_int(int a, int b) {
2940
int r = a % b;
2941
r += ((r != 0) & ((r ^ b) < 0)) * b;
2942
return r;
2943
}
2944
2945
/* GetVTable */
2946
static void* __Pyx_GetVtable(PyObject *dict) {
2947
void* ptr;
2948
PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
2949
if (!ob)
2950
goto bad;
2951
#if PY_VERSION_HEX >= 0x02070000
2952
ptr = PyCapsule_GetPointer(ob, 0);
2953
#else
2954
ptr = PyCObject_AsVoidPtr(ob);
2955
#endif
2956
if (!ptr && !PyErr_Occurred())
2957
PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
2958
Py_DECREF(ob);
2959
return ptr;
2960
bad:
2961
Py_XDECREF(ob);
2962
return NULL;
2963
}
2964
2965
/* Import */
2966
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
2967
PyObject *empty_list = 0;
2968
PyObject *module = 0;
2969
PyObject *global_dict = 0;
2970
PyObject *empty_dict = 0;
2971
PyObject *list;
2972
#if PY_VERSION_HEX < 0x03030000
2973
PyObject *py_import;
2974
py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
2975
if (!py_import)
2976
goto bad;
2977
#endif
2978
if (from_list)
2979
list = from_list;
2980
else {
2981
empty_list = PyList_New(0);
2982
if (!empty_list)
2983
goto bad;
2984
list = empty_list;
2985
}
2986
global_dict = PyModule_GetDict(__pyx_m);
2987
if (!global_dict)
2988
goto bad;
2989
empty_dict = PyDict_New();
2990
if (!empty_dict)
2991
goto bad;
2992
{
2993
#if PY_MAJOR_VERSION >= 3
2994
if (level == -1) {
2995
if (strchr(__Pyx_MODULE_NAME, '.')) {
2996
#if PY_VERSION_HEX < 0x03030000
2997
PyObject *py_level = PyInt_FromLong(1);
2998
if (!py_level)
2999
goto bad;
3000
module = PyObject_CallFunctionObjArgs(py_import,
3001
name, global_dict, empty_dict, list, py_level, NULL);
3002
Py_DECREF(py_level);
3003
#else
3004
module = PyImport_ImportModuleLevelObject(
3005
name, global_dict, empty_dict, list, 1);
3006
#endif
3007
if (!module) {
3008
if (!PyErr_ExceptionMatches(PyExc_ImportError))
3009
goto bad;
3010
PyErr_Clear();
3011
}
3012
}
3013
level = 0;
3014
}
3015
#endif
3016
if (!module) {
3017
#if PY_VERSION_HEX < 0x03030000
3018
PyObject *py_level = PyInt_FromLong(level);
3019
if (!py_level)
3020
goto bad;
3021
module = PyObject_CallFunctionObjArgs(py_import,
3022
name, global_dict, empty_dict, list, py_level, NULL);
3023
Py_DECREF(py_level);
3024
#else
3025
module = PyImport_ImportModuleLevelObject(
3026
name, global_dict, empty_dict, list, level);
3027
#endif
3028
}
3029
}
3030
bad:
3031
#if PY_VERSION_HEX < 0x03030000
3032
Py_XDECREF(py_import);
3033
#endif
3034
Py_XDECREF(empty_list);
3035
Py_XDECREF(empty_dict);
3036
return module;
3037
}
3038
3039
/* ImportFrom */
3040
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
3041
PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
3042
if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
3043
PyErr_Format(PyExc_ImportError,
3044
#if PY_MAJOR_VERSION < 3
3045
"cannot import name %.230s", PyString_AS_STRING(name));
3046
#else
3047
"cannot import name %S", name);
3048
#endif
3049
}
3050
return value;
3051
}
3052
3053
/* CodeObjectCache */
3054
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
3055
int start = 0, mid = 0, end = count - 1;
3056
if (end >= 0 && code_line > entries[end].code_line) {
3057
return count;
3058
}
3059
while (start < end) {
3060
mid = start + (end - start) / 2;
3061
if (code_line < entries[mid].code_line) {
3062
end = mid;
3063
} else if (code_line > entries[mid].code_line) {
3064
start = mid + 1;
3065
} else {
3066
return mid;
3067
}
3068
}
3069
if (code_line <= entries[mid].code_line) {
3070
return mid;
3071
} else {
3072
return mid + 1;
3073
}
3074
}
3075
static PyCodeObject *__pyx_find_code_object(int code_line) {
3076
PyCodeObject* code_object;
3077
int pos;
3078
if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
3079
return NULL;
3080
}
3081
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3082
if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
3083
return NULL;
3084
}
3085
code_object = __pyx_code_cache.entries[pos].code_object;
3086
Py_INCREF(code_object);
3087
return code_object;
3088
}
3089
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
3090
int pos, i;
3091
__Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
3092
if (unlikely(!code_line)) {
3093
return;
3094
}
3095
if (unlikely(!entries)) {
3096
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
3097
if (likely(entries)) {
3098
__pyx_code_cache.entries = entries;
3099
__pyx_code_cache.max_count = 64;
3100
__pyx_code_cache.count = 1;
3101
entries[0].code_line = code_line;
3102
entries[0].code_object = code_object;
3103
Py_INCREF(code_object);
3104
}
3105
return;
3106
}
3107
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3108
if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
3109
PyCodeObject* tmp = entries[pos].code_object;
3110
entries[pos].code_object = code_object;
3111
Py_DECREF(tmp);
3112
return;
3113
}
3114
if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
3115
int new_max = __pyx_code_cache.max_count + 64;
3116
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
3117
__pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
3118
if (unlikely(!entries)) {
3119
return;
3120
}
3121
__pyx_code_cache.entries = entries;
3122
__pyx_code_cache.max_count = new_max;
3123
}
3124
for (i=__pyx_code_cache.count; i>pos; i--) {
3125
entries[i] = entries[i-1];
3126
}
3127
entries[pos].code_line = code_line;
3128
entries[pos].code_object = code_object;
3129
__pyx_code_cache.count++;
3130
Py_INCREF(code_object);
3131
}
3132
3133
/* AddTraceback */
3134
#include "compile.h"
3135
#include "frameobject.h"
3136
#include "traceback.h"
3137
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
3138
const char *funcname, int c_line,
3139
int py_line, const char *filename) {
3140
PyCodeObject *py_code = 0;
3141
PyObject *py_srcfile = 0;
3142
PyObject *py_funcname = 0;
3143
#if PY_MAJOR_VERSION < 3
3144
py_srcfile = PyString_FromString(filename);
3145
#else
3146
py_srcfile = PyUnicode_FromString(filename);
3147
#endif
3148
if (!py_srcfile) goto bad;
3149
if (c_line) {
3150
#if PY_MAJOR_VERSION < 3
3151
py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3152
#else
3153
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3154
#endif
3155
}
3156
else {
3157
#if PY_MAJOR_VERSION < 3
3158
py_funcname = PyString_FromString(funcname);
3159
#else
3160
py_funcname = PyUnicode_FromString(funcname);
3161
#endif
3162
}
3163
if (!py_funcname) goto bad;
3164
py_code = __Pyx_PyCode_New(
3165
0,
3166
0,
3167
0,
3168
0,
3169
0,
3170
__pyx_empty_bytes, /*PyObject *code,*/
3171
__pyx_empty_tuple, /*PyObject *consts,*/
3172
__pyx_empty_tuple, /*PyObject *names,*/
3173
__pyx_empty_tuple, /*PyObject *varnames,*/
3174
__pyx_empty_tuple, /*PyObject *freevars,*/
3175
__pyx_empty_tuple, /*PyObject *cellvars,*/
3176
py_srcfile, /*PyObject *filename,*/
3177
py_funcname, /*PyObject *name,*/
3178
py_line,
3179
__pyx_empty_bytes /*PyObject *lnotab*/
3180
);
3181
Py_DECREF(py_srcfile);
3182
Py_DECREF(py_funcname);
3183
return py_code;
3184
bad:
3185
Py_XDECREF(py_srcfile);
3186
Py_XDECREF(py_funcname);
3187
return NULL;
3188
}
3189
static void __Pyx_AddTraceback(const char *funcname, int c_line,
3190
int py_line, const char *filename) {
3191
PyCodeObject *py_code = 0;
3192
PyFrameObject *py_frame = 0;
3193
py_code = __pyx_find_code_object(c_line ? c_line : py_line);
3194
if (!py_code) {
3195
py_code = __Pyx_CreateCodeObjectForTraceback(
3196
funcname, c_line, py_line, filename);
3197
if (!py_code) goto bad;
3198
__pyx_insert_code_object(c_line ? c_line : py_line, py_code);
3199
}
3200
py_frame = PyFrame_New(
3201
PyThreadState_GET(), /*PyThreadState *tstate,*/
3202
py_code, /*PyCodeObject *code,*/
3203
__pyx_d, /*PyObject *globals,*/
3204
0 /*PyObject *locals*/
3205
);
3206
if (!py_frame) goto bad;
3207
__Pyx_PyFrame_SetLineNumber(py_frame, py_line);
3208
PyTraceBack_Here(py_frame);
3209
bad:
3210
Py_XDECREF(py_code);
3211
Py_XDECREF(py_frame);
3212
}
3213
3214
/* CIntToPy */
3215
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
3216
const long neg_one = (long) -1, const_zero = (long) 0;
3217
const int is_unsigned = neg_one > const_zero;
3218
if (is_unsigned) {
3219
if (sizeof(long) < sizeof(long)) {
3220
return PyInt_FromLong((long) value);
3221
} else if (sizeof(long) <= sizeof(unsigned long)) {
3222
return PyLong_FromUnsignedLong((unsigned long) value);
3223
#ifdef HAVE_LONG_LONG
3224
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
3225
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
3226
#endif
3227
}
3228
} else {
3229
if (sizeof(long) <= sizeof(long)) {
3230
return PyInt_FromLong((long) value);
3231
#ifdef HAVE_LONG_LONG
3232
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
3233
return PyLong_FromLongLong((PY_LONG_LONG) value);
3234
#endif
3235
}
3236
}
3237
{
3238
int one = 1; int little = (int)*(unsigned char *)&one;
3239
unsigned char *bytes = (unsigned char *)&value;
3240
return _PyLong_FromByteArray(bytes, sizeof(long),
3241
little, !is_unsigned);
3242
}
3243
}
3244
3245
/* CIntFromPyVerify */
3246
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
3247
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
3248
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
3249
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
3250
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
3251
{\
3252
func_type value = func_value;\
3253
if (sizeof(target_type) < sizeof(func_type)) {\
3254
if (unlikely(value != (func_type) (target_type) value)) {\
3255
func_type zero = 0;\
3256
if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
3257
return (target_type) -1;\
3258
if (is_unsigned && unlikely(value < zero))\
3259
goto raise_neg_overflow;\
3260
else\
3261
goto raise_overflow;\
3262
}\
3263
}\
3264
return (target_type) value;\
3265
}
3266
3267
/* CIntToPy */
3268
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
3269
const int neg_one = (int) -1, const_zero = (int) 0;
3270
const int is_unsigned = neg_one > const_zero;
3271
if (is_unsigned) {
3272
if (sizeof(int) < sizeof(long)) {
3273
return PyInt_FromLong((long) value);
3274
} else if (sizeof(int) <= sizeof(unsigned long)) {
3275
return PyLong_FromUnsignedLong((unsigned long) value);
3276
#ifdef HAVE_LONG_LONG
3277
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
3278
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
3279
#endif
3280
}
3281
} else {
3282
if (sizeof(int) <= sizeof(long)) {
3283
return PyInt_FromLong((long) value);
3284
#ifdef HAVE_LONG_LONG
3285
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
3286
return PyLong_FromLongLong((PY_LONG_LONG) value);
3287
#endif
3288
}
3289
}
3290
{
3291
int one = 1; int little = (int)*(unsigned char *)&one;
3292
unsigned char *bytes = (unsigned char *)&value;
3293
return _PyLong_FromByteArray(bytes, sizeof(int),
3294
little, !is_unsigned);
3295
}
3296
}
3297
3298
/* CIntFromPy */
3299
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
3300
const int neg_one = (int) -1, const_zero = (int) 0;
3301
const int is_unsigned = neg_one > const_zero;
3302
#if PY_MAJOR_VERSION < 3
3303
if (likely(PyInt_Check(x))) {
3304
if (sizeof(int) < sizeof(long)) {
3305
__PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
3306
} else {
3307
long val = PyInt_AS_LONG(x);
3308
if (is_unsigned && unlikely(val < 0)) {
3309
goto raise_neg_overflow;
3310
}
3311
return (int) val;
3312
}
3313
} else
3314
#endif
3315
if (likely(PyLong_Check(x))) {
3316
if (is_unsigned) {
3317
#if CYTHON_USE_PYLONG_INTERNALS
3318
const digit* digits = ((PyLongObject*)x)->ob_digit;
3319
switch (Py_SIZE(x)) {
3320
case 0: return (int) 0;
3321
case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
3322
case 2:
3323
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3324
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3325
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3326
} else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
3327
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3328
}
3329
}
3330
break;
3331
case 3:
3332
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3333
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3334
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3335
} else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
3336
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3337
}
3338
}
3339
break;
3340
case 4:
3341
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3342
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3343
__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])))
3344
} else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
3345
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3346
}
3347
}
3348
break;
3349
}
3350
#endif
3351
#if CYTHON_COMPILING_IN_CPYTHON
3352
if (unlikely(Py_SIZE(x) < 0)) {
3353
goto raise_neg_overflow;
3354
}
3355
#else
3356
{
3357
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
3358
if (unlikely(result < 0))
3359
return (int) -1;
3360
if (unlikely(result == 1))
3361
goto raise_neg_overflow;
3362
}
3363
#endif
3364
if (sizeof(int) <= sizeof(unsigned long)) {
3365
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
3366
#ifdef HAVE_LONG_LONG
3367
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
3368
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3369
#endif
3370
}
3371
} else {
3372
#if CYTHON_USE_PYLONG_INTERNALS
3373
const digit* digits = ((PyLongObject*)x)->ob_digit;
3374
switch (Py_SIZE(x)) {
3375
case 0: return (int) 0;
3376
case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
3377
case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
3378
case -2:
3379
if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
3380
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3381
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3382
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3383
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3384
}
3385
}
3386
break;
3387
case 2:
3388
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3389
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3390
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3391
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3392
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3393
}
3394
}
3395
break;
3396
case -3:
3397
if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3398
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3399
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3400
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3401
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3402
}
3403
}
3404
break;
3405
case 3:
3406
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3407
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3408
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3409
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3410
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3411
}
3412
}
3413
break;
3414
case -4:
3415
if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3416
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3417
__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])))
3418
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3419
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3420
}
3421
}
3422
break;
3423
case 4:
3424
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3425
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3426
__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])))
3427
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3428
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3429
}
3430
}
3431
break;
3432
}
3433
#endif
3434
if (sizeof(int) <= sizeof(long)) {
3435
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
3436
#ifdef HAVE_LONG_LONG
3437
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
3438
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
3439
#endif
3440
}
3441
}
3442
{
3443
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3444
PyErr_SetString(PyExc_RuntimeError,
3445
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3446
#else
3447
int val;
3448
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3449
#if PY_MAJOR_VERSION < 3
3450
if (likely(v) && !PyLong_Check(v)) {
3451
PyObject *tmp = v;
3452
v = PyNumber_Long(tmp);
3453
Py_DECREF(tmp);
3454
}
3455
#endif
3456
if (likely(v)) {
3457
int one = 1; int is_little = (int)*(unsigned char *)&one;
3458
unsigned char *bytes = (unsigned char *)&val;
3459
int ret = _PyLong_AsByteArray((PyLongObject *)v,
3460
bytes, sizeof(val),
3461
is_little, !is_unsigned);
3462
Py_DECREF(v);
3463
if (likely(!ret))
3464
return val;
3465
}
3466
#endif
3467
return (int) -1;
3468
}
3469
} else {
3470
int val;
3471
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3472
if (!tmp) return (int) -1;
3473
val = __Pyx_PyInt_As_int(tmp);
3474
Py_DECREF(tmp);
3475
return val;
3476
}
3477
raise_overflow:
3478
PyErr_SetString(PyExc_OverflowError,
3479
"value too large to convert to int");
3480
return (int) -1;
3481
raise_neg_overflow:
3482
PyErr_SetString(PyExc_OverflowError,
3483
"can't convert negative value to int");
3484
return (int) -1;
3485
}
3486
3487
/* CIntFromPy */
3488
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
3489
const long neg_one = (long) -1, const_zero = (long) 0;
3490
const int is_unsigned = neg_one > const_zero;
3491
#if PY_MAJOR_VERSION < 3
3492
if (likely(PyInt_Check(x))) {
3493
if (sizeof(long) < sizeof(long)) {
3494
__PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
3495
} else {
3496
long val = PyInt_AS_LONG(x);
3497
if (is_unsigned && unlikely(val < 0)) {
3498
goto raise_neg_overflow;
3499
}
3500
return (long) val;
3501
}
3502
} else
3503
#endif
3504
if (likely(PyLong_Check(x))) {
3505
if (is_unsigned) {
3506
#if CYTHON_USE_PYLONG_INTERNALS
3507
const digit* digits = ((PyLongObject*)x)->ob_digit;
3508
switch (Py_SIZE(x)) {
3509
case 0: return (long) 0;
3510
case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
3511
case 2:
3512
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
3513
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3514
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3515
} else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
3516
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
3517
}
3518
}
3519
break;
3520
case 3:
3521
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
3522
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3523
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3524
} else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
3525
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
3526
}
3527
}
3528
break;
3529
case 4:
3530
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
3531
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3532
__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])))
3533
} else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
3534
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
3535
}
3536
}
3537
break;
3538
}
3539
#endif
3540
#if CYTHON_COMPILING_IN_CPYTHON
3541
if (unlikely(Py_SIZE(x) < 0)) {
3542
goto raise_neg_overflow;
3543
}
3544
#else
3545
{
3546
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
3547
if (unlikely(result < 0))
3548
return (long) -1;
3549
if (unlikely(result == 1))
3550
goto raise_neg_overflow;
3551
}
3552
#endif
3553
if (sizeof(long) <= sizeof(unsigned long)) {
3554
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
3555
#ifdef HAVE_LONG_LONG
3556
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
3557
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3558
#endif
3559
}
3560
} else {
3561
#if CYTHON_USE_PYLONG_INTERNALS
3562
const digit* digits = ((PyLongObject*)x)->ob_digit;
3563
switch (Py_SIZE(x)) {
3564
case 0: return (long) 0;
3565
case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
3566
case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
3567
case -2:
3568
if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
3569
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3570
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3571
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
3572
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3573
}
3574
}
3575
break;
3576
case 2:
3577
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
3578
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3579
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3580
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
3581
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3582
}
3583
}
3584
break;
3585
case -3:
3586
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
3587
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3588
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3589
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
3590
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3591
}
3592
}
3593
break;
3594
case 3:
3595
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
3596
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3597
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3598
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
3599
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3600
}
3601
}
3602
break;
3603
case -4:
3604
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
3605
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3606
__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])))
3607
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
3608
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3609
}
3610
}
3611
break;
3612
case 4:
3613
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
3614
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3615
__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])))
3616
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
3617
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3618
}
3619
}
3620
break;
3621
}
3622
#endif
3623
if (sizeof(long) <= sizeof(long)) {
3624
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
3625
#ifdef HAVE_LONG_LONG
3626
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
3627
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
3628
#endif
3629
}
3630
}
3631
{
3632
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3633
PyErr_SetString(PyExc_RuntimeError,
3634
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3635
#else
3636
long val;
3637
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3638
#if PY_MAJOR_VERSION < 3
3639
if (likely(v) && !PyLong_Check(v)) {
3640
PyObject *tmp = v;
3641
v = PyNumber_Long(tmp);
3642
Py_DECREF(tmp);
3643
}
3644
#endif
3645
if (likely(v)) {
3646
int one = 1; int is_little = (int)*(unsigned char *)&one;
3647
unsigned char *bytes = (unsigned char *)&val;
3648
int ret = _PyLong_AsByteArray((PyLongObject *)v,
3649
bytes, sizeof(val),
3650
is_little, !is_unsigned);
3651
Py_DECREF(v);
3652
if (likely(!ret))
3653
return val;
3654
}
3655
#endif
3656
return (long) -1;
3657
}
3658
} else {
3659
long val;
3660
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3661
if (!tmp) return (long) -1;
3662
val = __Pyx_PyInt_As_long(tmp);
3663
Py_DECREF(tmp);
3664
return val;
3665
}
3666
raise_overflow:
3667
PyErr_SetString(PyExc_OverflowError,
3668
"value too large to convert to long");
3669
return (long) -1;
3670
raise_neg_overflow:
3671
PyErr_SetString(PyExc_OverflowError,
3672
"can't convert negative value to long");
3673
return (long) -1;
3674
}
3675
3676
/* CheckBinaryVersion */
3677
static int __Pyx_check_binary_version(void) {
3678
char ctversion[4], rtversion[4];
3679
PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
3680
PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
3681
if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
3682
char message[200];
3683
PyOS_snprintf(message, sizeof(message),
3684
"compiletime version %s of module '%.100s' "
3685
"does not match runtime version %s",
3686
ctversion, __Pyx_MODULE_NAME, rtversion);
3687
return PyErr_WarnEx(NULL, message, 1);
3688
}
3689
return 0;
3690
}
3691
3692
/* ModuleImport */
3693
#ifndef __PYX_HAVE_RT_ImportModule
3694
#define __PYX_HAVE_RT_ImportModule
3695
static PyObject *__Pyx_ImportModule(const char *name) {
3696
PyObject *py_name = 0;
3697
PyObject *py_module = 0;
3698
py_name = __Pyx_PyIdentifier_FromString(name);
3699
if (!py_name)
3700
goto bad;
3701
py_module = PyImport_Import(py_name);
3702
Py_DECREF(py_name);
3703
return py_module;
3704
bad:
3705
Py_XDECREF(py_name);
3706
return 0;
3707
}
3708
#endif
3709
3710
/* TypeImport */
3711
#ifndef __PYX_HAVE_RT_ImportType
3712
#define __PYX_HAVE_RT_ImportType
3713
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
3714
size_t size, int strict)
3715
{
3716
PyObject *py_module = 0;
3717
PyObject *result = 0;
3718
PyObject *py_name = 0;
3719
char warning[200];
3720
Py_ssize_t basicsize;
3721
#ifdef Py_LIMITED_API
3722
PyObject *py_basicsize;
3723
#endif
3724
py_module = __Pyx_ImportModule(module_name);
3725
if (!py_module)
3726
goto bad;
3727
py_name = __Pyx_PyIdentifier_FromString(class_name);
3728
if (!py_name)
3729
goto bad;
3730
result = PyObject_GetAttr(py_module, py_name);
3731
Py_DECREF(py_name);
3732
py_name = 0;
3733
Py_DECREF(py_module);
3734
py_module = 0;
3735
if (!result)
3736
goto bad;
3737
if (!PyType_Check(result)) {
3738
PyErr_Format(PyExc_TypeError,
3739
"%.200s.%.200s is not a type object",
3740
module_name, class_name);
3741
goto bad;
3742
}
3743
#ifndef Py_LIMITED_API
3744
basicsize = ((PyTypeObject *)result)->tp_basicsize;
3745
#else
3746
py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
3747
if (!py_basicsize)
3748
goto bad;
3749
basicsize = PyLong_AsSsize_t(py_basicsize);
3750
Py_DECREF(py_basicsize);
3751
py_basicsize = 0;
3752
if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
3753
goto bad;
3754
#endif
3755
if (!strict && (size_t)basicsize > size) {
3756
PyOS_snprintf(warning, sizeof(warning),
3757
"%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
3758
module_name, class_name, basicsize, size);
3759
if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
3760
}
3761
else if ((size_t)basicsize != size) {
3762
PyErr_Format(PyExc_ValueError,
3763
"%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
3764
module_name, class_name, basicsize, size);
3765
goto bad;
3766
}
3767
return (PyTypeObject *)result;
3768
bad:
3769
Py_XDECREF(py_module);
3770
Py_XDECREF(result);
3771
return NULL;
3772
}
3773
#endif
3774
3775
/* InitStrings */
3776
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
3777
while (t->p) {
3778
#if PY_MAJOR_VERSION < 3
3779
if (t->is_unicode) {
3780
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
3781
} else if (t->intern) {
3782
*t->p = PyString_InternFromString(t->s);
3783
} else {
3784
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
3785
}
3786
#else
3787
if (t->is_unicode | t->is_str) {
3788
if (t->intern) {
3789
*t->p = PyUnicode_InternFromString(t->s);
3790
} else if (t->encoding) {
3791
*t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
3792
} else {
3793
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
3794
}
3795
} else {
3796
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
3797
}
3798
#endif
3799
if (!*t->p)
3800
return -1;
3801
++t;
3802
}
3803
return 0;
3804
}
3805
3806
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
3807
return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
3808
}
3809
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
3810
Py_ssize_t ignore;
3811
return __Pyx_PyObject_AsStringAndSize(o, &ignore);
3812
}
3813
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
3814
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
3815
if (
3816
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3817
__Pyx_sys_getdefaultencoding_not_ascii &&
3818
#endif
3819
PyUnicode_Check(o)) {
3820
#if PY_VERSION_HEX < 0x03030000
3821
char* defenc_c;
3822
PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
3823
if (!defenc) return NULL;
3824
defenc_c = PyBytes_AS_STRING(defenc);
3825
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3826
{
3827
char* end = defenc_c + PyBytes_GET_SIZE(defenc);
3828
char* c;
3829
for (c = defenc_c; c < end; c++) {
3830
if ((unsigned char) (*c) >= 128) {
3831
PyUnicode_AsASCIIString(o);
3832
return NULL;
3833
}
3834
}
3835
}
3836
#endif
3837
*length = PyBytes_GET_SIZE(defenc);
3838
return defenc_c;
3839
#else
3840
if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
3841
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3842
if (PyUnicode_IS_ASCII(o)) {
3843
*length = PyUnicode_GET_LENGTH(o);
3844
return PyUnicode_AsUTF8(o);
3845
} else {
3846
PyUnicode_AsASCIIString(o);
3847
return NULL;
3848
}
3849
#else
3850
return PyUnicode_AsUTF8AndSize(o, length);
3851
#endif
3852
#endif
3853
} else
3854
#endif
3855
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
3856
if (PyByteArray_Check(o)) {
3857
*length = PyByteArray_GET_SIZE(o);
3858
return PyByteArray_AS_STRING(o);
3859
} else
3860
#endif
3861
{
3862
char* result;
3863
int r = PyBytes_AsStringAndSize(o, &result, length);
3864
if (unlikely(r < 0)) {
3865
return NULL;
3866
} else {
3867
return result;
3868
}
3869
}
3870
}
3871
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
3872
int is_true = x == Py_True;
3873
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
3874
else return PyObject_IsTrue(x);
3875
}
3876
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
3877
#if CYTHON_USE_TYPE_SLOTS
3878
PyNumberMethods *m;
3879
#endif
3880
const char *name = NULL;
3881
PyObject *res = NULL;
3882
#if PY_MAJOR_VERSION < 3
3883
if (PyInt_Check(x) || PyLong_Check(x))
3884
#else
3885
if (PyLong_Check(x))
3886
#endif
3887
return __Pyx_NewRef(x);
3888
#if CYTHON_USE_TYPE_SLOTS
3889
m = Py_TYPE(x)->tp_as_number;
3890
#if PY_MAJOR_VERSION < 3
3891
if (m && m->nb_int) {
3892
name = "int";
3893
res = PyNumber_Int(x);
3894
}
3895
else if (m && m->nb_long) {
3896
name = "long";
3897
res = PyNumber_Long(x);
3898
}
3899
#else
3900
if (m && m->nb_int) {
3901
name = "int";
3902
res = PyNumber_Long(x);
3903
}
3904
#endif
3905
#else
3906
res = PyNumber_Int(x);
3907
#endif
3908
if (res) {
3909
#if PY_MAJOR_VERSION < 3
3910
if (!PyInt_Check(res) && !PyLong_Check(res)) {
3911
#else
3912
if (!PyLong_Check(res)) {
3913
#endif
3914
PyErr_Format(PyExc_TypeError,
3915
"__%.4s__ returned non-%.4s (type %.200s)",
3916
name, name, Py_TYPE(res)->tp_name);
3917
Py_DECREF(res);
3918
return NULL;
3919
}
3920
}
3921
else if (!PyErr_Occurred()) {
3922
PyErr_SetString(PyExc_TypeError,
3923
"an integer is required");
3924
}
3925
return res;
3926
}
3927
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
3928
Py_ssize_t ival;
3929
PyObject *x;
3930
#if PY_MAJOR_VERSION < 3
3931
if (likely(PyInt_CheckExact(b))) {
3932
if (sizeof(Py_ssize_t) >= sizeof(long))
3933
return PyInt_AS_LONG(b);
3934
else
3935
return PyInt_AsSsize_t(x);
3936
}
3937
#endif
3938
if (likely(PyLong_CheckExact(b))) {
3939
#if CYTHON_USE_PYLONG_INTERNALS
3940
const digit* digits = ((PyLongObject*)b)->ob_digit;
3941
const Py_ssize_t size = Py_SIZE(b);
3942
if (likely(__Pyx_sst_abs(size) <= 1)) {
3943
ival = likely(size) ? digits[0] : 0;
3944
if (size == -1) ival = -ival;
3945
return ival;
3946
} else {
3947
switch (size) {
3948
case 2:
3949
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
3950
return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3951
}
3952
break;
3953
case -2:
3954
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
3955
return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3956
}
3957
break;
3958
case 3:
3959
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
3960
return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3961
}
3962
break;
3963
case -3:
3964
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
3965
return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3966
}
3967
break;
3968
case 4:
3969
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
3970
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]));
3971
}
3972
break;
3973
case -4:
3974
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
3975
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]));
3976
}
3977
break;
3978
}
3979
}
3980
#endif
3981
return PyLong_AsSsize_t(b);
3982
}
3983
x = PyNumber_Index(b);
3984
if (!x) return -1;
3985
ival = PyInt_AsSsize_t(x);
3986
Py_DECREF(x);
3987
return ival;
3988
}
3989
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
3990
return PyInt_FromSize_t(ival);
3991
}
3992
3993
3994
#endif /* Py_PYTHON_H */
3995
3996