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