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