Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241818 views
1
/* Generated by Cython 0.25.2 */
2
3
#define PY_SSIZE_T_CLEAN
4
#include "Python.h"
5
#ifndef Py_PYTHON_H
6
#error Python headers needed to compile C extensions, please install development version of Python.
7
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
8
#error Cython requires Python 2.6+ or Python 3.2+.
9
#else
10
#define CYTHON_ABI "0_25_2"
11
#include <stddef.h>
12
#ifndef offsetof
13
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
14
#endif
15
#if !defined(WIN32) && !defined(MS_WINDOWS)
16
#ifndef __stdcall
17
#define __stdcall
18
#endif
19
#ifndef __cdecl
20
#define __cdecl
21
#endif
22
#ifndef __fastcall
23
#define __fastcall
24
#endif
25
#endif
26
#ifndef DL_IMPORT
27
#define DL_IMPORT(t) t
28
#endif
29
#ifndef DL_EXPORT
30
#define DL_EXPORT(t) t
31
#endif
32
#ifndef HAVE_LONG_LONG
33
#if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
34
#define HAVE_LONG_LONG
35
#endif
36
#endif
37
#ifndef PY_LONG_LONG
38
#define PY_LONG_LONG LONG_LONG
39
#endif
40
#ifndef Py_HUGE_VAL
41
#define Py_HUGE_VAL HUGE_VAL
42
#endif
43
#ifdef PYPY_VERSION
44
#define CYTHON_COMPILING_IN_PYPY 1
45
#define CYTHON_COMPILING_IN_PYSTON 0
46
#define CYTHON_COMPILING_IN_CPYTHON 0
47
#undef CYTHON_USE_TYPE_SLOTS
48
#define CYTHON_USE_TYPE_SLOTS 0
49
#undef CYTHON_USE_ASYNC_SLOTS
50
#define CYTHON_USE_ASYNC_SLOTS 0
51
#undef CYTHON_USE_PYLIST_INTERNALS
52
#define CYTHON_USE_PYLIST_INTERNALS 0
53
#undef CYTHON_USE_UNICODE_INTERNALS
54
#define CYTHON_USE_UNICODE_INTERNALS 0
55
#undef CYTHON_USE_UNICODE_WRITER
56
#define CYTHON_USE_UNICODE_WRITER 0
57
#undef CYTHON_USE_PYLONG_INTERNALS
58
#define CYTHON_USE_PYLONG_INTERNALS 0
59
#undef CYTHON_AVOID_BORROWED_REFS
60
#define CYTHON_AVOID_BORROWED_REFS 1
61
#undef CYTHON_ASSUME_SAFE_MACROS
62
#define CYTHON_ASSUME_SAFE_MACROS 0
63
#undef CYTHON_UNPACK_METHODS
64
#define CYTHON_UNPACK_METHODS 0
65
#undef CYTHON_FAST_THREAD_STATE
66
#define CYTHON_FAST_THREAD_STATE 0
67
#undef CYTHON_FAST_PYCALL
68
#define CYTHON_FAST_PYCALL 0
69
#elif defined(PYSTON_VERSION)
70
#define CYTHON_COMPILING_IN_PYPY 0
71
#define CYTHON_COMPILING_IN_PYSTON 1
72
#define CYTHON_COMPILING_IN_CPYTHON 0
73
#ifndef CYTHON_USE_TYPE_SLOTS
74
#define CYTHON_USE_TYPE_SLOTS 1
75
#endif
76
#undef CYTHON_USE_ASYNC_SLOTS
77
#define CYTHON_USE_ASYNC_SLOTS 0
78
#undef CYTHON_USE_PYLIST_INTERNALS
79
#define CYTHON_USE_PYLIST_INTERNALS 0
80
#ifndef CYTHON_USE_UNICODE_INTERNALS
81
#define CYTHON_USE_UNICODE_INTERNALS 1
82
#endif
83
#undef CYTHON_USE_UNICODE_WRITER
84
#define CYTHON_USE_UNICODE_WRITER 0
85
#undef CYTHON_USE_PYLONG_INTERNALS
86
#define CYTHON_USE_PYLONG_INTERNALS 0
87
#ifndef CYTHON_AVOID_BORROWED_REFS
88
#define CYTHON_AVOID_BORROWED_REFS 0
89
#endif
90
#ifndef CYTHON_ASSUME_SAFE_MACROS
91
#define CYTHON_ASSUME_SAFE_MACROS 1
92
#endif
93
#ifndef CYTHON_UNPACK_METHODS
94
#define CYTHON_UNPACK_METHODS 1
95
#endif
96
#undef CYTHON_FAST_THREAD_STATE
97
#define CYTHON_FAST_THREAD_STATE 0
98
#undef CYTHON_FAST_PYCALL
99
#define CYTHON_FAST_PYCALL 0
100
#else
101
#define CYTHON_COMPILING_IN_PYPY 0
102
#define CYTHON_COMPILING_IN_PYSTON 0
103
#define CYTHON_COMPILING_IN_CPYTHON 1
104
#ifndef CYTHON_USE_TYPE_SLOTS
105
#define CYTHON_USE_TYPE_SLOTS 1
106
#endif
107
#if PY_MAJOR_VERSION < 3
108
#undef CYTHON_USE_ASYNC_SLOTS
109
#define CYTHON_USE_ASYNC_SLOTS 0
110
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
111
#define CYTHON_USE_ASYNC_SLOTS 1
112
#endif
113
#if PY_VERSION_HEX < 0x02070000
114
#undef CYTHON_USE_PYLONG_INTERNALS
115
#define CYTHON_USE_PYLONG_INTERNALS 0
116
#elif !defined(CYTHON_USE_PYLONG_INTERNALS)
117
#define CYTHON_USE_PYLONG_INTERNALS 1
118
#endif
119
#ifndef CYTHON_USE_PYLIST_INTERNALS
120
#define CYTHON_USE_PYLIST_INTERNALS 1
121
#endif
122
#ifndef CYTHON_USE_UNICODE_INTERNALS
123
#define CYTHON_USE_UNICODE_INTERNALS 1
124
#endif
125
#if PY_VERSION_HEX < 0x030300F0
126
#undef CYTHON_USE_UNICODE_WRITER
127
#define CYTHON_USE_UNICODE_WRITER 0
128
#elif !defined(CYTHON_USE_UNICODE_WRITER)
129
#define CYTHON_USE_UNICODE_WRITER 1
130
#endif
131
#ifndef CYTHON_AVOID_BORROWED_REFS
132
#define CYTHON_AVOID_BORROWED_REFS 0
133
#endif
134
#ifndef CYTHON_ASSUME_SAFE_MACROS
135
#define CYTHON_ASSUME_SAFE_MACROS 1
136
#endif
137
#ifndef CYTHON_UNPACK_METHODS
138
#define CYTHON_UNPACK_METHODS 1
139
#endif
140
#ifndef CYTHON_FAST_THREAD_STATE
141
#define CYTHON_FAST_THREAD_STATE 1
142
#endif
143
#ifndef CYTHON_FAST_PYCALL
144
#define CYTHON_FAST_PYCALL 1
145
#endif
146
#endif
147
#if !defined(CYTHON_FAST_PYCCALL)
148
#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
149
#endif
150
#if CYTHON_USE_PYLONG_INTERNALS
151
#include "longintrepr.h"
152
#undef SHIFT
153
#undef BASE
154
#undef MASK
155
#endif
156
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
157
#define Py_OptimizeFlag 0
158
#endif
159
#define __PYX_BUILD_PY_SSIZE_T "n"
160
#define CYTHON_FORMAT_SSIZE_T "z"
161
#if PY_MAJOR_VERSION < 3
162
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
163
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
164
PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
165
#define __Pyx_DefaultClassType PyClass_Type
166
#else
167
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
168
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
169
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
170
#define __Pyx_DefaultClassType PyType_Type
171
#endif
172
#ifndef Py_TPFLAGS_CHECKTYPES
173
#define Py_TPFLAGS_CHECKTYPES 0
174
#endif
175
#ifndef Py_TPFLAGS_HAVE_INDEX
176
#define Py_TPFLAGS_HAVE_INDEX 0
177
#endif
178
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
179
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
180
#endif
181
#ifndef Py_TPFLAGS_HAVE_FINALIZE
182
#define Py_TPFLAGS_HAVE_FINALIZE 0
183
#endif
184
#ifndef METH_FASTCALL
185
#define METH_FASTCALL 0x80
186
typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args,
187
Py_ssize_t nargs, PyObject *kwnames);
188
#else
189
#define __Pyx_PyCFunctionFast _PyCFunctionFast
190
#endif
191
#if CYTHON_FAST_PYCCALL
192
#define __Pyx_PyFastCFunction_Check(func)\
193
((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))))
194
#else
195
#define __Pyx_PyFastCFunction_Check(func) 0
196
#endif
197
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
198
#define CYTHON_PEP393_ENABLED 1
199
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
200
0 : _PyUnicode_Ready((PyObject *)(op)))
201
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
202
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
203
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
204
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
205
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
206
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
207
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
208
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
209
#else
210
#define CYTHON_PEP393_ENABLED 0
211
#define PyUnicode_1BYTE_KIND 1
212
#define PyUnicode_2BYTE_KIND 2
213
#define PyUnicode_4BYTE_KIND 4
214
#define __Pyx_PyUnicode_READY(op) (0)
215
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
216
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
217
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
218
#define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
219
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
220
#define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
221
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
222
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
223
#endif
224
#if CYTHON_COMPILING_IN_PYPY
225
#define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
226
#define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
227
#else
228
#define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
229
#define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
230
PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
231
#endif
232
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
233
#define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
234
#endif
235
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
236
#define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
237
#endif
238
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
239
#define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
240
#endif
241
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
242
#define PyObject_Malloc(s) PyMem_Malloc(s)
243
#define PyObject_Free(p) PyMem_Free(p)
244
#define PyObject_Realloc(p) PyMem_Realloc(p)
245
#endif
246
#if CYTHON_COMPILING_IN_PYSTON
247
#define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
248
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
249
#else
250
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
251
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
252
#endif
253
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
254
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
255
#if PY_MAJOR_VERSION >= 3
256
#define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
257
#else
258
#define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
259
#endif
260
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
261
#define PyObject_ASCII(o) PyObject_Repr(o)
262
#endif
263
#if PY_MAJOR_VERSION >= 3
264
#define PyBaseString_Type PyUnicode_Type
265
#define PyStringObject PyUnicodeObject
266
#define PyString_Type PyUnicode_Type
267
#define PyString_Check PyUnicode_Check
268
#define PyString_CheckExact PyUnicode_CheckExact
269
#endif
270
#if PY_MAJOR_VERSION >= 3
271
#define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
272
#define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
273
#else
274
#define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
275
#define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
276
#endif
277
#ifndef PySet_CheckExact
278
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
279
#endif
280
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
281
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
282
#if PY_MAJOR_VERSION >= 3
283
#define PyIntObject PyLongObject
284
#define PyInt_Type PyLong_Type
285
#define PyInt_Check(op) PyLong_Check(op)
286
#define PyInt_CheckExact(op) PyLong_CheckExact(op)
287
#define PyInt_FromString PyLong_FromString
288
#define PyInt_FromUnicode PyLong_FromUnicode
289
#define PyInt_FromLong PyLong_FromLong
290
#define PyInt_FromSize_t PyLong_FromSize_t
291
#define PyInt_FromSsize_t PyLong_FromSsize_t
292
#define PyInt_AsLong PyLong_AsLong
293
#define PyInt_AS_LONG PyLong_AS_LONG
294
#define PyInt_AsSsize_t PyLong_AsSsize_t
295
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
296
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
297
#define PyNumber_Int PyNumber_Long
298
#endif
299
#if PY_MAJOR_VERSION >= 3
300
#define PyBoolObject PyLongObject
301
#endif
302
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
303
#ifndef PyUnicode_InternFromString
304
#define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
305
#endif
306
#endif
307
#if PY_VERSION_HEX < 0x030200A4
308
typedef long Py_hash_t;
309
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
310
#define __Pyx_PyInt_AsHash_t PyInt_AsLong
311
#else
312
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
313
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
314
#endif
315
#if PY_MAJOR_VERSION >= 3
316
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
317
#else
318
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
319
#endif
320
#if CYTHON_USE_ASYNC_SLOTS
321
#if PY_VERSION_HEX >= 0x030500B1
322
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
323
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
324
#else
325
typedef struct {
326
unaryfunc am_await;
327
unaryfunc am_aiter;
328
unaryfunc am_anext;
329
} __Pyx_PyAsyncMethodsStruct;
330
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
331
#endif
332
#else
333
#define __Pyx_PyType_AsAsync(obj) NULL
334
#endif
335
#ifndef CYTHON_RESTRICT
336
#if defined(__GNUC__)
337
#define CYTHON_RESTRICT __restrict__
338
#elif defined(_MSC_VER) && _MSC_VER >= 1400
339
#define CYTHON_RESTRICT __restrict
340
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
341
#define CYTHON_RESTRICT restrict
342
#else
343
#define CYTHON_RESTRICT
344
#endif
345
#endif
346
#ifndef CYTHON_UNUSED
347
# if defined(__GNUC__)
348
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
349
# define CYTHON_UNUSED __attribute__ ((__unused__))
350
# else
351
# define CYTHON_UNUSED
352
# endif
353
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
354
# define CYTHON_UNUSED __attribute__ ((__unused__))
355
# else
356
# define CYTHON_UNUSED
357
# endif
358
#endif
359
#ifndef CYTHON_MAYBE_UNUSED_VAR
360
# if defined(__cplusplus)
361
template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
362
# else
363
# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
364
# endif
365
#endif
366
#ifndef CYTHON_NCP_UNUSED
367
# if CYTHON_COMPILING_IN_CPYTHON
368
# define CYTHON_NCP_UNUSED
369
# else
370
# define CYTHON_NCP_UNUSED CYTHON_UNUSED
371
# endif
372
#endif
373
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
374
375
#ifndef CYTHON_INLINE
376
#if defined(__clang__)
377
#define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
378
#elif defined(__GNUC__)
379
#define CYTHON_INLINE __inline__
380
#elif defined(_MSC_VER)
381
#define CYTHON_INLINE __inline
382
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
383
#define CYTHON_INLINE inline
384
#else
385
#define CYTHON_INLINE
386
#endif
387
#endif
388
389
#if defined(WIN32) || defined(MS_WINDOWS)
390
#define _USE_MATH_DEFINES
391
#endif
392
#include <math.h>
393
#ifdef NAN
394
#define __PYX_NAN() ((float) NAN)
395
#else
396
static CYTHON_INLINE float __PYX_NAN() {
397
float value;
398
memset(&value, 0xFF, sizeof(value));
399
return value;
400
}
401
#endif
402
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
403
#define __Pyx_truncl trunc
404
#else
405
#define __Pyx_truncl truncl
406
#endif
407
408
409
#define __PYX_ERR(f_index, lineno, Ln_error) \
410
{ \
411
__pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
412
}
413
414
#if PY_MAJOR_VERSION >= 3
415
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
416
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
417
#else
418
#define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
419
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
420
#endif
421
422
#ifndef __PYX_EXTERN_C
423
#ifdef __cplusplus
424
#define __PYX_EXTERN_C extern "C"
425
#else
426
#define __PYX_EXTERN_C extern
427
#endif
428
#endif
429
430
#define __PYX_HAVE__code__alex__psage__psage__ellcurve__minmodel__sqrt5
431
#define __PYX_HAVE_API__code__alex__psage__psage__ellcurve__minmodel__sqrt5
432
#include "struct_signals.h"
433
#include "pxi.h"
434
#include <string.h>
435
#include <stdlib.h>
436
#include <stdio.h>
437
#include <math.h>
438
#include "gmp.h"
439
#include <stdint.h>
440
#include "longintrepr.h"
441
#include "sage/libs/ntl/ntlwrap.h"
442
#include "pythread.h"
443
#include "sage/misc/cython_metaclass.h"
444
#ifdef _OPENMP
445
#include <omp.h>
446
#endif /* _OPENMP */
447
448
#ifdef PYREX_WITHOUT_ASSERTIONS
449
#define CYTHON_WITHOUT_ASSERTIONS
450
#endif
451
452
typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
453
const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
454
455
#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
456
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
457
#define __PYX_DEFAULT_STRING_ENCODING ""
458
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
459
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
460
#define __Pyx_uchar_cast(c) ((unsigned char)c)
461
#define __Pyx_long_cast(x) ((long)x)
462
#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
463
(sizeof(type) < sizeof(Py_ssize_t)) ||\
464
(sizeof(type) > sizeof(Py_ssize_t) &&\
465
likely(v < (type)PY_SSIZE_T_MAX ||\
466
v == (type)PY_SSIZE_T_MAX) &&\
467
(!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
468
v == (type)PY_SSIZE_T_MIN))) ||\
469
(sizeof(type) == sizeof(Py_ssize_t) &&\
470
(is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
471
v == (type)PY_SSIZE_T_MAX))) )
472
#if defined (__cplusplus) && __cplusplus >= 201103L
473
#include <cstdlib>
474
#define __Pyx_sst_abs(value) std::abs(value)
475
#elif SIZEOF_INT >= SIZEOF_SIZE_T
476
#define __Pyx_sst_abs(value) abs(value)
477
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
478
#define __Pyx_sst_abs(value) labs(value)
479
#elif defined (_MSC_VER) && defined (_M_X64)
480
#define __Pyx_sst_abs(value) _abs64(value)
481
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
482
#define __Pyx_sst_abs(value) llabs(value)
483
#elif defined (__GNUC__)
484
#define __Pyx_sst_abs(value) __builtin_llabs(value)
485
#else
486
#define __Pyx_sst_abs(value) ((value<0) ? -value : value)
487
#endif
488
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
489
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
490
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
491
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
492
#define __Pyx_PyBytes_FromString PyBytes_FromString
493
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
494
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
495
#if PY_MAJOR_VERSION < 3
496
#define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
497
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
498
#else
499
#define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
500
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
501
#endif
502
#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
503
#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
504
#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
505
#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
506
#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
507
#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
508
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
509
#if PY_MAJOR_VERSION < 3
510
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
511
{
512
const Py_UNICODE *u_end = u;
513
while (*u_end++) ;
514
return (size_t)(u_end - u - 1);
515
}
516
#else
517
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
518
#endif
519
#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
520
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
521
#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
522
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
523
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
524
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
525
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
526
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
527
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
528
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
529
#if CYTHON_ASSUME_SAFE_MACROS
530
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
531
#else
532
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
533
#endif
534
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
535
#if PY_MAJOR_VERSION >= 3
536
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
537
#else
538
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
539
#endif
540
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
541
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
542
static int __Pyx_sys_getdefaultencoding_not_ascii;
543
static int __Pyx_init_sys_getdefaultencoding_params(void) {
544
PyObject* sys;
545
PyObject* default_encoding = NULL;
546
PyObject* ascii_chars_u = NULL;
547
PyObject* ascii_chars_b = NULL;
548
const char* default_encoding_c;
549
sys = PyImport_ImportModule("sys");
550
if (!sys) goto bad;
551
default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
552
Py_DECREF(sys);
553
if (!default_encoding) goto bad;
554
default_encoding_c = PyBytes_AsString(default_encoding);
555
if (!default_encoding_c) goto bad;
556
if (strcmp(default_encoding_c, "ascii") == 0) {
557
__Pyx_sys_getdefaultencoding_not_ascii = 0;
558
} else {
559
char ascii_chars[128];
560
int c;
561
for (c = 0; c < 128; c++) {
562
ascii_chars[c] = c;
563
}
564
__Pyx_sys_getdefaultencoding_not_ascii = 1;
565
ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
566
if (!ascii_chars_u) goto bad;
567
ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
568
if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
569
PyErr_Format(
570
PyExc_ValueError,
571
"This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
572
default_encoding_c);
573
goto bad;
574
}
575
Py_DECREF(ascii_chars_u);
576
Py_DECREF(ascii_chars_b);
577
}
578
Py_DECREF(default_encoding);
579
return 0;
580
bad:
581
Py_XDECREF(default_encoding);
582
Py_XDECREF(ascii_chars_u);
583
Py_XDECREF(ascii_chars_b);
584
return -1;
585
}
586
#endif
587
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
588
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
589
#else
590
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
591
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
592
static char* __PYX_DEFAULT_STRING_ENCODING;
593
static int __Pyx_init_sys_getdefaultencoding_params(void) {
594
PyObject* sys;
595
PyObject* default_encoding = NULL;
596
char* default_encoding_c;
597
sys = PyImport_ImportModule("sys");
598
if (!sys) goto bad;
599
default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
600
Py_DECREF(sys);
601
if (!default_encoding) goto bad;
602
default_encoding_c = PyBytes_AsString(default_encoding);
603
if (!default_encoding_c) goto bad;
604
__PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
605
if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
606
strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
607
Py_DECREF(default_encoding);
608
return 0;
609
bad:
610
Py_XDECREF(default_encoding);
611
return -1;
612
}
613
#endif
614
#endif
615
616
617
/* Test for GCC > 2.95 */
618
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
619
#define likely(x) __builtin_expect(!!(x), 1)
620
#define unlikely(x) __builtin_expect(!!(x), 0)
621
#else /* !__GNUC__ or GCC < 2.95 */
622
#define likely(x) (x)
623
#define unlikely(x) (x)
624
#endif /* __GNUC__ */
625
626
static PyObject *__pyx_m;
627
static PyObject *__pyx_d;
628
static PyObject *__pyx_b;
629
static PyObject *__pyx_empty_tuple;
630
static PyObject *__pyx_empty_bytes;
631
static PyObject *__pyx_empty_unicode;
632
static int __pyx_lineno;
633
static int __pyx_clineno = 0;
634
static const char * __pyx_cfilenm= __FILE__;
635
static const char *__pyx_filename;
636
637
638
static const char *__pyx_f[] = {
639
"code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx",
640
"element.pxd",
641
"memory.pxd",
642
"sage_object.pxd",
643
"stdsage.pxd",
644
"code/alex/psage/psage/ellcurve/minmodel/stringsource",
645
"type.pxd",
646
"bool.pxd",
647
"complex.pxd",
648
"category_object.pxd",
649
"coerce_dict.pxd",
650
"parent.pxd",
651
"inherit_comparison.pxd",
652
"map.pxd",
653
"morphism.pxd",
654
"integer.pxd",
655
"signals.pxi",
656
"stdsage.pxi",
657
};
658
659
/*--- Type declarations ---*/
660
struct __pyx_obj_4sage_9structure_11sage_object_SageObject;
661
struct __pyx_obj_4sage_9structure_15category_object_CategoryObject;
662
struct __pyx_obj_4sage_9structure_11coerce_dict_MonoDict;
663
struct __pyx_obj_4sage_9structure_11coerce_dict_TripleDict;
664
struct __pyx_obj_4sage_9structure_6parent_Parent;
665
struct __pyx_obj_4sage_4misc_18inherit_comparison_InheritComparisonMetaclass;
666
struct __pyx_obj_4sage_9structure_7element_Element;
667
struct __pyx_obj_4sage_9structure_7element_ElementWithCachedMethod;
668
struct __pyx_obj_4sage_9structure_7element_ModuleElement;
669
struct __pyx_obj_4sage_9structure_7element_MonoidElement;
670
struct __pyx_obj_4sage_9structure_7element_MultiplicativeGroupElement;
671
struct __pyx_obj_4sage_9structure_7element_AdditiveGroupElement;
672
struct __pyx_obj_4sage_9structure_7element_RingElement;
673
struct __pyx_obj_4sage_9structure_7element_CommutativeRingElement;
674
struct __pyx_obj_4sage_9structure_7element_IntegralDomainElement;
675
struct __pyx_obj_4sage_9structure_7element_DedekindDomainElement;
676
struct __pyx_obj_4sage_9structure_7element_PrincipalIdealDomainElement;
677
struct __pyx_obj_4sage_9structure_7element_EuclideanDomainElement;
678
struct __pyx_obj_4sage_9structure_7element_FieldElement;
679
struct __pyx_obj_4sage_9structure_7element_AlgebraElement;
680
struct __pyx_obj_4sage_9structure_7element_CommutativeAlgebraElement;
681
struct __pyx_obj_4sage_9structure_7element_InfinityElement;
682
struct __pyx_obj_4sage_9structure_7element_Vector;
683
struct __pyx_obj_4sage_9structure_7element_Matrix;
684
struct __pyx_obj_4sage_9structure_7element_CoercionModel;
685
struct __pyx_obj_4sage_10categories_3map_Map;
686
struct __pyx_obj_4sage_10categories_3map_Section;
687
struct __pyx_obj_4sage_10categories_3map_FormalCompositeMap;
688
struct __pyx_obj_4sage_10categories_8morphism_Morphism;
689
struct __pyx_obj_4sage_10categories_8morphism_SetMorphism;
690
struct __pyx_obj_4sage_5rings_7integer_Integer;
691
struct __pyx_obj_4sage_5rings_7integer_int_to_Z;
692
struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py;
693
struct __pyx_opt_args_4sage_9structure_6parent_6Parent_init_coerce;
694
struct __pyx_opt_args_4sage_9structure_6parent_6Parent_get_action;
695
struct __pyx_opt_args_4sage_9structure_6parent_6Parent_discover_action;
696
697
/* "parent.pxd":102
698
*
699
* # Flags for Parent.flags
700
* cdef enum: # <<<<<<<<<<<<<<
701
* # If this flag is set, call __richcmp__ on elements without
702
* # coercion. This allows a completely custom comparison function.
703
*/
704
enum {
705
__pyx_e_4sage_9structure_6parent_Parent_richcmp_element_without_coercion = 1
706
};
707
708
/* "parent.pxd":38
709
*
710
* # Called from the __init__ method to set up coercion.
711
* cdef int init_coerce(self, bint warn=*) except -1 # <<<<<<<<<<<<<<
712
*
713
* # returns whether or not there is a Morphism from S to self
714
*/
715
struct __pyx_opt_args_4sage_9structure_6parent_6Parent_init_coerce {
716
int __pyx_n;
717
int warn;
718
};
719
720
/* "parent.pxd":55
721
* # returns the Action by/on self on/by S
722
* # corresponding to op and self_on_left
723
* cpdef get_action(self, S, op=*, bint self_on_left=*, self_el=*, S_el=*) # <<<<<<<<<<<<<<
724
* cpdef _get_action_(self, S, op, bint self_on_left)
725
*
726
*/
727
struct __pyx_opt_args_4sage_9structure_6parent_6Parent_get_action {
728
int __pyx_n;
729
PyObject *op;
730
int self_on_left;
731
PyObject *self_el;
732
PyObject *S_el;
733
};
734
735
/* "parent.pxd":68
736
* cdef discover_coerce_map_from(self, S)
737
* cdef discover_convert_map_from(self, S)
738
* cdef discover_action(self, S, op, bint self_on_left, self_el=*, S_el=*) # <<<<<<<<<<<<<<
739
*
740
* # List consisting of Morphisms (from anything to self)
741
*/
742
struct __pyx_opt_args_4sage_9structure_6parent_6Parent_discover_action {
743
int __pyx_n;
744
PyObject *self_el;
745
PyObject *S_el;
746
};
747
struct __pyx_opt_args_4sage_10categories_3map_3Map__call_with_args;
748
749
/* "map.pxd":15
750
* # these methods require x is an element of domain, and returns an element with parent codomain
751
* cpdef Element _call_(self, x)
752
* cpdef Element _call_with_args(self, x, args=*, kwds=*) # <<<<<<<<<<<<<<
753
*
754
* cdef public domain # will be either a weakref or a constant map
755
*/
756
struct __pyx_opt_args_4sage_10categories_3map_3Map__call_with_args {
757
int __pyx_n;
758
PyObject *args;
759
PyObject *kwds;
760
};
761
762
/* "sage_object.pxd":9
763
*
764
*
765
* cdef class SageObject: # <<<<<<<<<<<<<<
766
* pass
767
*
768
*/
769
struct __pyx_obj_4sage_9structure_11sage_object_SageObject {
770
PyObject_HEAD
771
};
772
773
774
/* "sage/structure/category_object.pxd":15
775
* cpdef check_default_category(default_category, category)
776
*
777
* cdef class CategoryObject(SageObject): # <<<<<<<<<<<<<<
778
* cdef public dict __cached_methods
779
* cdef _category
780
*/
781
struct __pyx_obj_4sage_9structure_15category_object_CategoryObject {
782
struct __pyx_obj_4sage_9structure_11sage_object_SageObject __pyx_base;
783
struct __pyx_vtabstruct_4sage_9structure_15category_object_CategoryObject *__pyx_vtab;
784
PyObject *__cached_methods;
785
PyObject *_category;
786
PyObject *_base;
787
PyObject *_names;
788
PyObject *_factory_data;
789
PyObject *__weakref__;
790
long _hash_value;
791
};
792
793
794
/* "sage/structure/coerce_dict.pxd":7
795
*
796
* @cython.final
797
* cdef class MonoDict: # <<<<<<<<<<<<<<
798
* cdef __weakref__
799
* cdef size_t mask
800
*/
801
struct __pyx_obj_4sage_9structure_11coerce_dict_MonoDict {
802
PyObject_HEAD
803
struct __pyx_vtabstruct_4sage_9structure_11coerce_dict_MonoDict *__pyx_vtab;
804
PyObject *__weakref__;
805
size_t mask;
806
size_t used;
807
size_t fill;
808
struct __pyx_t_4sage_9structure_11coerce_dict_mono_cell *table;
809
int weak_values;
810
PyObject *eraser;
811
};
812
813
814
/* "sage/structure/coerce_dict.pxd":23
815
*
816
* @cython.final
817
* cdef class TripleDict: # <<<<<<<<<<<<<<
818
* cdef __weakref__
819
* cdef size_t mask
820
*/
821
struct __pyx_obj_4sage_9structure_11coerce_dict_TripleDict {
822
PyObject_HEAD
823
struct __pyx_vtabstruct_4sage_9structure_11coerce_dict_TripleDict *__pyx_vtab;
824
PyObject *__weakref__;
825
size_t mask;
826
size_t used;
827
size_t fill;
828
struct __pyx_t_4sage_9structure_11coerce_dict_triple_cell *table;
829
int weak_values;
830
PyObject *eraser;
831
};
832
833
834
/* "parent.pxd":12
835
* from sage.structure.coerce_dict cimport MonoDict, TripleDict
836
*
837
* cdef class Parent(category_object.CategoryObject): # <<<<<<<<<<<<<<
838
* cdef public _element_constructor
839
* cdef public _convert_method_name
840
*/
841
struct __pyx_obj_4sage_9structure_6parent_Parent {
842
struct __pyx_obj_4sage_9structure_15category_object_CategoryObject __pyx_base;
843
PyObject *_element_constructor;
844
PyObject *_convert_method_name;
845
int _element_init_pass_parent;
846
PyObject *_initial_coerce_list;
847
PyObject *_initial_action_list;
848
PyObject *_initial_convert_list;
849
int _coercions_used;
850
int flags;
851
PyObject *_cache_an_element;
852
PyObject *_coerce_from_list;
853
PyObject *_registered_domains;
854
struct __pyx_obj_4sage_9structure_11coerce_dict_MonoDict *_coerce_from_hash;
855
PyObject *_action_list;
856
struct __pyx_obj_4sage_9structure_11coerce_dict_TripleDict *_action_hash;
857
PyObject *_convert_from_list;
858
struct __pyx_obj_4sage_9structure_11coerce_dict_MonoDict *_convert_from_hash;
859
PyObject *_embedding;
860
};
861
862
863
/* "sage/misc/inherit_comparison.pxd":3
864
* cimport sage.misc.cython_metaclass
865
*
866
* cdef class InheritComparisonMetaclass(type): # <<<<<<<<<<<<<<
867
* pass
868
*/
869
struct __pyx_obj_4sage_4misc_18inherit_comparison_InheritComparisonMetaclass {
870
PyHeapTypeObject __pyx_base;
871
};
872
873
874
/* "sage/structure/element.pxd":169
875
*
876
*
877
* cdef class Element(SageObject): # <<<<<<<<<<<<<<
878
* cdef Parent _parent
879
* cpdef _richcmp_(left, right, int op)
880
*/
881
struct __pyx_obj_4sage_9structure_7element_Element {
882
struct __pyx_obj_4sage_9structure_11sage_object_SageObject __pyx_base;
883
struct __pyx_vtabstruct_4sage_9structure_7element_Element *__pyx_vtab;
884
struct __pyx_obj_4sage_9structure_6parent_Parent *_parent;
885
};
886
887
888
/* "sage/structure/element.pxd":192
889
*
890
*
891
* cdef class ElementWithCachedMethod(Element): # <<<<<<<<<<<<<<
892
* cdef public dict __cached_methods
893
*
894
*/
895
struct __pyx_obj_4sage_9structure_7element_ElementWithCachedMethod {
896
struct __pyx_obj_4sage_9structure_7element_Element __pyx_base;
897
PyObject *__cached_methods;
898
};
899
900
901
/* "sage/structure/element.pxd":195
902
* cdef public dict __cached_methods
903
*
904
* cdef class ModuleElement(Element) # forward declaration # <<<<<<<<<<<<<<
905
*
906
* cdef class RingElement(ModuleElement) # forward declaration
907
*/
908
struct __pyx_obj_4sage_9structure_7element_ModuleElement {
909
struct __pyx_obj_4sage_9structure_7element_Element __pyx_base;
910
};
911
912
913
/* "sage/structure/element.pxd":208
914
* cpdef _rmul_(self, RingElement left)
915
*
916
* cdef class MonoidElement(Element): # <<<<<<<<<<<<<<
917
* pass
918
*
919
*/
920
struct __pyx_obj_4sage_9structure_7element_MonoidElement {
921
struct __pyx_obj_4sage_9structure_7element_Element __pyx_base;
922
};
923
924
925
/* "sage/structure/element.pxd":211
926
* pass
927
*
928
* cdef class MultiplicativeGroupElement(MonoidElement): # <<<<<<<<<<<<<<
929
* cpdef _div_(self, right)
930
*
931
*/
932
struct __pyx_obj_4sage_9structure_7element_MultiplicativeGroupElement {
933
struct __pyx_obj_4sage_9structure_7element_MonoidElement __pyx_base;
934
};
935
936
937
/* "sage/structure/element.pxd":214
938
* cpdef _div_(self, right)
939
*
940
* cdef class AdditiveGroupElement(ModuleElement): # <<<<<<<<<<<<<<
941
* pass
942
*
943
*/
944
struct __pyx_obj_4sage_9structure_7element_AdditiveGroupElement {
945
struct __pyx_obj_4sage_9structure_7element_ModuleElement __pyx_base;
946
};
947
948
949
/* "sage/structure/element.pxd":197
950
* cdef class ModuleElement(Element) # forward declaration
951
*
952
* cdef class RingElement(ModuleElement) # forward declaration # <<<<<<<<<<<<<<
953
*
954
* cdef class ModuleElement(Element):
955
*/
956
struct __pyx_obj_4sage_9structure_7element_RingElement {
957
struct __pyx_obj_4sage_9structure_7element_ModuleElement __pyx_base;
958
};
959
960
961
/* "sage/structure/element.pxd":220
962
* cpdef _div_(self, right)
963
*
964
* cdef class CommutativeRingElement(RingElement): # <<<<<<<<<<<<<<
965
* pass
966
*
967
*/
968
struct __pyx_obj_4sage_9structure_7element_CommutativeRingElement {
969
struct __pyx_obj_4sage_9structure_7element_RingElement __pyx_base;
970
};
971
972
973
/* "sage/structure/element.pxd":223
974
* pass
975
*
976
* cdef class IntegralDomainElement(CommutativeRingElement): # <<<<<<<<<<<<<<
977
* pass
978
*
979
*/
980
struct __pyx_obj_4sage_9structure_7element_IntegralDomainElement {
981
struct __pyx_obj_4sage_9structure_7element_CommutativeRingElement __pyx_base;
982
};
983
984
985
/* "sage/structure/element.pxd":226
986
* pass
987
*
988
* cdef class DedekindDomainElement(IntegralDomainElement): # <<<<<<<<<<<<<<
989
* pass
990
*
991
*/
992
struct __pyx_obj_4sage_9structure_7element_DedekindDomainElement {
993
struct __pyx_obj_4sage_9structure_7element_IntegralDomainElement __pyx_base;
994
};
995
996
997
/* "sage/structure/element.pxd":229
998
* pass
999
*
1000
* cdef class PrincipalIdealDomainElement(DedekindDomainElement): # <<<<<<<<<<<<<<
1001
* pass
1002
*
1003
*/
1004
struct __pyx_obj_4sage_9structure_7element_PrincipalIdealDomainElement {
1005
struct __pyx_obj_4sage_9structure_7element_DedekindDomainElement __pyx_base;
1006
};
1007
1008
1009
/* "sage/structure/element.pxd":232
1010
* pass
1011
*
1012
* cdef class EuclideanDomainElement(PrincipalIdealDomainElement): # <<<<<<<<<<<<<<
1013
* cpdef _floordiv_(self, right)
1014
* cpdef _mod_(self, right)
1015
*/
1016
struct __pyx_obj_4sage_9structure_7element_EuclideanDomainElement {
1017
struct __pyx_obj_4sage_9structure_7element_PrincipalIdealDomainElement __pyx_base;
1018
};
1019
1020
1021
/* "sage/structure/element.pxd":236
1022
* cpdef _mod_(self, right)
1023
*
1024
* cdef class FieldElement(CommutativeRingElement): # <<<<<<<<<<<<<<
1025
* cpdef _floordiv_(self, right)
1026
*
1027
*/
1028
struct __pyx_obj_4sage_9structure_7element_FieldElement {
1029
struct __pyx_obj_4sage_9structure_7element_CommutativeRingElement __pyx_base;
1030
};
1031
1032
1033
/* "sage/structure/element.pxd":239
1034
* cpdef _floordiv_(self, right)
1035
*
1036
* cdef class AlgebraElement(RingElement): # <<<<<<<<<<<<<<
1037
* pass
1038
*
1039
*/
1040
struct __pyx_obj_4sage_9structure_7element_AlgebraElement {
1041
struct __pyx_obj_4sage_9structure_7element_RingElement __pyx_base;
1042
};
1043
1044
1045
/* "sage/structure/element.pxd":242
1046
* pass
1047
*
1048
* cdef class CommutativeAlgebraElement(CommutativeRingElement): # <<<<<<<<<<<<<<
1049
* pass
1050
*
1051
*/
1052
struct __pyx_obj_4sage_9structure_7element_CommutativeAlgebraElement {
1053
struct __pyx_obj_4sage_9structure_7element_CommutativeRingElement __pyx_base;
1054
};
1055
1056
1057
/* "sage/structure/element.pxd":245
1058
* pass
1059
*
1060
* cdef class InfinityElement(RingElement): # <<<<<<<<<<<<<<
1061
* pass
1062
*
1063
*/
1064
struct __pyx_obj_4sage_9structure_7element_InfinityElement {
1065
struct __pyx_obj_4sage_9structure_7element_RingElement __pyx_base;
1066
};
1067
1068
1069
/* "sage/structure/element.pxd":249
1070
*
1071
*
1072
* cdef class Vector(ModuleElement): # <<<<<<<<<<<<<<
1073
* cdef Py_ssize_t _degree
1074
*
1075
*/
1076
struct __pyx_obj_4sage_9structure_7element_Vector {
1077
struct __pyx_obj_4sage_9structure_7element_ModuleElement __pyx_base;
1078
Py_ssize_t _degree;
1079
};
1080
1081
1082
/* "sage/structure/element.pxd":264
1083
*
1084
*
1085
* cdef class Matrix(ModuleElement): # <<<<<<<<<<<<<<
1086
* # All matrix classes must be written in Cython
1087
* cdef Py_ssize_t _nrows
1088
*/
1089
struct __pyx_obj_4sage_9structure_7element_Matrix {
1090
struct __pyx_obj_4sage_9structure_7element_ModuleElement __pyx_base;
1091
Py_ssize_t _nrows;
1092
Py_ssize_t _ncols;
1093
};
1094
1095
1096
/* "sage/structure/element.pxd":277
1097
*
1098
*
1099
* cdef class CoercionModel: # <<<<<<<<<<<<<<
1100
* cpdef canonical_coercion(self, x, y)
1101
* cpdef bin_op(self, x, y, op)
1102
*/
1103
struct __pyx_obj_4sage_9structure_7element_CoercionModel {
1104
PyObject_HEAD
1105
struct __pyx_vtabstruct_4sage_9structure_7element_CoercionModel *__pyx_vtab;
1106
};
1107
1108
1109
/* "map.pxd":4
1110
* from sage.structure.element cimport Element
1111
*
1112
* cdef class Map(Element): # <<<<<<<<<<<<<<
1113
* cdef object __weakref__
1114
*
1115
*/
1116
struct __pyx_obj_4sage_10categories_3map_Map {
1117
struct __pyx_obj_4sage_9structure_7element_Element __pyx_base;
1118
PyObject *__weakref__;
1119
int _coerce_cost;
1120
PyObject *domain;
1121
PyObject *codomain;
1122
struct __pyx_obj_4sage_9structure_6parent_Parent *_codomain;
1123
PyObject *_category_for;
1124
PyObject *_repr_type_str;
1125
};
1126
1127
1128
/* "map.pxd":25
1129
*
1130
*
1131
* cdef class Section(Map): # <<<<<<<<<<<<<<
1132
* cdef Map _inverse
1133
*
1134
*/
1135
struct __pyx_obj_4sage_10categories_3map_Section {
1136
struct __pyx_obj_4sage_10categories_3map_Map __pyx_base;
1137
struct __pyx_obj_4sage_10categories_3map_Map *_inverse;
1138
};
1139
1140
1141
/* "map.pxd":28
1142
* cdef Map _inverse
1143
*
1144
* cdef class FormalCompositeMap(Map): # <<<<<<<<<<<<<<
1145
* cdef __list
1146
*/
1147
struct __pyx_obj_4sage_10categories_3map_FormalCompositeMap {
1148
struct __pyx_obj_4sage_10categories_3map_Map __pyx_base;
1149
PyObject *__pyx___list;
1150
};
1151
1152
1153
/* "sage/categories/morphism.pxd":5
1154
* from .map cimport Map
1155
*
1156
* cdef class Morphism(Map): # <<<<<<<<<<<<<<
1157
* pass
1158
*
1159
*/
1160
struct __pyx_obj_4sage_10categories_8morphism_Morphism {
1161
struct __pyx_obj_4sage_10categories_3map_Map __pyx_base;
1162
};
1163
1164
1165
/* "sage/categories/morphism.pxd":8
1166
* pass
1167
*
1168
* cdef class SetMorphism(Morphism): # <<<<<<<<<<<<<<
1169
* cdef object _function
1170
* cpdef bint _eq_c_impl(left, Element right)
1171
*/
1172
struct __pyx_obj_4sage_10categories_8morphism_SetMorphism {
1173
struct __pyx_obj_4sage_10categories_8morphism_Morphism __pyx_base;
1174
PyObject *_function;
1175
};
1176
1177
1178
/* "sage/rings/integer.pxd":7
1179
* from sage.categories.morphism cimport Morphism
1180
*
1181
* cdef class Integer(EuclideanDomainElement): # <<<<<<<<<<<<<<
1182
* cdef mpz_t value
1183
*
1184
*/
1185
struct __pyx_obj_4sage_5rings_7integer_Integer {
1186
struct __pyx_obj_4sage_9structure_7element_EuclideanDomainElement __pyx_base;
1187
mpz_t value;
1188
};
1189
1190
1191
/* "sage/rings/integer.pxd":37
1192
* cdef Integer smallInteger(long value)
1193
*
1194
* cdef class int_to_Z(Morphism): # <<<<<<<<<<<<<<
1195
* pass
1196
*/
1197
struct __pyx_obj_4sage_5rings_7integer_int_to_Z {
1198
struct __pyx_obj_4sage_10categories_8morphism_Morphism __pyx_base;
1199
};
1200
1201
1202
/* "cfunc.to_py":64
1203
*
1204
* @cname("__Pyx_CFunc_object____object____object____int___to_py")
1205
* cdef object __Pyx_CFunc_object____object____object____int___to_py(object (*f)(object, object, int) ): # <<<<<<<<<<<<<<
1206
* def wrap(object arg0, object arg1, int arg2):
1207
* """wrap(arg0, arg1, arg2: 'int')"""
1208
*/
1209
struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py {
1210
PyObject_HEAD
1211
PyObject *(*__pyx_v_f)(PyObject *, PyObject *, int);
1212
};
1213
1214
1215
1216
/* "sage/structure/category_object.pxd":15
1217
* cpdef check_default_category(default_category, category)
1218
*
1219
* cdef class CategoryObject(SageObject): # <<<<<<<<<<<<<<
1220
* cdef public dict __cached_methods
1221
* cdef _category
1222
*/
1223
1224
struct __pyx_vtabstruct_4sage_9structure_15category_object_CategoryObject {
1225
PyObject *(*getattr_from_category)(struct __pyx_obj_4sage_9structure_15category_object_CategoryObject *, PyObject *);
1226
};
1227
static struct __pyx_vtabstruct_4sage_9structure_15category_object_CategoryObject *__pyx_vtabptr_4sage_9structure_15category_object_CategoryObject;
1228
1229
1230
/* "sage/structure/coerce_dict.pxd":7
1231
*
1232
* @cython.final
1233
* cdef class MonoDict: # <<<<<<<<<<<<<<
1234
* cdef __weakref__
1235
* cdef size_t mask
1236
*/
1237
1238
struct __pyx_vtabstruct_4sage_9structure_11coerce_dict_MonoDict {
1239
struct __pyx_t_4sage_9structure_11coerce_dict_mono_cell *(*lookup)(struct __pyx_obj_4sage_9structure_11coerce_dict_MonoDict *, PyObject *);
1240
PyObject *(*get)(struct __pyx_obj_4sage_9structure_11coerce_dict_MonoDict *, PyObject *);
1241
PyObject *(*set)(struct __pyx_obj_4sage_9structure_11coerce_dict_MonoDict *, PyObject *, PyObject *);
1242
int (*resize)(struct __pyx_obj_4sage_9structure_11coerce_dict_MonoDict *);
1243
};
1244
static struct __pyx_vtabstruct_4sage_9structure_11coerce_dict_MonoDict *__pyx_vtabptr_4sage_9structure_11coerce_dict_MonoDict;
1245
1246
1247
/* "sage/structure/coerce_dict.pxd":23
1248
*
1249
* @cython.final
1250
* cdef class TripleDict: # <<<<<<<<<<<<<<
1251
* cdef __weakref__
1252
* cdef size_t mask
1253
*/
1254
1255
struct __pyx_vtabstruct_4sage_9structure_11coerce_dict_TripleDict {
1256
struct __pyx_t_4sage_9structure_11coerce_dict_triple_cell *(*lookup)(struct __pyx_obj_4sage_9structure_11coerce_dict_TripleDict *, PyObject *, PyObject *, PyObject *);
1257
PyObject *(*get)(struct __pyx_obj_4sage_9structure_11coerce_dict_TripleDict *, PyObject *, PyObject *, PyObject *);
1258
PyObject *(*set)(struct __pyx_obj_4sage_9structure_11coerce_dict_TripleDict *, PyObject *, PyObject *, PyObject *, PyObject *);
1259
int (*resize)(struct __pyx_obj_4sage_9structure_11coerce_dict_TripleDict *);
1260
};
1261
static struct __pyx_vtabstruct_4sage_9structure_11coerce_dict_TripleDict *__pyx_vtabptr_4sage_9structure_11coerce_dict_TripleDict;
1262
1263
1264
/* "parent.pxd":12
1265
* from sage.structure.coerce_dict cimport MonoDict, TripleDict
1266
*
1267
* cdef class Parent(category_object.CategoryObject): # <<<<<<<<<<<<<<
1268
* cdef public _element_constructor
1269
* cdef public _convert_method_name
1270
*/
1271
1272
struct __pyx_vtabstruct_4sage_9structure_6parent_Parent {
1273
struct __pyx_vtabstruct_4sage_9structure_15category_object_CategoryObject __pyx_base;
1274
int (*get_flag)(struct __pyx_obj_4sage_9structure_6parent_Parent *, int);
1275
int (*is_coercion_cached)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1276
int (*is_conversion_cached)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1277
PyObject *(*register_coercion)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1278
PyObject *(*register_action)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1279
PyObject *(*register_conversion)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1280
PyObject *(*register_embedding)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1281
int (*_richcmp)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int, int __pyx_skip_dispatch);
1282
int (*_cmp_)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1283
int (*is_exact)(struct __pyx_obj_4sage_9structure_6parent_Parent *, int __pyx_skip_dispatch);
1284
int (*init_coerce)(struct __pyx_obj_4sage_9structure_6parent_Parent *, struct __pyx_opt_args_4sage_9structure_6parent_6Parent_init_coerce *__pyx_optional_args);
1285
int (*has_coerce_map_from)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1286
PyObject *(*coerce_map_from)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1287
PyObject *(*_internal_coerce_map_from)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1288
PyObject *(*_coerce_map_from_)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1289
PyObject *(*convert_map_from)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1290
PyObject *(*_internal_convert_map_from)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1291
PyObject *(*_convert_map_from_)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1292
PyObject *(*get_action)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4sage_9structure_6parent_6Parent_get_action *__pyx_optional_args);
1293
PyObject *(*_get_action_)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, PyObject *, int, int __pyx_skip_dispatch);
1294
PyObject *(*coerce)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1295
PyObject *(*an_element)(struct __pyx_obj_4sage_9structure_6parent_Parent *, int __pyx_skip_dispatch);
1296
PyObject *(*_generic_convert_map)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, int __pyx_skip_dispatch);
1297
PyObject *(*discover_coerce_map_from)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *);
1298
PyObject *(*discover_convert_map_from)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *);
1299
PyObject *(*discover_action)(struct __pyx_obj_4sage_9structure_6parent_Parent *, PyObject *, PyObject *, int, struct __pyx_opt_args_4sage_9structure_6parent_6Parent_discover_action *__pyx_optional_args);
1300
};
1301
static struct __pyx_vtabstruct_4sage_9structure_6parent_Parent *__pyx_vtabptr_4sage_9structure_6parent_Parent;
1302
static CYTHON_INLINE int __pyx_f_4sage_9structure_6parent_6Parent_get_flag(struct __pyx_obj_4sage_9structure_6parent_Parent *, int);
1303
1304
1305
/* "sage/structure/element.pxd":169
1306
*
1307
*
1308
* cdef class Element(SageObject): # <<<<<<<<<<<<<<
1309
* cdef Parent _parent
1310
* cpdef _richcmp_(left, right, int op)
1311
*/
1312
1313
struct __pyx_vtabstruct_4sage_9structure_7element_Element {
1314
PyObject *(*_richcmp_)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *, int, int __pyx_skip_dispatch);
1315
int (*_cmp_)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *, int __pyx_skip_dispatch);
1316
PyObject *(*base_extend)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *, int __pyx_skip_dispatch);
1317
PyObject *(*getattr_from_category)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *);
1318
PyObject *(*_act_on_)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *, int, int __pyx_skip_dispatch);
1319
PyObject *(*_acted_upon_)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *, int, int __pyx_skip_dispatch);
1320
PyObject *(*_add_)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *);
1321
PyObject *(*_sub_)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *);
1322
PyObject *(*_neg_)(struct __pyx_obj_4sage_9structure_7element_Element *);
1323
PyObject *(*_add_long)(struct __pyx_obj_4sage_9structure_7element_Element *, long);
1324
PyObject *(*_mul_)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *);
1325
PyObject *(*_mul_long)(struct __pyx_obj_4sage_9structure_7element_Element *, long);
1326
PyObject *(*_div_)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *);
1327
PyObject *(*_floordiv_)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *);
1328
PyObject *(*_mod_)(struct __pyx_obj_4sage_9structure_7element_Element *, PyObject *);
1329
};
1330
static struct __pyx_vtabstruct_4sage_9structure_7element_Element *__pyx_vtabptr_4sage_9structure_7element_Element;
1331
1332
1333
/* "sage/structure/element.pxd":192
1334
*
1335
*
1336
* cdef class ElementWithCachedMethod(Element): # <<<<<<<<<<<<<<
1337
* cdef public dict __cached_methods
1338
*
1339
*/
1340
1341
struct __pyx_vtabstruct_4sage_9structure_7element_ElementWithCachedMethod {
1342
struct __pyx_vtabstruct_4sage_9structure_7element_Element __pyx_base;
1343
};
1344
static struct __pyx_vtabstruct_4sage_9structure_7element_ElementWithCachedMethod *__pyx_vtabptr_4sage_9structure_7element_ElementWithCachedMethod;
1345
1346
1347
/* "sage/structure/element.pxd":195
1348
* cdef public dict __cached_methods
1349
*
1350
* cdef class ModuleElement(Element) # forward declaration # <<<<<<<<<<<<<<
1351
*
1352
* cdef class RingElement(ModuleElement) # forward declaration
1353
*/
1354
1355
struct __pyx_vtabstruct_4sage_9structure_7element_ModuleElement {
1356
struct __pyx_vtabstruct_4sage_9structure_7element_Element __pyx_base;
1357
PyObject *(*_sub_)(struct __pyx_obj_4sage_9structure_7element_ModuleElement *, PyObject *, int __pyx_skip_dispatch);
1358
PyObject *(*_neg_)(struct __pyx_obj_4sage_9structure_7element_ModuleElement *, int __pyx_skip_dispatch);
1359
PyObject *(*_lmul_)(struct __pyx_obj_4sage_9structure_7element_ModuleElement *, struct __pyx_obj_4sage_9structure_7element_RingElement *, int __pyx_skip_dispatch);
1360
PyObject *(*_rmul_)(struct __pyx_obj_4sage_9structure_7element_ModuleElement *, struct __pyx_obj_4sage_9structure_7element_RingElement *, int __pyx_skip_dispatch);
1361
};
1362
static struct __pyx_vtabstruct_4sage_9structure_7element_ModuleElement *__pyx_vtabptr_4sage_9structure_7element_ModuleElement;
1363
1364
1365
/* "sage/structure/element.pxd":197
1366
* cdef class ModuleElement(Element) # forward declaration
1367
*
1368
* cdef class RingElement(ModuleElement) # forward declaration # <<<<<<<<<<<<<<
1369
*
1370
* cdef class ModuleElement(Element):
1371
*/
1372
1373
struct __pyx_vtabstruct_4sage_9structure_7element_RingElement {
1374
struct __pyx_vtabstruct_4sage_9structure_7element_ModuleElement __pyx_base;
1375
PyObject *(*_div_)(struct __pyx_obj_4sage_9structure_7element_RingElement *, PyObject *, int __pyx_skip_dispatch);
1376
};
1377
static struct __pyx_vtabstruct_4sage_9structure_7element_RingElement *__pyx_vtabptr_4sage_9structure_7element_RingElement;
1378
1379
1380
/* "sage/structure/element.pxd":208
1381
* cpdef _rmul_(self, RingElement left)
1382
*
1383
* cdef class MonoidElement(Element): # <<<<<<<<<<<<<<
1384
* pass
1385
*
1386
*/
1387
1388
struct __pyx_vtabstruct_4sage_9structure_7element_MonoidElement {
1389
struct __pyx_vtabstruct_4sage_9structure_7element_Element __pyx_base;
1390
};
1391
static struct __pyx_vtabstruct_4sage_9structure_7element_MonoidElement *__pyx_vtabptr_4sage_9structure_7element_MonoidElement;
1392
1393
1394
/* "sage/structure/element.pxd":211
1395
* pass
1396
*
1397
* cdef class MultiplicativeGroupElement(MonoidElement): # <<<<<<<<<<<<<<
1398
* cpdef _div_(self, right)
1399
*
1400
*/
1401
1402
struct __pyx_vtabstruct_4sage_9structure_7element_MultiplicativeGroupElement {
1403
struct __pyx_vtabstruct_4sage_9structure_7element_MonoidElement __pyx_base;
1404
PyObject *(*_div_)(struct __pyx_obj_4sage_9structure_7element_MultiplicativeGroupElement *, PyObject *, int __pyx_skip_dispatch);
1405
};
1406
static struct __pyx_vtabstruct_4sage_9structure_7element_MultiplicativeGroupElement *__pyx_vtabptr_4sage_9structure_7element_MultiplicativeGroupElement;
1407
1408
1409
/* "sage/structure/element.pxd":214
1410
* cpdef _div_(self, right)
1411
*
1412
* cdef class AdditiveGroupElement(ModuleElement): # <<<<<<<<<<<<<<
1413
* pass
1414
*
1415
*/
1416
1417
struct __pyx_vtabstruct_4sage_9structure_7element_AdditiveGroupElement {
1418
struct __pyx_vtabstruct_4sage_9structure_7element_ModuleElement __pyx_base;
1419
};
1420
static struct __pyx_vtabstruct_4sage_9structure_7element_AdditiveGroupElement *__pyx_vtabptr_4sage_9structure_7element_AdditiveGroupElement;
1421
1422
1423
/* "sage/structure/element.pxd":220
1424
* cpdef _div_(self, right)
1425
*
1426
* cdef class CommutativeRingElement(RingElement): # <<<<<<<<<<<<<<
1427
* pass
1428
*
1429
*/
1430
1431
struct __pyx_vtabstruct_4sage_9structure_7element_CommutativeRingElement {
1432
struct __pyx_vtabstruct_4sage_9structure_7element_RingElement __pyx_base;
1433
};
1434
static struct __pyx_vtabstruct_4sage_9structure_7element_CommutativeRingElement *__pyx_vtabptr_4sage_9structure_7element_CommutativeRingElement;
1435
1436
1437
/* "sage/structure/element.pxd":223
1438
* pass
1439
*
1440
* cdef class IntegralDomainElement(CommutativeRingElement): # <<<<<<<<<<<<<<
1441
* pass
1442
*
1443
*/
1444
1445
struct __pyx_vtabstruct_4sage_9structure_7element_IntegralDomainElement {
1446
struct __pyx_vtabstruct_4sage_9structure_7element_CommutativeRingElement __pyx_base;
1447
};
1448
static struct __pyx_vtabstruct_4sage_9structure_7element_IntegralDomainElement *__pyx_vtabptr_4sage_9structure_7element_IntegralDomainElement;
1449
1450
1451
/* "sage/structure/element.pxd":226
1452
* pass
1453
*
1454
* cdef class DedekindDomainElement(IntegralDomainElement): # <<<<<<<<<<<<<<
1455
* pass
1456
*
1457
*/
1458
1459
struct __pyx_vtabstruct_4sage_9structure_7element_DedekindDomainElement {
1460
struct __pyx_vtabstruct_4sage_9structure_7element_IntegralDomainElement __pyx_base;
1461
};
1462
static struct __pyx_vtabstruct_4sage_9structure_7element_DedekindDomainElement *__pyx_vtabptr_4sage_9structure_7element_DedekindDomainElement;
1463
1464
1465
/* "sage/structure/element.pxd":229
1466
* pass
1467
*
1468
* cdef class PrincipalIdealDomainElement(DedekindDomainElement): # <<<<<<<<<<<<<<
1469
* pass
1470
*
1471
*/
1472
1473
struct __pyx_vtabstruct_4sage_9structure_7element_PrincipalIdealDomainElement {
1474
struct __pyx_vtabstruct_4sage_9structure_7element_DedekindDomainElement __pyx_base;
1475
};
1476
static struct __pyx_vtabstruct_4sage_9structure_7element_PrincipalIdealDomainElement *__pyx_vtabptr_4sage_9structure_7element_PrincipalIdealDomainElement;
1477
1478
1479
/* "sage/structure/element.pxd":232
1480
* pass
1481
*
1482
* cdef class EuclideanDomainElement(PrincipalIdealDomainElement): # <<<<<<<<<<<<<<
1483
* cpdef _floordiv_(self, right)
1484
* cpdef _mod_(self, right)
1485
*/
1486
1487
struct __pyx_vtabstruct_4sage_9structure_7element_EuclideanDomainElement {
1488
struct __pyx_vtabstruct_4sage_9structure_7element_PrincipalIdealDomainElement __pyx_base;
1489
PyObject *(*_floordiv_)(struct __pyx_obj_4sage_9structure_7element_EuclideanDomainElement *, PyObject *, int __pyx_skip_dispatch);
1490
PyObject *(*_mod_)(struct __pyx_obj_4sage_9structure_7element_EuclideanDomainElement *, PyObject *, int __pyx_skip_dispatch);
1491
};
1492
static struct __pyx_vtabstruct_4sage_9structure_7element_EuclideanDomainElement *__pyx_vtabptr_4sage_9structure_7element_EuclideanDomainElement;
1493
1494
1495
/* "sage/structure/element.pxd":236
1496
* cpdef _mod_(self, right)
1497
*
1498
* cdef class FieldElement(CommutativeRingElement): # <<<<<<<<<<<<<<
1499
* cpdef _floordiv_(self, right)
1500
*
1501
*/
1502
1503
struct __pyx_vtabstruct_4sage_9structure_7element_FieldElement {
1504
struct __pyx_vtabstruct_4sage_9structure_7element_CommutativeRingElement __pyx_base;
1505
PyObject *(*_floordiv_)(struct __pyx_obj_4sage_9structure_7element_FieldElement *, PyObject *, int __pyx_skip_dispatch);
1506
};
1507
static struct __pyx_vtabstruct_4sage_9structure_7element_FieldElement *__pyx_vtabptr_4sage_9structure_7element_FieldElement;
1508
1509
1510
/* "sage/structure/element.pxd":239
1511
* cpdef _floordiv_(self, right)
1512
*
1513
* cdef class AlgebraElement(RingElement): # <<<<<<<<<<<<<<
1514
* pass
1515
*
1516
*/
1517
1518
struct __pyx_vtabstruct_4sage_9structure_7element_AlgebraElement {
1519
struct __pyx_vtabstruct_4sage_9structure_7element_RingElement __pyx_base;
1520
};
1521
static struct __pyx_vtabstruct_4sage_9structure_7element_AlgebraElement *__pyx_vtabptr_4sage_9structure_7element_AlgebraElement;
1522
1523
1524
/* "sage/structure/element.pxd":242
1525
* pass
1526
*
1527
* cdef class CommutativeAlgebraElement(CommutativeRingElement): # <<<<<<<<<<<<<<
1528
* pass
1529
*
1530
*/
1531
1532
struct __pyx_vtabstruct_4sage_9structure_7element_CommutativeAlgebraElement {
1533
struct __pyx_vtabstruct_4sage_9structure_7element_CommutativeRingElement __pyx_base;
1534
};
1535
static struct __pyx_vtabstruct_4sage_9structure_7element_CommutativeAlgebraElement *__pyx_vtabptr_4sage_9structure_7element_CommutativeAlgebraElement;
1536
1537
1538
/* "sage/structure/element.pxd":245
1539
* pass
1540
*
1541
* cdef class InfinityElement(RingElement): # <<<<<<<<<<<<<<
1542
* pass
1543
*
1544
*/
1545
1546
struct __pyx_vtabstruct_4sage_9structure_7element_InfinityElement {
1547
struct __pyx_vtabstruct_4sage_9structure_7element_RingElement __pyx_base;
1548
};
1549
static struct __pyx_vtabstruct_4sage_9structure_7element_InfinityElement *__pyx_vtabptr_4sage_9structure_7element_InfinityElement;
1550
1551
1552
/* "sage/structure/element.pxd":249
1553
*
1554
*
1555
* cdef class Vector(ModuleElement): # <<<<<<<<<<<<<<
1556
* cdef Py_ssize_t _degree
1557
*
1558
*/
1559
1560
struct __pyx_vtabstruct_4sage_9structure_7element_Vector {
1561
struct __pyx_vtabstruct_4sage_9structure_7element_ModuleElement __pyx_base;
1562
PyObject *(*_dot_product_)(struct __pyx_obj_4sage_9structure_7element_Vector *, struct __pyx_obj_4sage_9structure_7element_Vector *, int __pyx_skip_dispatch);
1563
PyObject *(*_dot_product_coerce_)(struct __pyx_obj_4sage_9structure_7element_Vector *, struct __pyx_obj_4sage_9structure_7element_Vector *, int __pyx_skip_dispatch);
1564
PyObject *(*_pairwise_product_)(struct __pyx_obj_4sage_9structure_7element_Vector *, struct __pyx_obj_4sage_9structure_7element_Vector *, int __pyx_skip_dispatch);
1565
int (*is_sparse_c)(struct __pyx_obj_4sage_9structure_7element_Vector *);
1566
int (*is_dense_c)(struct __pyx_obj_4sage_9structure_7element_Vector *);
1567
};
1568
static struct __pyx_vtabstruct_4sage_9structure_7element_Vector *__pyx_vtabptr_4sage_9structure_7element_Vector;
1569
1570
1571
/* "sage/structure/element.pxd":264
1572
*
1573
*
1574
* cdef class Matrix(ModuleElement): # <<<<<<<<<<<<<<
1575
* # All matrix classes must be written in Cython
1576
* cdef Py_ssize_t _nrows
1577
*/
1578
1579
struct __pyx_vtabstruct_4sage_9structure_7element_Matrix {
1580
struct __pyx_vtabstruct_4sage_9structure_7element_ModuleElement __pyx_base;
1581
PyObject *(*_vector_times_matrix_)(struct __pyx_obj_4sage_9structure_7element_Matrix *, struct __pyx_obj_4sage_9structure_7element_Vector *);
1582
PyObject *(*_matrix_times_vector_)(struct __pyx_obj_4sage_9structure_7element_Matrix *, struct __pyx_obj_4sage_9structure_7element_Vector *);
1583
PyObject *(*_matrix_times_matrix_)(struct __pyx_obj_4sage_9structure_7element_Matrix *, struct __pyx_obj_4sage_9structure_7element_Matrix *);
1584
int (*is_sparse_c)(struct __pyx_obj_4sage_9structure_7element_Matrix *);
1585
int (*is_dense_c)(struct __pyx_obj_4sage_9structure_7element_Matrix *);
1586
};
1587
static struct __pyx_vtabstruct_4sage_9structure_7element_Matrix *__pyx_vtabptr_4sage_9structure_7element_Matrix;
1588
1589
1590
/* "sage/structure/element.pxd":277
1591
*
1592
*
1593
* cdef class CoercionModel: # <<<<<<<<<<<<<<
1594
* cpdef canonical_coercion(self, x, y)
1595
* cpdef bin_op(self, x, y, op)
1596
*/
1597
1598
struct __pyx_vtabstruct_4sage_9structure_7element_CoercionModel {
1599
PyObject *(*canonical_coercion)(struct __pyx_obj_4sage_9structure_7element_CoercionModel *, PyObject *, PyObject *, int __pyx_skip_dispatch);
1600
PyObject *(*bin_op)(struct __pyx_obj_4sage_9structure_7element_CoercionModel *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
1601
PyObject *(*richcmp)(struct __pyx_obj_4sage_9structure_7element_CoercionModel *, PyObject *, PyObject *, int, int __pyx_skip_dispatch);
1602
};
1603
static struct __pyx_vtabstruct_4sage_9structure_7element_CoercionModel *__pyx_vtabptr_4sage_9structure_7element_CoercionModel;
1604
1605
1606
/* "map.pxd":4
1607
* from sage.structure.element cimport Element
1608
*
1609
* cdef class Map(Element): # <<<<<<<<<<<<<<
1610
* cdef object __weakref__
1611
*
1612
*/
1613
1614
struct __pyx_vtabstruct_4sage_10categories_3map_Map {
1615
struct __pyx_vtabstruct_4sage_9structure_7element_Element __pyx_base;
1616
PyObject *(*_update_slots)(struct __pyx_obj_4sage_10categories_3map_Map *, PyObject *);
1617
PyObject *(*_extra_slots)(struct __pyx_obj_4sage_10categories_3map_Map *, PyObject *);
1618
struct __pyx_obj_4sage_9structure_7element_Element *(*_call_)(struct __pyx_obj_4sage_10categories_3map_Map *, PyObject *, int __pyx_skip_dispatch);
1619
struct __pyx_obj_4sage_9structure_7element_Element *(*_call_with_args)(struct __pyx_obj_4sage_10categories_3map_Map *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4sage_10categories_3map_3Map__call_with_args *__pyx_optional_args);
1620
};
1621
static struct __pyx_vtabstruct_4sage_10categories_3map_Map *__pyx_vtabptr_4sage_10categories_3map_Map;
1622
1623
1624
/* "map.pxd":25
1625
*
1626
*
1627
* cdef class Section(Map): # <<<<<<<<<<<<<<
1628
* cdef Map _inverse
1629
*
1630
*/
1631
1632
struct __pyx_vtabstruct_4sage_10categories_3map_Section {
1633
struct __pyx_vtabstruct_4sage_10categories_3map_Map __pyx_base;
1634
};
1635
static struct __pyx_vtabstruct_4sage_10categories_3map_Section *__pyx_vtabptr_4sage_10categories_3map_Section;
1636
1637
1638
/* "map.pxd":28
1639
* cdef Map _inverse
1640
*
1641
* cdef class FormalCompositeMap(Map): # <<<<<<<<<<<<<<
1642
* cdef __list
1643
*/
1644
1645
struct __pyx_vtabstruct_4sage_10categories_3map_FormalCompositeMap {
1646
struct __pyx_vtabstruct_4sage_10categories_3map_Map __pyx_base;
1647
};
1648
static struct __pyx_vtabstruct_4sage_10categories_3map_FormalCompositeMap *__pyx_vtabptr_4sage_10categories_3map_FormalCompositeMap;
1649
1650
1651
/* "sage/categories/morphism.pxd":5
1652
* from .map cimport Map
1653
*
1654
* cdef class Morphism(Map): # <<<<<<<<<<<<<<
1655
* pass
1656
*
1657
*/
1658
1659
struct __pyx_vtabstruct_4sage_10categories_8morphism_Morphism {
1660
struct __pyx_vtabstruct_4sage_10categories_3map_Map __pyx_base;
1661
};
1662
static struct __pyx_vtabstruct_4sage_10categories_8morphism_Morphism *__pyx_vtabptr_4sage_10categories_8morphism_Morphism;
1663
1664
1665
/* "sage/categories/morphism.pxd":8
1666
* pass
1667
*
1668
* cdef class SetMorphism(Morphism): # <<<<<<<<<<<<<<
1669
* cdef object _function
1670
* cpdef bint _eq_c_impl(left, Element right)
1671
*/
1672
1673
struct __pyx_vtabstruct_4sage_10categories_8morphism_SetMorphism {
1674
struct __pyx_vtabstruct_4sage_10categories_8morphism_Morphism __pyx_base;
1675
int (*_eq_c_impl)(struct __pyx_obj_4sage_10categories_8morphism_SetMorphism *, struct __pyx_obj_4sage_9structure_7element_Element *, int __pyx_skip_dispatch);
1676
};
1677
static struct __pyx_vtabstruct_4sage_10categories_8morphism_SetMorphism *__pyx_vtabptr_4sage_10categories_8morphism_SetMorphism;
1678
1679
1680
/* "sage/rings/integer.pxd":7
1681
* from sage.categories.morphism cimport Morphism
1682
*
1683
* cdef class Integer(EuclideanDomainElement): # <<<<<<<<<<<<<<
1684
* cdef mpz_t value
1685
*
1686
*/
1687
1688
struct __pyx_vtabstruct_4sage_5rings_7integer_Integer {
1689
struct __pyx_vtabstruct_4sage_9structure_7element_EuclideanDomainElement __pyx_base;
1690
int (*_to_ZZ)(struct __pyx_obj_4sage_5rings_7integer_Integer *, ZZ *);
1691
void (*set_from_mpz)(struct __pyx_obj_4sage_5rings_7integer_Integer *, __mpz_struct *);
1692
PyObject *(*hash_c)(struct __pyx_obj_4sage_5rings_7integer_Integer *);
1693
PyObject *(*_pari_)(struct __pyx_obj_4sage_5rings_7integer_Integer *, int __pyx_skip_dispatch);
1694
PyObject *(*_shift_helper)(struct __pyx_obj_4sage_5rings_7integer_Integer *, PyObject *, int, int __pyx_skip_dispatch);
1695
PyObject *(*_and)(struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *);
1696
PyObject *(*_or)(struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *);
1697
PyObject *(*_xor)(struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *);
1698
size_t (*_exact_log_log2_iter)(struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *, int __pyx_skip_dispatch);
1699
size_t (*_exact_log_mpfi_log)(struct __pyx_obj_4sage_5rings_7integer_Integer *, PyObject *, int __pyx_skip_dispatch);
1700
struct __pyx_obj_4sage_9structure_7element_RingElement *(*_valuation)(struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *, int __pyx_skip_dispatch);
1701
PyObject *(*_val_unit)(struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *);
1702
struct __pyx_obj_4sage_5rings_7integer_Integer *(*_divide_knowing_divisible_by)(struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *);
1703
int (*_is_power_of)(struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *);
1704
int (*_pseudoprime_is_prime)(struct __pyx_obj_4sage_5rings_7integer_Integer *, PyObject *);
1705
PyObject *(*_pari_divisors_small)(struct __pyx_obj_4sage_5rings_7integer_Integer *, int __pyx_skip_dispatch);
1706
PyObject *(*_reduce_set)(struct __pyx_obj_4sage_5rings_7integer_Integer *, PyObject *);
1707
};
1708
static struct __pyx_vtabstruct_4sage_5rings_7integer_Integer *__pyx_vtabptr_4sage_5rings_7integer_Integer;
1709
1710
1711
/* "sage/rings/integer.pxd":37
1712
* cdef Integer smallInteger(long value)
1713
*
1714
* cdef class int_to_Z(Morphism): # <<<<<<<<<<<<<<
1715
* pass
1716
*/
1717
1718
struct __pyx_vtabstruct_4sage_5rings_7integer_int_to_Z {
1719
struct __pyx_vtabstruct_4sage_10categories_8morphism_Morphism __pyx_base;
1720
};
1721
static struct __pyx_vtabstruct_4sage_5rings_7integer_int_to_Z *__pyx_vtabptr_4sage_5rings_7integer_int_to_Z;
1722
1723
/* --- Runtime support code (head) --- */
1724
/* Refnanny.proto */
1725
#ifndef CYTHON_REFNANNY
1726
#define CYTHON_REFNANNY 0
1727
#endif
1728
#if CYTHON_REFNANNY
1729
typedef struct {
1730
void (*INCREF)(void*, PyObject*, int);
1731
void (*DECREF)(void*, PyObject*, int);
1732
void (*GOTREF)(void*, PyObject*, int);
1733
void (*GIVEREF)(void*, PyObject*, int);
1734
void* (*SetupContext)(const char*, int, const char*);
1735
void (*FinishContext)(void**);
1736
} __Pyx_RefNannyAPIStruct;
1737
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1738
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1739
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1740
#ifdef WITH_THREAD
1741
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
1742
if (acquire_gil) {\
1743
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1744
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1745
PyGILState_Release(__pyx_gilstate_save);\
1746
} else {\
1747
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1748
}
1749
#else
1750
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
1751
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1752
#endif
1753
#define __Pyx_RefNannyFinishContext()\
1754
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1755
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1756
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1757
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1758
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1759
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1760
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1761
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1762
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1763
#else
1764
#define __Pyx_RefNannyDeclarations
1765
#define __Pyx_RefNannySetupContext(name, acquire_gil)
1766
#define __Pyx_RefNannyFinishContext()
1767
#define __Pyx_INCREF(r) Py_INCREF(r)
1768
#define __Pyx_DECREF(r) Py_DECREF(r)
1769
#define __Pyx_GOTREF(r)
1770
#define __Pyx_GIVEREF(r)
1771
#define __Pyx_XINCREF(r) Py_XINCREF(r)
1772
#define __Pyx_XDECREF(r) Py_XDECREF(r)
1773
#define __Pyx_XGOTREF(r)
1774
#define __Pyx_XGIVEREF(r)
1775
#endif
1776
#define __Pyx_XDECREF_SET(r, v) do {\
1777
PyObject *tmp = (PyObject *) r;\
1778
r = v; __Pyx_XDECREF(tmp);\
1779
} while (0)
1780
#define __Pyx_DECREF_SET(r, v) do {\
1781
PyObject *tmp = (PyObject *) r;\
1782
r = v; __Pyx_DECREF(tmp);\
1783
} while (0)
1784
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1785
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1786
1787
/* PyObjectGetAttrStr.proto */
1788
#if CYTHON_USE_TYPE_SLOTS
1789
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
1790
PyTypeObject* tp = Py_TYPE(obj);
1791
if (likely(tp->tp_getattro))
1792
return tp->tp_getattro(obj, attr_name);
1793
#if PY_MAJOR_VERSION < 3
1794
if (likely(tp->tp_getattr))
1795
return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
1796
#endif
1797
return PyObject_GetAttr(obj, attr_name);
1798
}
1799
#else
1800
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1801
#endif
1802
1803
/* GetBuiltinName.proto */
1804
static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1805
1806
/* None.proto */
1807
static CYTHON_INLINE int64_t __Pyx_mod_int64_t(int64_t, int64_t);
1808
1809
/* None.proto */
1810
static CYTHON_INLINE int64_t __Pyx_div_int64_t(int64_t, int64_t);
1811
1812
/* PyThreadStateGet.proto */
1813
#if CYTHON_FAST_THREAD_STATE
1814
#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1815
#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET();
1816
#else
1817
#define __Pyx_PyThreadState_declare
1818
#define __Pyx_PyThreadState_assign
1819
#endif
1820
1821
/* PyErrFetchRestore.proto */
1822
#if CYTHON_FAST_THREAD_STATE
1823
#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1824
#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1825
#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1826
#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1827
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1828
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1829
#else
1830
#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1831
#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1832
#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1833
#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1834
#endif
1835
1836
/* WriteUnraisableException.proto */
1837
static void __Pyx_WriteUnraisable(const char *name, int clineno,
1838
int lineno, const char *filename,
1839
int full_traceback, int nogil);
1840
1841
/* RaiseArgTupleInvalid.proto */
1842
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1843
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1844
1845
/* RaiseDoubleKeywords.proto */
1846
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1847
1848
/* ParseKeywords.proto */
1849
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1850
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1851
const char* function_name);
1852
1853
/* ArgTypeTest.proto */
1854
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
1855
const char *name, int exact);
1856
1857
/* PyCFunctionFastCall.proto */
1858
#if CYTHON_FAST_PYCCALL
1859
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1860
#else
1861
#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
1862
#endif
1863
1864
/* PyFunctionFastCall.proto */
1865
#if CYTHON_FAST_PYCALL
1866
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
1867
__Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1868
#if 1 || PY_VERSION_HEX < 0x030600B1
1869
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
1870
#else
1871
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1872
#endif
1873
#endif
1874
1875
/* PyObjectCall.proto */
1876
#if CYTHON_COMPILING_IN_CPYTHON
1877
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1878
#else
1879
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1880
#endif
1881
1882
/* PyObjectCallMethO.proto */
1883
#if CYTHON_COMPILING_IN_CPYTHON
1884
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1885
#endif
1886
1887
/* PyObjectCallOneArg.proto */
1888
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1889
1890
/* PyObjectCallNoArg.proto */
1891
#if CYTHON_COMPILING_IN_CPYTHON
1892
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1893
#else
1894
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1895
#endif
1896
1897
/* RaiseException.proto */
1898
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1899
1900
/* RaiseTooManyValuesToUnpack.proto */
1901
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1902
1903
/* RaiseNeedMoreValuesToUnpack.proto */
1904
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1905
1906
/* IterFinish.proto */
1907
static CYTHON_INLINE int __Pyx_IterFinish(void);
1908
1909
/* UnpackItemEndCheck.proto */
1910
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
1911
1912
/* SaveResetException.proto */
1913
#if CYTHON_FAST_THREAD_STATE
1914
#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1915
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1916
#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1917
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1918
#else
1919
#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
1920
#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
1921
#endif
1922
1923
/* PyErrExceptionMatches.proto */
1924
#if CYTHON_FAST_THREAD_STATE
1925
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1926
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1927
#else
1928
#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1929
#endif
1930
1931
/* GetException.proto */
1932
#if CYTHON_FAST_THREAD_STATE
1933
#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
1934
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1935
#else
1936
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1937
#endif
1938
1939
/* GetModuleGlobalName.proto */
1940
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
1941
1942
/* FetchCommonType.proto */
1943
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
1944
1945
/* CythonFunction.proto */
1946
#define __Pyx_CyFunction_USED 1
1947
#include <structmember.h>
1948
#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
1949
#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
1950
#define __Pyx_CYFUNCTION_CCLASS 0x04
1951
#define __Pyx_CyFunction_GetClosure(f)\
1952
(((__pyx_CyFunctionObject *) (f))->func_closure)
1953
#define __Pyx_CyFunction_GetClassObj(f)\
1954
(((__pyx_CyFunctionObject *) (f))->func_classobj)
1955
#define __Pyx_CyFunction_Defaults(type, f)\
1956
((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
1957
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
1958
((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
1959
typedef struct {
1960
PyCFunctionObject func;
1961
#if PY_VERSION_HEX < 0x030500A0
1962
PyObject *func_weakreflist;
1963
#endif
1964
PyObject *func_dict;
1965
PyObject *func_name;
1966
PyObject *func_qualname;
1967
PyObject *func_doc;
1968
PyObject *func_globals;
1969
PyObject *func_code;
1970
PyObject *func_closure;
1971
PyObject *func_classobj;
1972
void *defaults;
1973
int defaults_pyobjects;
1974
int flags;
1975
PyObject *defaults_tuple;
1976
PyObject *defaults_kwdict;
1977
PyObject *(*defaults_getter)(PyObject *);
1978
PyObject *func_annotations;
1979
} __pyx_CyFunctionObject;
1980
static PyTypeObject *__pyx_CyFunctionType = 0;
1981
#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
1982
__Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
1983
static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
1984
int flags, PyObject* qualname,
1985
PyObject *self,
1986
PyObject *module, PyObject *globals,
1987
PyObject* code);
1988
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
1989
size_t size,
1990
int pyobjects);
1991
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
1992
PyObject *tuple);
1993
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
1994
PyObject *dict);
1995
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
1996
PyObject *dict);
1997
static int __pyx_CyFunction_init(void);
1998
1999
/* IncludeStringH.proto */
2000
#include <string.h>
2001
2002
/* GetVTable.proto */
2003
static void* __Pyx_GetVtable(PyObject *dict);
2004
2005
/* Import.proto */
2006
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
2007
2008
/* ImportFrom.proto */
2009
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
2010
2011
/* CodeObjectCache.proto */
2012
typedef struct {
2013
PyCodeObject* code_object;
2014
int code_line;
2015
} __Pyx_CodeObjectCacheEntry;
2016
struct __Pyx_CodeObjectCache {
2017
int count;
2018
int max_count;
2019
__Pyx_CodeObjectCacheEntry* entries;
2020
};
2021
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
2022
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
2023
static PyCodeObject *__pyx_find_code_object(int code_line);
2024
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
2025
2026
/* AddTraceback.proto */
2027
static void __Pyx_AddTraceback(const char *funcname, int c_line,
2028
int py_line, const char *filename);
2029
2030
/* CIntToPy.proto */
2031
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value);
2032
2033
/* CIntToPy.proto */
2034
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value);
2035
2036
/* CIntFromPy.proto */
2037
static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *);
2038
2039
/* CIntFromPy.proto */
2040
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
2041
2042
/* CIntToPy.proto */
2043
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
2044
2045
/* CIntFromPy.proto */
2046
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
2047
2048
/* CheckBinaryVersion.proto */
2049
static int __Pyx_check_binary_version(void);
2050
2051
/* PyIdentifierFromString.proto */
2052
#if !defined(__Pyx_PyIdentifier_FromString)
2053
#if PY_MAJOR_VERSION < 3
2054
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
2055
#else
2056
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
2057
#endif
2058
#endif
2059
2060
/* ModuleImport.proto */
2061
static PyObject *__Pyx_ImportModule(const char *name);
2062
2063
/* TypeImport.proto */
2064
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
2065
2066
/* VoidPtrImport.proto */
2067
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
2068
2069
/* InitStrings.proto */
2070
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
2071
2072
static CYTHON_INLINE int __pyx_f_4sage_9structure_6parent_6Parent_get_flag(struct __pyx_obj_4sage_9structure_6parent_Parent *__pyx_v_self, int __pyx_v_flag); /* proto*/
2073
2074
/* Module declarations from 'cysignals.__init__' */
2075
2076
/* Module declarations from 'cysignals' */
2077
2078
/* Module declarations from 'cysignals.signals' */
2079
static cysigs_t *__pyx_vp_9cysignals_7signals_cysigs = 0;
2080
#define cysigs (*__pyx_vp_9cysignals_7signals_cysigs)
2081
static void (*__pyx_f_9cysignals_7signals_print_backtrace)(void); /*proto*/
2082
static void (*__pyx_f_9cysignals_7signals__sig_on_interrupt_received)(void); /*proto*/
2083
static void (*__pyx_f_9cysignals_7signals__sig_on_recover)(void); /*proto*/
2084
static void (*__pyx_f_9cysignals_7signals__sig_off_warning)(char const *, int); /*proto*/
2085
2086
/* Module declarations from 'cython' */
2087
2088
/* Module declarations from 'libc.string' */
2089
2090
/* Module declarations from 'libc.stdlib' */
2091
2092
/* Module declarations from 'cysignals.memory' */
2093
static CYTHON_INLINE void *sig_malloc(size_t); /*proto*/
2094
static CYTHON_INLINE void *sig_realloc(void *, size_t); /*proto*/
2095
static CYTHON_INLINE void *sig_calloc(size_t, size_t); /*proto*/
2096
static CYTHON_INLINE void sig_free(void *); /*proto*/
2097
static CYTHON_INLINE size_t __pyx_f_9cysignals_6memory_mul_overflowcheck(size_t, size_t); /*proto*/
2098
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_allocarray(size_t, size_t); /*proto*/
2099
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_reallocarray(void *, size_t, size_t); /*proto*/
2100
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_malloc(size_t); /*proto*/
2101
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_realloc(void *, size_t); /*proto*/
2102
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_calloc(size_t, size_t); /*proto*/
2103
2104
/* Module declarations from 'libc.stdio' */
2105
2106
/* Module declarations from '__builtin__' */
2107
2108
/* Module declarations from 'cpython.type' */
2109
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
2110
2111
/* Module declarations from 'cpython.version' */
2112
2113
/* Module declarations from 'cpython.ref' */
2114
2115
/* Module declarations from 'cpython.exc' */
2116
2117
/* Module declarations from 'cpython.module' */
2118
2119
/* Module declarations from 'cpython.mem' */
2120
2121
/* Module declarations from 'cpython.tuple' */
2122
2123
/* Module declarations from 'cpython.list' */
2124
2125
/* Module declarations from 'cpython.sequence' */
2126
2127
/* Module declarations from 'cpython.mapping' */
2128
2129
/* Module declarations from 'cpython.iterator' */
2130
2131
/* Module declarations from 'cpython.number' */
2132
2133
/* Module declarations from 'cpython.int' */
2134
2135
/* Module declarations from '__builtin__' */
2136
2137
/* Module declarations from 'cpython.bool' */
2138
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
2139
2140
/* Module declarations from 'cpython.long' */
2141
2142
/* Module declarations from 'cpython.float' */
2143
2144
/* Module declarations from '__builtin__' */
2145
2146
/* Module declarations from 'cpython.complex' */
2147
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
2148
2149
/* Module declarations from 'cpython.string' */
2150
2151
/* Module declarations from 'cpython.unicode' */
2152
2153
/* Module declarations from 'cpython.dict' */
2154
2155
/* Module declarations from 'cpython.instance' */
2156
2157
/* Module declarations from 'cpython.function' */
2158
2159
/* Module declarations from 'cpython.method' */
2160
2161
/* Module declarations from 'cpython.weakref' */
2162
2163
/* Module declarations from 'cpython.getargs' */
2164
2165
/* Module declarations from 'cpython.pythread' */
2166
2167
/* Module declarations from 'cpython.pystate' */
2168
2169
/* Module declarations from 'cpython.cobject' */
2170
2171
/* Module declarations from 'cpython.oldbuffer' */
2172
2173
/* Module declarations from 'cpython.set' */
2174
2175
/* Module declarations from 'cpython.buffer' */
2176
2177
/* Module declarations from 'cpython.bytes' */
2178
2179
/* Module declarations from 'cpython.pycapsule' */
2180
2181
/* Module declarations from 'cpython' */
2182
2183
/* Module declarations from 'cpython.object' */
2184
2185
/* Module declarations from 'sage.ext.stdsage' */
2186
static CYTHON_INLINE PyObject *__pyx_f_4sage_3ext_7stdsage_PY_NEW(PyTypeObject *); /*proto*/
2187
static CYTHON_INLINE int __pyx_f_4sage_3ext_7stdsage_HAS_DICTIONARY(PyObject *); /*proto*/
2188
2189
/* Module declarations from 'libc.math' */
2190
2191
/* Module declarations from 'sage.libs.gmp.types' */
2192
2193
/* Module declarations from 'sage.libs.gmp.random' */
2194
2195
/* Module declarations from 'libc.stdint' */
2196
2197
/* Module declarations from 'sage.libs.gmp.mpz' */
2198
2199
/* Module declarations from 'sage.libs.gmp.mpq' */
2200
2201
/* Module declarations from 'sage.libs.gmp.pylong' */
2202
2203
/* Module declarations from 'sage.libs.gmp.all' */
2204
2205
/* Module declarations from 'sage.libs.ntl.types' */
2206
2207
/* Module declarations from 'sage.structure.sage_object' */
2208
static PyTypeObject *__pyx_ptype_4sage_9structure_11sage_object_SageObject = 0;
2209
static CYTHON_INLINE PyObject *__pyx_f_4sage_9structure_11sage_object_richcmp_not_equal(PyObject *, PyObject *, int, int __pyx_skip_dispatch); /*proto*/
2210
static CYTHON_INLINE int __pyx_f_4sage_9structure_11sage_object_rich_to_bool(int, int, int __pyx_skip_dispatch); /*proto*/
2211
static CYTHON_INLINE int __pyx_f_4sage_9structure_11sage_object_rich_to_bool_sgn(int, int, int __pyx_skip_dispatch); /*proto*/
2212
2213
/* Module declarations from 'sage.structure.category_object' */
2214
static PyTypeObject *__pyx_ptype_4sage_9structure_15category_object_CategoryObject = 0;
2215
2216
/* Module declarations from 'sage.structure' */
2217
2218
/* Module declarations from 'sage.misc.cython_metaclass' */
2219
2220
/* Module declarations from 'sage.misc' */
2221
2222
/* Module declarations from 'sage' */
2223
2224
/* Module declarations from 'sage.structure.coerce_dict' */
2225
static PyTypeObject *__pyx_ptype_4sage_9structure_11coerce_dict_MonoDict = 0;
2226
static PyTypeObject *__pyx_ptype_4sage_9structure_11coerce_dict_TripleDict = 0;
2227
2228
/* Module declarations from 'sage.structure.parent' */
2229
static PyTypeObject *__pyx_ptype_4sage_9structure_6parent_Parent = 0;
2230
2231
/* Module declarations from 'sage.misc.inherit_comparison' */
2232
static PyTypeObject *__pyx_ptype_4sage_4misc_18inherit_comparison_InheritComparisonMetaclass = 0;
2233
2234
/* Module declarations from 'sage.structure.element' */
2235
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_Element = 0;
2236
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_ElementWithCachedMethod = 0;
2237
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_ModuleElement = 0;
2238
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_RingElement = 0;
2239
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_MonoidElement = 0;
2240
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_MultiplicativeGroupElement = 0;
2241
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_AdditiveGroupElement = 0;
2242
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_CommutativeRingElement = 0;
2243
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_IntegralDomainElement = 0;
2244
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_DedekindDomainElement = 0;
2245
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_PrincipalIdealDomainElement = 0;
2246
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_EuclideanDomainElement = 0;
2247
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_FieldElement = 0;
2248
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_AlgebraElement = 0;
2249
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_CommutativeAlgebraElement = 0;
2250
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_InfinityElement = 0;
2251
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_Vector = 0;
2252
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_Matrix = 0;
2253
static PyTypeObject *__pyx_ptype_4sage_9structure_7element_CoercionModel = 0;
2254
static struct __pyx_obj_4sage_9structure_7element_CoercionModel **__pyx_vp_4sage_9structure_7element_coercion_model = 0;
2255
#define __pyx_v_4sage_9structure_7element_coercion_model (*__pyx_vp_4sage_9structure_7element_coercion_model)
2256
static CYTHON_INLINE PyObject *__pyx_f_4sage_9structure_7element_parent(PyObject *, int __pyx_skip_dispatch); /*proto*/
2257
static CYTHON_INLINE int __pyx_f_4sage_9structure_7element_classify_elements(PyObject *, PyObject *); /*proto*/
2258
static CYTHON_INLINE int __pyx_f_4sage_9structure_7element_HAVE_SAME_PARENT(int); /*proto*/
2259
static CYTHON_INLINE int __pyx_f_4sage_9structure_7element_have_same_parent(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
2260
2261
/* Module declarations from 'sage.categories.map' */
2262
static PyTypeObject *__pyx_ptype_4sage_10categories_3map_Map = 0;
2263
static PyTypeObject *__pyx_ptype_4sage_10categories_3map_Section = 0;
2264
static PyTypeObject *__pyx_ptype_4sage_10categories_3map_FormalCompositeMap = 0;
2265
2266
/* Module declarations from 'sage.categories.morphism' */
2267
static PyTypeObject *__pyx_ptype_4sage_10categories_8morphism_Morphism = 0;
2268
static PyTypeObject *__pyx_ptype_4sage_10categories_8morphism_SetMorphism = 0;
2269
2270
/* Module declarations from 'sage.rings.integer' */
2271
static PyTypeObject *__pyx_ptype_4sage_5rings_7integer_Integer = 0;
2272
static PyTypeObject *__pyx_ptype_4sage_5rings_7integer_int_to_Z = 0;
2273
2274
/* Module declarations from 'code.alex.psage.psage.ellcurve.minmodel.sqrt5' */
2275
static PyTypeObject *__pyx_ptype___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py = 0;
2276
static void __pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_map64(int64_t *); /*proto*/
2277
static void __pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_mapC(__mpz_struct *, __mpz_struct *, __mpz_struct *, __mpz_struct *, __mpz_struct *, __mpz_struct *); /*proto*/
2278
static PyObject *__pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_map(struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *, int __pyx_skip_dispatch); /*proto*/
2279
static PyObject *__pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_canonical_model_c_invariants(struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *, struct __pyx_obj_4sage_5rings_7integer_Integer *, int __pyx_skip_dispatch); /*proto*/
2280
static PyObject *__Pyx_CFunc_object____object____object____int___to_py(PyObject *(*)(PyObject *, PyObject *, int)); /*proto*/
2281
#define __Pyx_MODULE_NAME "code.alex.psage.psage.ellcurve.minmodel.sqrt5"
2282
int __pyx_module_is_main_code__alex__psage__psage__ellcurve__minmodel__sqrt5 = 0;
2283
2284
/* Implementation of 'code.alex.psage.psage.ellcurve.minmodel.sqrt5' */
2285
static PyObject *__pyx_builtin_TypeError;
2286
static PyObject *__pyx_builtin_AttributeError;
2287
static PyObject *__pyx_builtin_MemoryError;
2288
static const char __pyx_k_E[] = "E";
2289
static const char __pyx_k_K[] = "K";
2290
static const char __pyx_k_a[] = "a";
2291
static const char __pyx_k_b[] = "b";
2292
static const char __pyx_k_c[] = "c";
2293
static const char __pyx_k_d[] = "d";
2294
static const char __pyx_k_r[] = "r";
2295
static const char __pyx_k_s[] = "s";
2296
static const char __pyx_k_t[] = "t";
2297
static const char __pyx_k_u[] = "u";
2298
static const char __pyx_k_x[] = "x";
2299
static const char __pyx_k_y[] = "y";
2300
static const char __pyx_k_D1[] = "D1";
2301
static const char __pyx_k_D2[] = "D2";
2302
static const char __pyx_k_P2[] = "P2";
2303
static const char __pyx_k_P3[] = "P3";
2304
static const char __pyx_k_a1[] = "a1";
2305
static const char __pyx_k_a2[] = "a2";
2306
static const char __pyx_k_a3[] = "a3";
2307
static const char __pyx_k_a4[] = "a4";
2308
static const char __pyx_k_a6[] = "a6";
2309
static const char __pyx_k_op[] = "op";
2310
static const char __pyx_k_t1[] = "t1";
2311
static const char __pyx_k_t2[] = "t2";
2312
static const char __pyx_k_u1[] = "u1";
2313
static const char __pyx_k_u2[] = "u2";
2314
static const char __pyx_k_a1p[] = "a1p";
2315
static const char __pyx_k_a2p[] = "a2p";
2316
static const char __pyx_k_a3p[] = "a3p";
2317
static const char __pyx_k_a4p[] = "a4p";
2318
static const char __pyx_k_a6p[] = "a6p";
2319
static const char __pyx_k_gen[] = "gen";
2320
static const char __pyx_k_mod[] = "mod";
2321
static const char __pyx_k_sa1[] = "sa1";
2322
static const char __pyx_k_arg0[] = "arg0";
2323
static const char __pyx_k_arg1[] = "arg1";
2324
static const char __pyx_k_arg2[] = "arg2";
2325
static const char __pyx_k_disc[] = "disc";
2326
static const char __pyx_k_left[] = "left";
2327
static const char __pyx_k_main[] = "__main__";
2328
static const char __pyx_k_ra1p[] = "ra1p";
2329
static const char __pyx_k_test[] = "__test__";
2330
static const char __pyx_k_wrap[] = "wrap";
2331
static const char __pyx_k_ideal[] = "ideal";
2332
static const char __pyx_k_right[] = "right";
2333
static const char __pyx_k_import[] = "__import__";
2334
static const char __pyx_k_parent[] = "parent";
2335
static const char __pyx_k_TypeError[] = "TypeError";
2336
static const char __pyx_k_base_field[] = "base_field";
2337
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
2338
static const char __pyx_k_MemoryError[] = "MemoryError";
2339
static const char __pyx_k_cfunc_to_py[] = "cfunc.to_py";
2340
static const char __pyx_k_a_invariants[] = "a_invariants";
2341
static const char __pyx_k_discriminant[] = "discriminant";
2342
static const char __pyx_k_stringsource[] = "stringsource";
2343
static const char __pyx_k_EllipticCurve[] = "EllipticCurve";
2344
static const char __pyx_k_AttributeError[] = "AttributeError";
2345
static const char __pyx_k_canonical_model[] = "canonical_model";
2346
static const char __pyx_k_sage_ext_memory[] = "sage.ext.memory";
2347
static const char __pyx_k_init_memory_functions[] = "init_memory_functions";
2348
static const char __pyx_k_E_must_be_over_Q_sqrt_5[] = "E must be over Q(sqrt(5))";
2349
static const char __pyx_k_Pyx_CFunc_object____object[] = "__Pyx_CFunc_object____object____object____int___to_py.<locals>.wrap";
2350
static const char __pyx_k_failed_to_allocate_s_bytes[] = "failed to allocate %s bytes";
2351
static const char __pyx_k_E_must_be_an_elliptic_curve[] = "E must be an elliptic curve";
2352
static const char __pyx_k_failed_to_allocate_s_s_bytes[] = "failed to allocate %s * %s bytes";
2353
static const char __pyx_k_File_sqrt5_pyx_starting_at_line[] = "File: sqrt5.pyx (starting at line 1)\n\nFast Cython code to choose a canonical minimal model.\n";
2354
static const char __pyx_k_projects_68c8b2b8_03ba_44d4_a0d[] = "/projects/68c8b2b8-03ba-44d4-a0d1-5d771c8cb465/code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx";
2355
static const char __pyx_k_code_alex_psage_psage_ellcurve_m[] = "code.alex.psage.psage.ellcurve.minmodel.sqrt5";
2356
static const char __pyx_k_sage_schemes_elliptic_curves_con[] = "sage.schemes.elliptic_curves.constructor";
2357
static PyObject *__pyx_n_s_AttributeError;
2358
static PyObject *__pyx_n_s_D1;
2359
static PyObject *__pyx_n_s_D2;
2360
static PyObject *__pyx_n_s_E;
2361
static PyObject *__pyx_kp_s_E_must_be_an_elliptic_curve;
2362
static PyObject *__pyx_kp_s_E_must_be_over_Q_sqrt_5;
2363
static PyObject *__pyx_n_s_EllipticCurve;
2364
static PyObject *__pyx_n_s_K;
2365
static PyObject *__pyx_n_s_MemoryError;
2366
static PyObject *__pyx_n_s_P2;
2367
static PyObject *__pyx_n_s_P3;
2368
static PyObject *__pyx_n_s_Pyx_CFunc_object____object;
2369
static PyObject *__pyx_n_s_TypeError;
2370
static PyObject *__pyx_n_s_a;
2371
static PyObject *__pyx_n_s_a1;
2372
static PyObject *__pyx_n_s_a1p;
2373
static PyObject *__pyx_n_s_a2;
2374
static PyObject *__pyx_n_s_a2p;
2375
static PyObject *__pyx_n_s_a3;
2376
static PyObject *__pyx_n_s_a3p;
2377
static PyObject *__pyx_n_s_a4;
2378
static PyObject *__pyx_n_s_a4p;
2379
static PyObject *__pyx_n_s_a6;
2380
static PyObject *__pyx_n_s_a6p;
2381
static PyObject *__pyx_n_s_a_invariants;
2382
static PyObject *__pyx_n_s_arg0;
2383
static PyObject *__pyx_n_s_arg1;
2384
static PyObject *__pyx_n_s_arg2;
2385
static PyObject *__pyx_n_s_b;
2386
static PyObject *__pyx_n_s_base_field;
2387
static PyObject *__pyx_n_s_c;
2388
static PyObject *__pyx_n_s_canonical_model;
2389
static PyObject *__pyx_n_s_cfunc_to_py;
2390
static PyObject *__pyx_n_s_code_alex_psage_psage_ellcurve_m;
2391
static PyObject *__pyx_n_s_d;
2392
static PyObject *__pyx_n_s_disc;
2393
static PyObject *__pyx_n_s_discriminant;
2394
static PyObject *__pyx_kp_s_failed_to_allocate_s_bytes;
2395
static PyObject *__pyx_kp_s_failed_to_allocate_s_s_bytes;
2396
static PyObject *__pyx_n_s_gen;
2397
static PyObject *__pyx_n_s_ideal;
2398
static PyObject *__pyx_n_s_import;
2399
static PyObject *__pyx_n_s_init_memory_functions;
2400
static PyObject *__pyx_n_s_left;
2401
static PyObject *__pyx_n_s_main;
2402
static PyObject *__pyx_n_s_mod;
2403
static PyObject *__pyx_n_s_op;
2404
static PyObject *__pyx_n_s_parent;
2405
static PyObject *__pyx_kp_s_projects_68c8b2b8_03ba_44d4_a0d;
2406
static PyObject *__pyx_n_s_pyx_vtable;
2407
static PyObject *__pyx_n_s_r;
2408
static PyObject *__pyx_n_s_ra1p;
2409
static PyObject *__pyx_n_s_right;
2410
static PyObject *__pyx_n_s_s;
2411
static PyObject *__pyx_n_s_sa1;
2412
static PyObject *__pyx_n_s_sage_ext_memory;
2413
static PyObject *__pyx_n_s_sage_schemes_elliptic_curves_con;
2414
static PyObject *__pyx_kp_s_stringsource;
2415
static PyObject *__pyx_n_s_t;
2416
static PyObject *__pyx_n_s_t1;
2417
static PyObject *__pyx_n_s_t2;
2418
static PyObject *__pyx_n_s_test;
2419
static PyObject *__pyx_n_s_u;
2420
static PyObject *__pyx_n_s_u1;
2421
static PyObject *__pyx_n_s_u2;
2422
static PyObject *__pyx_n_s_wrap;
2423
static PyObject *__pyx_n_s_x;
2424
static PyObject *__pyx_n_s_y;
2425
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_map(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_a, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_b); /* proto */
2426
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_2canonical_model(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_E); /* proto */
2427
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_4canonical_model_c_invariants(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_a, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_b, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_c, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_d); /* proto */
2428
static PyObject *__pyx_pf_4sage_9structure_7element_parent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x); /* proto */
2429
static PyObject *__pyx_pf_4sage_9structure_7element_2have_same_parent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_left, PyObject *__pyx_v_right); /* proto */
2430
static PyObject *__pyx_pf_4sage_9structure_11sage_object_richcmp_not_equal(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op); /* proto */
2431
static PyObject *__pyx_pf_4sage_9structure_11sage_object_2rich_to_bool(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_op, int __pyx_v_c); /* proto */
2432
static PyObject *__pyx_pf_4sage_9structure_11sage_object_4rich_to_bool_sgn(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_op, int __pyx_v_c); /* proto */
2433
static PyObject *__pyx_pf_11cfunc_dot_to_py_53__Pyx_CFunc_object____object____object____int___to_py_wrap(PyObject *__pyx_self, PyObject *__pyx_v_arg0, PyObject *__pyx_v_arg1, int __pyx_v_arg2); /* proto */
2434
static PyObject *__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2435
static PyObject *__pyx_int_0;
2436
static PyObject *__pyx_int_2;
2437
static PyObject *__pyx_int_3;
2438
static PyObject *__pyx_int_4;
2439
static PyObject *__pyx_int_5;
2440
static PyObject *__pyx_int_6;
2441
static PyObject *__pyx_int_4294967295;
2442
static PyObject *__pyx_int_9223372036854775808L;
2443
static PyObject *__pyx_tuple_;
2444
static PyObject *__pyx_tuple__2;
2445
static PyObject *__pyx_tuple__3;
2446
static PyObject *__pyx_tuple__4;
2447
static PyObject *__pyx_tuple__5;
2448
static PyObject *__pyx_tuple__6;
2449
static PyObject *__pyx_tuple__7;
2450
static PyObject *__pyx_tuple__9;
2451
static PyObject *__pyx_codeobj__8;
2452
static PyObject *__pyx_codeobj__10;
2453
2454
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":33
2455
* from libc.stdint cimport int64_t, uint64_t
2456
*
2457
* cdef void f_map64(int64_t *o): # <<<<<<<<<<<<<<
2458
* cdef bint s
2459
* cdef uint64_t x[2],y[2],g[3],f[3],h[3],t
2460
*/
2461
2462
static void __pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_map64(int64_t *__pyx_v_o) {
2463
int __pyx_v_s;
2464
uint64_t __pyx_v_x[2];
2465
uint64_t __pyx_v_y[2];
2466
uint64_t __pyx_v_g[3];
2467
uint64_t __pyx_v_f[3];
2468
uint64_t __pyx_v_h[3];
2469
uint64_t __pyx_v_t;
2470
__Pyx_RefNannyDeclarations
2471
long __pyx_t_1;
2472
PyObject *__pyx_t_2 = NULL;
2473
PyObject *__pyx_t_3 = NULL;
2474
uint64_t __pyx_t_4;
2475
PyObject *__pyx_t_5 = NULL;
2476
int __pyx_t_6;
2477
int __pyx_t_7;
2478
__Pyx_RefNannySetupContext("f_map64", 0);
2479
2480
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":36
2481
* cdef bint s
2482
* cdef uint64_t x[2],y[2],g[3],f[3],h[3],t
2483
* o[2] = 1 # <<<<<<<<<<<<<<
2484
* o[3] = 0
2485
* s = (o[0] < 0L)
2486
*/
2487
(__pyx_v_o[2]) = 1;
2488
2489
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":37
2490
* cdef uint64_t x[2],y[2],g[3],f[3],h[3],t
2491
* o[2] = 1
2492
* o[3] = 0 # <<<<<<<<<<<<<<
2493
* s = (o[0] < 0L)
2494
* # to simplify boolean checks
2495
*/
2496
(__pyx_v_o[3]) = 0;
2497
2498
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":38
2499
* o[2] = 1
2500
* o[3] = 0
2501
* s = (o[0] < 0L) # <<<<<<<<<<<<<<
2502
* # to simplify boolean checks
2503
* o[0] *= 1-2*s
2504
*/
2505
__pyx_v_s = ((__pyx_v_o[0]) < 0L);
2506
2507
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":40
2508
* s = (o[0] < 0L)
2509
* # to simplify boolean checks
2510
* o[0] *= 1-2*s # <<<<<<<<<<<<<<
2511
* o[1] *= 1-2*s
2512
* x[1] = o[0] >> 32
2513
*/
2514
__pyx_t_1 = 0;
2515
(__pyx_v_o[__pyx_t_1]) = ((__pyx_v_o[__pyx_t_1]) * (1 - (2 * __pyx_v_s)));
2516
2517
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":41
2518
* # to simplify boolean checks
2519
* o[0] *= 1-2*s
2520
* o[1] *= 1-2*s # <<<<<<<<<<<<<<
2521
* x[1] = o[0] >> 32
2522
* x[0] = o[0]&0xFFFFFFFF
2523
*/
2524
__pyx_t_1 = 1;
2525
(__pyx_v_o[__pyx_t_1]) = ((__pyx_v_o[__pyx_t_1]) * (1 - (2 * __pyx_v_s)));
2526
2527
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":42
2528
* o[0] *= 1-2*s
2529
* o[1] *= 1-2*s
2530
* x[1] = o[0] >> 32 # <<<<<<<<<<<<<<
2531
* x[0] = o[0]&0xFFFFFFFF
2532
* # to avoid multiplying by negative ints
2533
*/
2534
(__pyx_v_x[1]) = ((__pyx_v_o[0]) >> 32);
2535
2536
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":43
2537
* o[1] *= 1-2*s
2538
* x[1] = o[0] >> 32
2539
* x[0] = o[0]&0xFFFFFFFF # <<<<<<<<<<<<<<
2540
* # to avoid multiplying by negative ints
2541
* y[1] = (1-2*(o[1]<0L))*o[1] >> 32
2542
*/
2543
__pyx_t_2 = __Pyx_PyInt_From_int64_t((__pyx_v_o[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error)
2544
__Pyx_GOTREF(__pyx_t_2);
2545
__pyx_t_3 = PyNumber_And(__pyx_t_2, __pyx_int_4294967295); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
2546
__Pyx_GOTREF(__pyx_t_3);
2547
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2548
__pyx_t_4 = __Pyx_PyInt_As_uint64_t(__pyx_t_3); if (unlikely((__pyx_t_4 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L1_error)
2549
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2550
(__pyx_v_x[0]) = __pyx_t_4;
2551
2552
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":45
2553
* x[0] = o[0]&0xFFFFFFFF
2554
* # to avoid multiplying by negative ints
2555
* y[1] = (1-2*(o[1]<0L))*o[1] >> 32 # <<<<<<<<<<<<<<
2556
* y[0] = ((1-2*(o[1]<0L))*o[1])&0xFFFFFFFF
2557
* # f = o[0]*o[1]
2558
*/
2559
(__pyx_v_y[1]) = (((1 - (2 * ((__pyx_v_o[1]) < 0L))) * (__pyx_v_o[1])) >> 32);
2560
2561
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":46
2562
* # to avoid multiplying by negative ints
2563
* y[1] = (1-2*(o[1]<0L))*o[1] >> 32
2564
* y[0] = ((1-2*(o[1]<0L))*o[1])&0xFFFFFFFF # <<<<<<<<<<<<<<
2565
* # f = o[0]*o[1]
2566
* f[0] = x[0]*y[0]
2567
*/
2568
__pyx_t_3 = __Pyx_PyInt_From_int64_t(((1 - (2 * ((__pyx_v_o[1]) < 0L))) * (__pyx_v_o[1]))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error)
2569
__Pyx_GOTREF(__pyx_t_3);
2570
__pyx_t_2 = PyNumber_And(__pyx_t_3, __pyx_int_4294967295); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error)
2571
__Pyx_GOTREF(__pyx_t_2);
2572
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2573
__pyx_t_4 = __Pyx_PyInt_As_uint64_t(__pyx_t_2); if (unlikely((__pyx_t_4 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error)
2574
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2575
(__pyx_v_y[0]) = __pyx_t_4;
2576
2577
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":48
2578
* y[0] = ((1-2*(o[1]<0L))*o[1])&0xFFFFFFFF
2579
* # f = o[0]*o[1]
2580
* f[0] = x[0]*y[0] # <<<<<<<<<<<<<<
2581
* t = x[0]*y[1] + x[1]*y[0] + (f[0]>>32)
2582
* f[1] = x[1]*y[1] + (t>>32)
2583
*/
2584
(__pyx_v_f[0]) = ((__pyx_v_x[0]) * (__pyx_v_y[0]));
2585
2586
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":49
2587
* # f = o[0]*o[1]
2588
* f[0] = x[0]*y[0]
2589
* t = x[0]*y[1] + x[1]*y[0] + (f[0]>>32) # <<<<<<<<<<<<<<
2590
* f[1] = x[1]*y[1] + (t>>32)
2591
* f[0] = (f[0]&0xFFFFFFFF) + (t<<32)
2592
*/
2593
__pyx_v_t = ((((__pyx_v_x[0]) * (__pyx_v_y[1])) + ((__pyx_v_x[1]) * (__pyx_v_y[0]))) + ((__pyx_v_f[0]) >> 32));
2594
2595
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":50
2596
* f[0] = x[0]*y[0]
2597
* t = x[0]*y[1] + x[1]*y[0] + (f[0]>>32)
2598
* f[1] = x[1]*y[1] + (t>>32) # <<<<<<<<<<<<<<
2599
* f[0] = (f[0]&0xFFFFFFFF) + (t<<32)
2600
* # fix sign if needed
2601
*/
2602
(__pyx_v_f[1]) = (((__pyx_v_x[1]) * (__pyx_v_y[1])) + (__pyx_v_t >> 32));
2603
2604
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":51
2605
* t = x[0]*y[1] + x[1]*y[0] + (f[0]>>32)
2606
* f[1] = x[1]*y[1] + (t>>32)
2607
* f[0] = (f[0]&0xFFFFFFFF) + (t<<32) # <<<<<<<<<<<<<<
2608
* # fix sign if needed
2609
* if o[1] < 0L:
2610
*/
2611
__pyx_t_2 = __Pyx_PyInt_From_uint64_t((__pyx_v_f[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error)
2612
__Pyx_GOTREF(__pyx_t_2);
2613
__pyx_t_3 = PyNumber_And(__pyx_t_2, __pyx_int_4294967295); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error)
2614
__Pyx_GOTREF(__pyx_t_3);
2615
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2616
__pyx_t_2 = __Pyx_PyInt_From_uint64_t((__pyx_v_t << 32)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error)
2617
__Pyx_GOTREF(__pyx_t_2);
2618
__pyx_t_5 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error)
2619
__Pyx_GOTREF(__pyx_t_5);
2620
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2621
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2622
__pyx_t_4 = __Pyx_PyInt_As_uint64_t(__pyx_t_5); if (unlikely((__pyx_t_4 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 51, __pyx_L1_error)
2623
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2624
(__pyx_v_f[0]) = __pyx_t_4;
2625
2626
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":53
2627
* f[0] = (f[0]&0xFFFFFFFF) + (t<<32)
2628
* # fix sign if needed
2629
* if o[1] < 0L: # <<<<<<<<<<<<<<
2630
* f[0] = -f[0]
2631
* f[1] = -f[1]-(f[0]>0)
2632
*/
2633
__pyx_t_6 = (((__pyx_v_o[1]) < 0L) != 0);
2634
if (__pyx_t_6) {
2635
2636
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":54
2637
* # fix sign if needed
2638
* if o[1] < 0L:
2639
* f[0] = -f[0] # <<<<<<<<<<<<<<
2640
* f[1] = -f[1]-(f[0]>0)
2641
* f[2] = -1
2642
*/
2643
(__pyx_v_f[0]) = (-(__pyx_v_f[0]));
2644
2645
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":55
2646
* if o[1] < 0L:
2647
* f[0] = -f[0]
2648
* f[1] = -f[1]-(f[0]>0) # <<<<<<<<<<<<<<
2649
* f[2] = -1
2650
* else:
2651
*/
2652
(__pyx_v_f[1]) = ((-(__pyx_v_f[1])) - ((__pyx_v_f[0]) > 0));
2653
2654
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":56
2655
* f[0] = -f[0]
2656
* f[1] = -f[1]-(f[0]>0)
2657
* f[2] = -1 # <<<<<<<<<<<<<<
2658
* else:
2659
* f[2] = 0
2660
*/
2661
(__pyx_v_f[2]) = -1LL;
2662
2663
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":53
2664
* f[0] = (f[0]&0xFFFFFFFF) + (t<<32)
2665
* # fix sign if needed
2666
* if o[1] < 0L: # <<<<<<<<<<<<<<
2667
* f[0] = -f[0]
2668
* f[1] = -f[1]-(f[0]>0)
2669
*/
2670
goto __pyx_L3;
2671
}
2672
2673
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":58
2674
* f[2] = -1
2675
* else:
2676
* f[2] = 0 # <<<<<<<<<<<<<<
2677
* # g = o[0]*o[0]
2678
* g[0] = x[0]*x[0]
2679
*/
2680
/*else*/ {
2681
(__pyx_v_f[2]) = 0;
2682
}
2683
__pyx_L3:;
2684
2685
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":60
2686
* f[2] = 0
2687
* # g = o[0]*o[0]
2688
* g[0] = x[0]*x[0] # <<<<<<<<<<<<<<
2689
* t = ((x[0]*x[1])<<1)+(g[0]>>32)
2690
* g[1] = x[1]*x[1] + (t>>32)
2691
*/
2692
(__pyx_v_g[0]) = ((__pyx_v_x[0]) * (__pyx_v_x[0]));
2693
2694
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":61
2695
* # g = o[0]*o[0]
2696
* g[0] = x[0]*x[0]
2697
* t = ((x[0]*x[1])<<1)+(g[0]>>32) # <<<<<<<<<<<<<<
2698
* g[1] = x[1]*x[1] + (t>>32)
2699
* g[0] = (g[0]&0xFFFFFFFF) + (t<<32)
2700
*/
2701
__pyx_v_t = ((((__pyx_v_x[0]) * (__pyx_v_x[1])) << 1) + ((__pyx_v_g[0]) >> 32));
2702
2703
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":62
2704
* g[0] = x[0]*x[0]
2705
* t = ((x[0]*x[1])<<1)+(g[0]>>32)
2706
* g[1] = x[1]*x[1] + (t>>32) # <<<<<<<<<<<<<<
2707
* g[0] = (g[0]&0xFFFFFFFF) + (t<<32)
2708
* # g *= 36
2709
*/
2710
(__pyx_v_g[1]) = (((__pyx_v_x[1]) * (__pyx_v_x[1])) + (__pyx_v_t >> 32));
2711
2712
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":63
2713
* t = ((x[0]*x[1])<<1)+(g[0]>>32)
2714
* g[1] = x[1]*x[1] + (t>>32)
2715
* g[0] = (g[0]&0xFFFFFFFF) + (t<<32) # <<<<<<<<<<<<<<
2716
* # g *= 36
2717
* g[2] = 9*(g[1]>>4)>>58
2718
*/
2719
__pyx_t_5 = __Pyx_PyInt_From_uint64_t((__pyx_v_g[0])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 63, __pyx_L1_error)
2720
__Pyx_GOTREF(__pyx_t_5);
2721
__pyx_t_2 = PyNumber_And(__pyx_t_5, __pyx_int_4294967295); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
2722
__Pyx_GOTREF(__pyx_t_2);
2723
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2724
__pyx_t_5 = __Pyx_PyInt_From_uint64_t((__pyx_v_t << 32)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 63, __pyx_L1_error)
2725
__Pyx_GOTREF(__pyx_t_5);
2726
__pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 63, __pyx_L1_error)
2727
__Pyx_GOTREF(__pyx_t_3);
2728
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2729
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2730
__pyx_t_4 = __Pyx_PyInt_As_uint64_t(__pyx_t_3); if (unlikely((__pyx_t_4 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 63, __pyx_L1_error)
2731
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2732
(__pyx_v_g[0]) = __pyx_t_4;
2733
2734
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":65
2735
* g[0] = (g[0]&0xFFFFFFFF) + (t<<32)
2736
* # g *= 36
2737
* g[2] = 9*(g[1]>>4)>>58 # <<<<<<<<<<<<<<
2738
* g[1] = 36*g[1] + (9*(g[0]>>4)>>58)
2739
* g[0] *= 36
2740
*/
2741
(__pyx_v_g[2]) = ((9 * ((__pyx_v_g[1]) >> 4)) >> 58);
2742
2743
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":66
2744
* # g *= 36
2745
* g[2] = 9*(g[1]>>4)>>58
2746
* g[1] = 36*g[1] + (9*(g[0]>>4)>>58) # <<<<<<<<<<<<<<
2747
* g[0] *= 36
2748
* # h = o[1]*o[1]
2749
*/
2750
(__pyx_v_g[1]) = ((36 * (__pyx_v_g[1])) + ((9 * ((__pyx_v_g[0]) >> 4)) >> 58));
2751
2752
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":67
2753
* g[2] = 9*(g[1]>>4)>>58
2754
* g[1] = 36*g[1] + (9*(g[0]>>4)>>58)
2755
* g[0] *= 36 # <<<<<<<<<<<<<<
2756
* # h = o[1]*o[1]
2757
* h[0] = y[0]*y[0]
2758
*/
2759
__pyx_t_1 = 0;
2760
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) * 36);
2761
2762
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":69
2763
* g[0] *= 36
2764
* # h = o[1]*o[1]
2765
* h[0] = y[0]*y[0] # <<<<<<<<<<<<<<
2766
* t = ((y[0]*y[1])<<1)+(h[0]>>32)
2767
* h[1] = y[1]*y[1] + (t>>32)
2768
*/
2769
(__pyx_v_h[0]) = ((__pyx_v_y[0]) * (__pyx_v_y[0]));
2770
2771
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":70
2772
* # h = o[1]*o[1]
2773
* h[0] = y[0]*y[0]
2774
* t = ((y[0]*y[1])<<1)+(h[0]>>32) # <<<<<<<<<<<<<<
2775
* h[1] = y[1]*y[1] + (t>>32)
2776
* h[0] = (h[0]&0xFFFFFFFF) + (t<<32)
2777
*/
2778
__pyx_v_t = ((((__pyx_v_y[0]) * (__pyx_v_y[1])) << 1) + ((__pyx_v_h[0]) >> 32));
2779
2780
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":71
2781
* h[0] = y[0]*y[0]
2782
* t = ((y[0]*y[1])<<1)+(h[0]>>32)
2783
* h[1] = y[1]*y[1] + (t>>32) # <<<<<<<<<<<<<<
2784
* h[0] = (h[0]&0xFFFFFFFF) + (t<<32)
2785
* # h *= 180
2786
*/
2787
(__pyx_v_h[1]) = (((__pyx_v_y[1]) * (__pyx_v_y[1])) + (__pyx_v_t >> 32));
2788
2789
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":72
2790
* t = ((y[0]*y[1])<<1)+(h[0]>>32)
2791
* h[1] = y[1]*y[1] + (t>>32)
2792
* h[0] = (h[0]&0xFFFFFFFF) + (t<<32) # <<<<<<<<<<<<<<
2793
* # h *= 180
2794
* h[2] = 45*(h[1]>>6)>>56
2795
*/
2796
__pyx_t_3 = __Pyx_PyInt_From_uint64_t((__pyx_v_h[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
2797
__Pyx_GOTREF(__pyx_t_3);
2798
__pyx_t_5 = PyNumber_And(__pyx_t_3, __pyx_int_4294967295); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 72, __pyx_L1_error)
2799
__Pyx_GOTREF(__pyx_t_5);
2800
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2801
__pyx_t_3 = __Pyx_PyInt_From_uint64_t((__pyx_v_t << 32)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
2802
__Pyx_GOTREF(__pyx_t_3);
2803
__pyx_t_2 = PyNumber_Add(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
2804
__Pyx_GOTREF(__pyx_t_2);
2805
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2806
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2807
__pyx_t_4 = __Pyx_PyInt_As_uint64_t(__pyx_t_2); if (unlikely((__pyx_t_4 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 72, __pyx_L1_error)
2808
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2809
(__pyx_v_h[0]) = __pyx_t_4;
2810
2811
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":74
2812
* h[0] = (h[0]&0xFFFFFFFF) + (t<<32)
2813
* # h *= 180
2814
* h[2] = 45*(h[1]>>6)>>56 # <<<<<<<<<<<<<<
2815
* h[1] = 180*h[1] + (45*(h[0]>>6)>>56)
2816
* h[0] *= 180
2817
*/
2818
(__pyx_v_h[2]) = ((45 * ((__pyx_v_h[1]) >> 6)) >> 56);
2819
2820
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":75
2821
* # h *= 180
2822
* h[2] = 45*(h[1]>>6)>>56
2823
* h[1] = 180*h[1] + (45*(h[0]>>6)>>56) # <<<<<<<<<<<<<<
2824
* h[0] *= 180
2825
* # g += h
2826
*/
2827
(__pyx_v_h[1]) = ((0xB4 * (__pyx_v_h[1])) + ((45 * ((__pyx_v_h[0]) >> 6)) >> 56));
2828
2829
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":76
2830
* h[2] = 45*(h[1]>>6)>>56
2831
* h[1] = 180*h[1] + (45*(h[0]>>6)>>56)
2832
* h[0] *= 180 # <<<<<<<<<<<<<<
2833
* # g += h
2834
* g[2] += h[2]
2835
*/
2836
__pyx_t_1 = 0;
2837
(__pyx_v_h[__pyx_t_1]) = ((__pyx_v_h[__pyx_t_1]) * 0xB4);
2838
2839
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":78
2840
* h[0] *= 180
2841
* # g += h
2842
* g[2] += h[2] # <<<<<<<<<<<<<<
2843
* g[1] += h[1]
2844
* g[0] += h[0]
2845
*/
2846
__pyx_t_1 = 2;
2847
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + (__pyx_v_h[2]));
2848
2849
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":79
2850
* # g += h
2851
* g[2] += h[2]
2852
* g[1] += h[1] # <<<<<<<<<<<<<<
2853
* g[0] += h[0]
2854
* g[1] += g[0] < h[0]
2855
*/
2856
__pyx_t_1 = 1;
2857
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + (__pyx_v_h[1]));
2858
2859
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":80
2860
* g[2] += h[2]
2861
* g[1] += h[1]
2862
* g[0] += h[0] # <<<<<<<<<<<<<<
2863
* g[1] += g[0] < h[0]
2864
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0])
2865
*/
2866
__pyx_t_1 = 0;
2867
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + (__pyx_v_h[0]));
2868
2869
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":81
2870
* g[1] += h[1]
2871
* g[0] += h[0]
2872
* g[1] += g[0] < h[0] # <<<<<<<<<<<<<<
2873
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0])
2874
* # h = 161*f
2875
*/
2876
__pyx_t_1 = 1;
2877
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + ((__pyx_v_g[0]) < (__pyx_v_h[0])));
2878
2879
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":82
2880
* g[0] += h[0]
2881
* g[1] += g[0] < h[0]
2882
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0]) # <<<<<<<<<<<<<<
2883
* # h = 161*f
2884
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56)
2885
*/
2886
__pyx_t_1 = 2;
2887
__pyx_t_6 = ((__pyx_v_g[1]) < (__pyx_v_h[1]));
2888
if (!__pyx_t_6) {
2889
} else {
2890
__pyx_t_4 = __pyx_t_6;
2891
goto __pyx_L4_bool_binop_done;
2892
}
2893
__pyx_t_6 = ((__pyx_v_g[1]) == (__pyx_v_h[1]));
2894
if (__pyx_t_6) {
2895
} else {
2896
__pyx_t_4 = __pyx_t_6;
2897
goto __pyx_L4_bool_binop_done;
2898
}
2899
__pyx_t_6 = ((__pyx_v_g[0]) < (__pyx_v_h[0]));
2900
__pyx_t_4 = __pyx_t_6;
2901
__pyx_L4_bool_binop_done:;
2902
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + __pyx_t_4);
2903
2904
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":84
2905
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0])
2906
* # h = 161*f
2907
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56) # <<<<<<<<<<<<<<
2908
* h[1] = 161*f[1] + (161*(f[0]>>8)>>56)
2909
* h[0] = 161*f[0]
2910
*/
2911
(__pyx_v_h[2]) = ((0xA1 * (__pyx_v_f[2])) + ((0xA1 * ((__pyx_v_f[1]) >> 8)) >> 56));
2912
2913
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":85
2914
* # h = 161*f
2915
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56)
2916
* h[1] = 161*f[1] + (161*(f[0]>>8)>>56) # <<<<<<<<<<<<<<
2917
* h[0] = 161*f[0]
2918
* # f *= 2
2919
*/
2920
(__pyx_v_h[1]) = ((0xA1 * (__pyx_v_f[1])) + ((0xA1 * ((__pyx_v_f[0]) >> 8)) >> 56));
2921
2922
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":86
2923
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56)
2924
* h[1] = 161*f[1] + (161*(f[0]>>8)>>56)
2925
* h[0] = 161*f[0] # <<<<<<<<<<<<<<
2926
* # f *= 2
2927
* f[2] = (f[2]<<1) + (f[1]>>63)
2928
*/
2929
(__pyx_v_h[0]) = (0xA1 * (__pyx_v_f[0]));
2930
2931
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":88
2932
* h[0] = 161*f[0]
2933
* # f *= 2
2934
* f[2] = (f[2]<<1) + (f[1]>>63) # <<<<<<<<<<<<<<
2935
* f[1] = (f[1]<<1) + (f[0]>>63)
2936
* f[0] <<= 1
2937
*/
2938
(__pyx_v_f[2]) = (((__pyx_v_f[2]) << 1) + ((__pyx_v_f[1]) >> 63));
2939
2940
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":89
2941
* # f *= 2
2942
* f[2] = (f[2]<<1) + (f[1]>>63)
2943
* f[1] = (f[1]<<1) + (f[0]>>63) # <<<<<<<<<<<<<<
2944
* f[0] <<= 1
2945
* # f = 2*o[0]*o[1]
2946
*/
2947
(__pyx_v_f[1]) = (((__pyx_v_f[1]) << 1) + ((__pyx_v_f[0]) >> 63));
2948
2949
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":90
2950
* f[2] = (f[2]<<1) + (f[1]>>63)
2951
* f[1] = (f[1]<<1) + (f[0]>>63)
2952
* f[0] <<= 1 # <<<<<<<<<<<<<<
2953
* # f = 2*o[0]*o[1]
2954
* if o[1] > 0L:
2955
*/
2956
__pyx_t_1 = 0;
2957
(__pyx_v_f[__pyx_t_1]) = ((__pyx_v_f[__pyx_t_1]) << 1);
2958
2959
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":92
2960
* f[0] <<= 1
2961
* # f = 2*o[0]*o[1]
2962
* if o[1] > 0L: # <<<<<<<<<<<<<<
2963
* # g = -g
2964
* g[0] = -g[0]
2965
*/
2966
__pyx_t_6 = (((__pyx_v_o[1]) > 0L) != 0);
2967
if (__pyx_t_6) {
2968
2969
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":94
2970
* if o[1] > 0L:
2971
* # g = -g
2972
* g[0] = -g[0] # <<<<<<<<<<<<<<
2973
* g[1] = -g[1]-(g[0]>0)
2974
* g[2] = -g[2]-(g[1]>0 or g[0]>0)
2975
*/
2976
(__pyx_v_g[0]) = (-(__pyx_v_g[0]));
2977
2978
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":95
2979
* # g = -g
2980
* g[0] = -g[0]
2981
* g[1] = -g[1]-(g[0]>0) # <<<<<<<<<<<<<<
2982
* g[2] = -g[2]-(g[1]>0 or g[0]>0)
2983
* # g += h
2984
*/
2985
(__pyx_v_g[1]) = ((-(__pyx_v_g[1])) - ((__pyx_v_g[0]) > 0));
2986
2987
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":96
2988
* g[0] = -g[0]
2989
* g[1] = -g[1]-(g[0]>0)
2990
* g[2] = -g[2]-(g[1]>0 or g[0]>0) # <<<<<<<<<<<<<<
2991
* # g += h
2992
* g[2] += h[2]
2993
*/
2994
__pyx_t_6 = ((__pyx_v_g[1]) > 0);
2995
if (!__pyx_t_6) {
2996
} else {
2997
__pyx_t_4 = __pyx_t_6;
2998
goto __pyx_L8_bool_binop_done;
2999
}
3000
__pyx_t_6 = ((__pyx_v_g[0]) > 0);
3001
__pyx_t_4 = __pyx_t_6;
3002
__pyx_L8_bool_binop_done:;
3003
(__pyx_v_g[2]) = ((-(__pyx_v_g[2])) - __pyx_t_4);
3004
3005
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":98
3006
* g[2] = -g[2]-(g[1]>0 or g[0]>0)
3007
* # g += h
3008
* g[2] += h[2] # <<<<<<<<<<<<<<
3009
* g[1] += h[1]
3010
* g[0] += h[0]
3011
*/
3012
__pyx_t_1 = 2;
3013
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + (__pyx_v_h[2]));
3014
3015
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":99
3016
* # g += h
3017
* g[2] += h[2]
3018
* g[1] += h[1] # <<<<<<<<<<<<<<
3019
* g[0] += h[0]
3020
* g[1] += g[0] < h[0]
3021
*/
3022
__pyx_t_1 = 1;
3023
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + (__pyx_v_h[1]));
3024
3025
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":100
3026
* g[2] += h[2]
3027
* g[1] += h[1]
3028
* g[0] += h[0] # <<<<<<<<<<<<<<
3029
* g[1] += g[0] < h[0]
3030
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0])
3031
*/
3032
__pyx_t_1 = 0;
3033
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + (__pyx_v_h[0]));
3034
3035
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":101
3036
* g[1] += h[1]
3037
* g[0] += h[0]
3038
* g[1] += g[0] < h[0] # <<<<<<<<<<<<<<
3039
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0])
3040
* # g = 161*o[0]*o[1]-36*o[0]*o[0]-180*o[1]*o[1]
3041
*/
3042
__pyx_t_1 = 1;
3043
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + ((__pyx_v_g[0]) < (__pyx_v_h[0])));
3044
3045
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":102
3046
* g[0] += h[0]
3047
* g[1] += g[0] < h[0]
3048
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0]) # <<<<<<<<<<<<<<
3049
* # g = 161*o[0]*o[1]-36*o[0]*o[0]-180*o[1]*o[1]
3050
* while g[2] < 0x8000000000000000L:
3051
*/
3052
__pyx_t_1 = 2;
3053
__pyx_t_6 = ((__pyx_v_g[1]) < (__pyx_v_h[1]));
3054
if (!__pyx_t_6) {
3055
} else {
3056
__pyx_t_4 = __pyx_t_6;
3057
goto __pyx_L10_bool_binop_done;
3058
}
3059
__pyx_t_6 = ((__pyx_v_g[1]) == (__pyx_v_h[1]));
3060
if (__pyx_t_6) {
3061
} else {
3062
__pyx_t_4 = __pyx_t_6;
3063
goto __pyx_L10_bool_binop_done;
3064
}
3065
__pyx_t_6 = ((__pyx_v_g[0]) < (__pyx_v_h[0]));
3066
__pyx_t_4 = __pyx_t_6;
3067
__pyx_L10_bool_binop_done:;
3068
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + __pyx_t_4);
3069
3070
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":104
3071
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0])
3072
* # g = 161*o[0]*o[1]-36*o[0]*o[0]-180*o[1]*o[1]
3073
* while g[2] < 0x8000000000000000L: # <<<<<<<<<<<<<<
3074
* t = 161*o[0]-360*o[1]
3075
* o[1] = 161*o[1]-72*o[0]
3076
*/
3077
while (1) {
3078
__pyx_t_2 = __Pyx_PyInt_From_uint64_t((__pyx_v_g[2])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
3079
__Pyx_GOTREF(__pyx_t_2);
3080
__pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_int_9223372036854775808L, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error)
3081
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3082
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 104, __pyx_L1_error)
3083
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3084
if (!__pyx_t_6) break;
3085
3086
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":105
3087
* # g = 161*o[0]*o[1]-36*o[0]*o[0]-180*o[1]*o[1]
3088
* while g[2] < 0x8000000000000000L:
3089
* t = 161*o[0]-360*o[1] # <<<<<<<<<<<<<<
3090
* o[1] = 161*o[1]-72*o[0]
3091
* o[0] = t
3092
*/
3093
__pyx_v_t = ((0xA1 * (__pyx_v_o[0])) - (0x168 * (__pyx_v_o[1])));
3094
3095
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":106
3096
* while g[2] < 0x8000000000000000L:
3097
* t = 161*o[0]-360*o[1]
3098
* o[1] = 161*o[1]-72*o[0] # <<<<<<<<<<<<<<
3099
* o[0] = t
3100
* # f = 644*g-f
3101
*/
3102
(__pyx_v_o[1]) = ((0xA1 * (__pyx_v_o[1])) - (72 * (__pyx_v_o[0])));
3103
3104
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":107
3105
* t = 161*o[0]-360*o[1]
3106
* o[1] = 161*o[1]-72*o[0]
3107
* o[0] = t # <<<<<<<<<<<<<<
3108
* # f = 644*g-f
3109
* h[2] = 644*g[2] + (161*(g[1]>>8)>>54)
3110
*/
3111
(__pyx_v_o[0]) = __pyx_v_t;
3112
3113
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":109
3114
* o[0] = t
3115
* # f = 644*g-f
3116
* h[2] = 644*g[2] + (161*(g[1]>>8)>>54) # <<<<<<<<<<<<<<
3117
* h[1] = 644*g[1] + (161*(g[0]>>8)>>54)
3118
* h[0] = 644*g[0]
3119
*/
3120
(__pyx_v_h[2]) = ((0x284 * (__pyx_v_g[2])) + ((0xA1 * ((__pyx_v_g[1]) >> 8)) >> 54));
3121
3122
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":110
3123
* # f = 644*g-f
3124
* h[2] = 644*g[2] + (161*(g[1]>>8)>>54)
3125
* h[1] = 644*g[1] + (161*(g[0]>>8)>>54) # <<<<<<<<<<<<<<
3126
* h[0] = 644*g[0]
3127
* f[2] = h[2]-f[2]
3128
*/
3129
(__pyx_v_h[1]) = ((0x284 * (__pyx_v_g[1])) + ((0xA1 * ((__pyx_v_g[0]) >> 8)) >> 54));
3130
3131
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":111
3132
* h[2] = 644*g[2] + (161*(g[1]>>8)>>54)
3133
* h[1] = 644*g[1] + (161*(g[0]>>8)>>54)
3134
* h[0] = 644*g[0] # <<<<<<<<<<<<<<
3135
* f[2] = h[2]-f[2]
3136
* f[1] = h[1]-f[1]
3137
*/
3138
(__pyx_v_h[0]) = (0x284 * (__pyx_v_g[0]));
3139
3140
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":112
3141
* h[1] = 644*g[1] + (161*(g[0]>>8)>>54)
3142
* h[0] = 644*g[0]
3143
* f[2] = h[2]-f[2] # <<<<<<<<<<<<<<
3144
* f[1] = h[1]-f[1]
3145
* f[0] = h[0]-f[0]
3146
*/
3147
(__pyx_v_f[2]) = ((__pyx_v_h[2]) - (__pyx_v_f[2]));
3148
3149
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":113
3150
* h[0] = 644*g[0]
3151
* f[2] = h[2]-f[2]
3152
* f[1] = h[1]-f[1] # <<<<<<<<<<<<<<
3153
* f[0] = h[0]-f[0]
3154
* f[1] -= f[0] > h[0]
3155
*/
3156
(__pyx_v_f[1]) = ((__pyx_v_h[1]) - (__pyx_v_f[1]));
3157
3158
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":114
3159
* f[2] = h[2]-f[2]
3160
* f[1] = h[1]-f[1]
3161
* f[0] = h[0]-f[0] # <<<<<<<<<<<<<<
3162
* f[1] -= f[0] > h[0]
3163
* f[2] -= f[1] > h[1] or (f[1] == h[1] and f[0] > h[0])
3164
*/
3165
(__pyx_v_f[0]) = ((__pyx_v_h[0]) - (__pyx_v_f[0]));
3166
3167
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":115
3168
* f[1] = h[1]-f[1]
3169
* f[0] = h[0]-f[0]
3170
* f[1] -= f[0] > h[0] # <<<<<<<<<<<<<<
3171
* f[2] -= f[1] > h[1] or (f[1] == h[1] and f[0] > h[0])
3172
* # g = 161*f-g
3173
*/
3174
__pyx_t_1 = 1;
3175
(__pyx_v_f[__pyx_t_1]) = ((__pyx_v_f[__pyx_t_1]) - ((__pyx_v_f[0]) > (__pyx_v_h[0])));
3176
3177
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":116
3178
* f[0] = h[0]-f[0]
3179
* f[1] -= f[0] > h[0]
3180
* f[2] -= f[1] > h[1] or (f[1] == h[1] and f[0] > h[0]) # <<<<<<<<<<<<<<
3181
* # g = 161*f-g
3182
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56)
3183
*/
3184
__pyx_t_1 = 2;
3185
__pyx_t_6 = ((__pyx_v_f[1]) > (__pyx_v_h[1]));
3186
if (!__pyx_t_6) {
3187
} else {
3188
__pyx_t_4 = __pyx_t_6;
3189
goto __pyx_L15_bool_binop_done;
3190
}
3191
__pyx_t_6 = ((__pyx_v_f[1]) == (__pyx_v_h[1]));
3192
if (__pyx_t_6) {
3193
} else {
3194
__pyx_t_4 = __pyx_t_6;
3195
goto __pyx_L15_bool_binop_done;
3196
}
3197
__pyx_t_6 = ((__pyx_v_f[0]) > (__pyx_v_h[0]));
3198
__pyx_t_4 = __pyx_t_6;
3199
__pyx_L15_bool_binop_done:;
3200
(__pyx_v_f[__pyx_t_1]) = ((__pyx_v_f[__pyx_t_1]) - __pyx_t_4);
3201
3202
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":118
3203
* f[2] -= f[1] > h[1] or (f[1] == h[1] and f[0] > h[0])
3204
* # g = 161*f-g
3205
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56) # <<<<<<<<<<<<<<
3206
* h[1] = 161*f[1] + (161*(f[0]>>8)>>56)
3207
* h[0] = 161*f[0]
3208
*/
3209
(__pyx_v_h[2]) = ((0xA1 * (__pyx_v_f[2])) + ((0xA1 * ((__pyx_v_f[1]) >> 8)) >> 56));
3210
3211
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":119
3212
* # g = 161*f-g
3213
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56)
3214
* h[1] = 161*f[1] + (161*(f[0]>>8)>>56) # <<<<<<<<<<<<<<
3215
* h[0] = 161*f[0]
3216
* g[2] = h[2]-g[2]
3217
*/
3218
(__pyx_v_h[1]) = ((0xA1 * (__pyx_v_f[1])) + ((0xA1 * ((__pyx_v_f[0]) >> 8)) >> 56));
3219
3220
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":120
3221
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56)
3222
* h[1] = 161*f[1] + (161*(f[0]>>8)>>56)
3223
* h[0] = 161*f[0] # <<<<<<<<<<<<<<
3224
* g[2] = h[2]-g[2]
3225
* g[1] = h[1]-g[1]
3226
*/
3227
(__pyx_v_h[0]) = (0xA1 * (__pyx_v_f[0]));
3228
3229
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":121
3230
* h[1] = 161*f[1] + (161*(f[0]>>8)>>56)
3231
* h[0] = 161*f[0]
3232
* g[2] = h[2]-g[2] # <<<<<<<<<<<<<<
3233
* g[1] = h[1]-g[1]
3234
* g[0] = h[0]-g[0]
3235
*/
3236
(__pyx_v_g[2]) = ((__pyx_v_h[2]) - (__pyx_v_g[2]));
3237
3238
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":122
3239
* h[0] = 161*f[0]
3240
* g[2] = h[2]-g[2]
3241
* g[1] = h[1]-g[1] # <<<<<<<<<<<<<<
3242
* g[0] = h[0]-g[0]
3243
* g[1] -= g[0] > h[0]
3244
*/
3245
(__pyx_v_g[1]) = ((__pyx_v_h[1]) - (__pyx_v_g[1]));
3246
3247
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":123
3248
* g[2] = h[2]-g[2]
3249
* g[1] = h[1]-g[1]
3250
* g[0] = h[0]-g[0] # <<<<<<<<<<<<<<
3251
* g[1] -= g[0] > h[0]
3252
* g[2] -= g[1] > h[1] or (g[1] == h[1] and g[0] > h[0])
3253
*/
3254
(__pyx_v_g[0]) = ((__pyx_v_h[0]) - (__pyx_v_g[0]));
3255
3256
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":124
3257
* g[1] = h[1]-g[1]
3258
* g[0] = h[0]-g[0]
3259
* g[1] -= g[0] > h[0] # <<<<<<<<<<<<<<
3260
* g[2] -= g[1] > h[1] or (g[1] == h[1] and g[0] > h[0])
3261
* o[3] += o[2]
3262
*/
3263
__pyx_t_1 = 1;
3264
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) - ((__pyx_v_g[0]) > (__pyx_v_h[0])));
3265
3266
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":125
3267
* g[0] = h[0]-g[0]
3268
* g[1] -= g[0] > h[0]
3269
* g[2] -= g[1] > h[1] or (g[1] == h[1] and g[0] > h[0]) # <<<<<<<<<<<<<<
3270
* o[3] += o[2]
3271
* o[2] = o[3]-o[2]
3272
*/
3273
__pyx_t_1 = 2;
3274
__pyx_t_6 = ((__pyx_v_g[1]) > (__pyx_v_h[1]));
3275
if (!__pyx_t_6) {
3276
} else {
3277
__pyx_t_4 = __pyx_t_6;
3278
goto __pyx_L18_bool_binop_done;
3279
}
3280
__pyx_t_6 = ((__pyx_v_g[1]) == (__pyx_v_h[1]));
3281
if (__pyx_t_6) {
3282
} else {
3283
__pyx_t_4 = __pyx_t_6;
3284
goto __pyx_L18_bool_binop_done;
3285
}
3286
__pyx_t_6 = ((__pyx_v_g[0]) > (__pyx_v_h[0]));
3287
__pyx_t_4 = __pyx_t_6;
3288
__pyx_L18_bool_binop_done:;
3289
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) - __pyx_t_4);
3290
3291
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":126
3292
* g[1] -= g[0] > h[0]
3293
* g[2] -= g[1] > h[1] or (g[1] == h[1] and g[0] > h[0])
3294
* o[3] += o[2] # <<<<<<<<<<<<<<
3295
* o[2] = o[3]-o[2]
3296
* elif o[1] < 0L:
3297
*/
3298
__pyx_t_1 = 3;
3299
(__pyx_v_o[__pyx_t_1]) = ((__pyx_v_o[__pyx_t_1]) + (__pyx_v_o[2]));
3300
3301
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":127
3302
* g[2] -= g[1] > h[1] or (g[1] == h[1] and g[0] > h[0])
3303
* o[3] += o[2]
3304
* o[2] = o[3]-o[2] # <<<<<<<<<<<<<<
3305
* elif o[1] < 0L:
3306
* # g += h
3307
*/
3308
(__pyx_v_o[2]) = ((__pyx_v_o[3]) - (__pyx_v_o[2]));
3309
}
3310
3311
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":92
3312
* f[0] <<= 1
3313
* # f = 2*o[0]*o[1]
3314
* if o[1] > 0L: # <<<<<<<<<<<<<<
3315
* # g = -g
3316
* g[0] = -g[0]
3317
*/
3318
goto __pyx_L7;
3319
}
3320
3321
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":128
3322
* o[3] += o[2]
3323
* o[2] = o[3]-o[2]
3324
* elif o[1] < 0L: # <<<<<<<<<<<<<<
3325
* # g += h
3326
* g[2] += h[2]
3327
*/
3328
__pyx_t_6 = (((__pyx_v_o[1]) < 0L) != 0);
3329
if (__pyx_t_6) {
3330
3331
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":130
3332
* elif o[1] < 0L:
3333
* # g += h
3334
* g[2] += h[2] # <<<<<<<<<<<<<<
3335
* g[1] += h[1]
3336
* g[0] += h[0]
3337
*/
3338
__pyx_t_1 = 2;
3339
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + (__pyx_v_h[2]));
3340
3341
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":131
3342
* # g += h
3343
* g[2] += h[2]
3344
* g[1] += h[1] # <<<<<<<<<<<<<<
3345
* g[0] += h[0]
3346
* g[1] += g[0] < h[0]
3347
*/
3348
__pyx_t_1 = 1;
3349
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + (__pyx_v_h[1]));
3350
3351
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":132
3352
* g[2] += h[2]
3353
* g[1] += h[1]
3354
* g[0] += h[0] # <<<<<<<<<<<<<<
3355
* g[1] += g[0] < h[0]
3356
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0])
3357
*/
3358
__pyx_t_1 = 0;
3359
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + (__pyx_v_h[0]));
3360
3361
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":133
3362
* g[1] += h[1]
3363
* g[0] += h[0]
3364
* g[1] += g[0] < h[0] # <<<<<<<<<<<<<<
3365
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0])
3366
* # g = 161*o[0]*o[1]+36*o[0]*o[0]+180*o[1]*o[1]
3367
*/
3368
__pyx_t_1 = 1;
3369
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + ((__pyx_v_g[0]) < (__pyx_v_h[0])));
3370
3371
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":134
3372
* g[0] += h[0]
3373
* g[1] += g[0] < h[0]
3374
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0]) # <<<<<<<<<<<<<<
3375
* # g = 161*o[0]*o[1]+36*o[0]*o[0]+180*o[1]*o[1]
3376
* while g[2] >= 0x8000000000000000L:
3377
*/
3378
__pyx_t_1 = 2;
3379
__pyx_t_6 = ((__pyx_v_g[1]) < (__pyx_v_h[1]));
3380
if (!__pyx_t_6) {
3381
} else {
3382
__pyx_t_4 = __pyx_t_6;
3383
goto __pyx_L21_bool_binop_done;
3384
}
3385
__pyx_t_6 = ((__pyx_v_g[1]) == (__pyx_v_h[1]));
3386
if (__pyx_t_6) {
3387
} else {
3388
__pyx_t_4 = __pyx_t_6;
3389
goto __pyx_L21_bool_binop_done;
3390
}
3391
__pyx_t_6 = ((__pyx_v_g[0]) < (__pyx_v_h[0]));
3392
__pyx_t_4 = __pyx_t_6;
3393
__pyx_L21_bool_binop_done:;
3394
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) + __pyx_t_4);
3395
3396
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":136
3397
* g[2] += g[1] < h[1] or (g[1] == h[1] and g[0] < h[0])
3398
* # g = 161*o[0]*o[1]+36*o[0]*o[0]+180*o[1]*o[1]
3399
* while g[2] >= 0x8000000000000000L: # <<<<<<<<<<<<<<
3400
* t = 161*o[0]+360*o[1]
3401
* o[1] = 72*o[0]+161*o[1]
3402
*/
3403
while (1) {
3404
__pyx_t_3 = __Pyx_PyInt_From_uint64_t((__pyx_v_g[2])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 136, __pyx_L1_error)
3405
__Pyx_GOTREF(__pyx_t_3);
3406
__pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_9223372036854775808L, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error)
3407
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3408
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 136, __pyx_L1_error)
3409
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3410
if (!__pyx_t_6) break;
3411
3412
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":137
3413
* # g = 161*o[0]*o[1]+36*o[0]*o[0]+180*o[1]*o[1]
3414
* while g[2] >= 0x8000000000000000L:
3415
* t = 161*o[0]+360*o[1] # <<<<<<<<<<<<<<
3416
* o[1] = 72*o[0]+161*o[1]
3417
* o[0] = t
3418
*/
3419
__pyx_v_t = ((0xA1 * (__pyx_v_o[0])) + (0x168 * (__pyx_v_o[1])));
3420
3421
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":138
3422
* while g[2] >= 0x8000000000000000L:
3423
* t = 161*o[0]+360*o[1]
3424
* o[1] = 72*o[0]+161*o[1] # <<<<<<<<<<<<<<
3425
* o[0] = t
3426
* # f = 644*g-f
3427
*/
3428
(__pyx_v_o[1]) = ((72 * (__pyx_v_o[0])) + (0xA1 * (__pyx_v_o[1])));
3429
3430
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":139
3431
* t = 161*o[0]+360*o[1]
3432
* o[1] = 72*o[0]+161*o[1]
3433
* o[0] = t # <<<<<<<<<<<<<<
3434
* # f = 644*g-f
3435
* h[2] = 644*g[2] + (161*(g[1]>>8)>>54)
3436
*/
3437
(__pyx_v_o[0]) = __pyx_v_t;
3438
3439
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":141
3440
* o[0] = t
3441
* # f = 644*g-f
3442
* h[2] = 644*g[2] + (161*(g[1]>>8)>>54) # <<<<<<<<<<<<<<
3443
* h[1] = 644*g[1] + (161*(g[0]>>8)>>54)
3444
* h[0] = 644*g[0]
3445
*/
3446
(__pyx_v_h[2]) = ((0x284 * (__pyx_v_g[2])) + ((0xA1 * ((__pyx_v_g[1]) >> 8)) >> 54));
3447
3448
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":142
3449
* # f = 644*g-f
3450
* h[2] = 644*g[2] + (161*(g[1]>>8)>>54)
3451
* h[1] = 644*g[1] + (161*(g[0]>>8)>>54) # <<<<<<<<<<<<<<
3452
* h[0] = 644*g[0]
3453
* f[2] = h[2]-f[2]
3454
*/
3455
(__pyx_v_h[1]) = ((0x284 * (__pyx_v_g[1])) + ((0xA1 * ((__pyx_v_g[0]) >> 8)) >> 54));
3456
3457
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":143
3458
* h[2] = 644*g[2] + (161*(g[1]>>8)>>54)
3459
* h[1] = 644*g[1] + (161*(g[0]>>8)>>54)
3460
* h[0] = 644*g[0] # <<<<<<<<<<<<<<
3461
* f[2] = h[2]-f[2]
3462
* f[1] = h[1]-f[1]
3463
*/
3464
(__pyx_v_h[0]) = (0x284 * (__pyx_v_g[0]));
3465
3466
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":144
3467
* h[1] = 644*g[1] + (161*(g[0]>>8)>>54)
3468
* h[0] = 644*g[0]
3469
* f[2] = h[2]-f[2] # <<<<<<<<<<<<<<
3470
* f[1] = h[1]-f[1]
3471
* f[0] = h[0]-f[0]
3472
*/
3473
(__pyx_v_f[2]) = ((__pyx_v_h[2]) - (__pyx_v_f[2]));
3474
3475
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":145
3476
* h[0] = 644*g[0]
3477
* f[2] = h[2]-f[2]
3478
* f[1] = h[1]-f[1] # <<<<<<<<<<<<<<
3479
* f[0] = h[0]-f[0]
3480
* f[1] -= f[0] > h[0]
3481
*/
3482
(__pyx_v_f[1]) = ((__pyx_v_h[1]) - (__pyx_v_f[1]));
3483
3484
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":146
3485
* f[2] = h[2]-f[2]
3486
* f[1] = h[1]-f[1]
3487
* f[0] = h[0]-f[0] # <<<<<<<<<<<<<<
3488
* f[1] -= f[0] > h[0]
3489
* f[2] -= f[1] > h[1] or (f[1] == h[1] and f[0] > h[0])
3490
*/
3491
(__pyx_v_f[0]) = ((__pyx_v_h[0]) - (__pyx_v_f[0]));
3492
3493
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":147
3494
* f[1] = h[1]-f[1]
3495
* f[0] = h[0]-f[0]
3496
* f[1] -= f[0] > h[0] # <<<<<<<<<<<<<<
3497
* f[2] -= f[1] > h[1] or (f[1] == h[1] and f[0] > h[0])
3498
* # g = 161*f-g
3499
*/
3500
__pyx_t_1 = 1;
3501
(__pyx_v_f[__pyx_t_1]) = ((__pyx_v_f[__pyx_t_1]) - ((__pyx_v_f[0]) > (__pyx_v_h[0])));
3502
3503
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":148
3504
* f[0] = h[0]-f[0]
3505
* f[1] -= f[0] > h[0]
3506
* f[2] -= f[1] > h[1] or (f[1] == h[1] and f[0] > h[0]) # <<<<<<<<<<<<<<
3507
* # g = 161*f-g
3508
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56)
3509
*/
3510
__pyx_t_1 = 2;
3511
__pyx_t_6 = ((__pyx_v_f[1]) > (__pyx_v_h[1]));
3512
if (!__pyx_t_6) {
3513
} else {
3514
__pyx_t_4 = __pyx_t_6;
3515
goto __pyx_L26_bool_binop_done;
3516
}
3517
__pyx_t_6 = ((__pyx_v_f[1]) == (__pyx_v_h[1]));
3518
if (__pyx_t_6) {
3519
} else {
3520
__pyx_t_4 = __pyx_t_6;
3521
goto __pyx_L26_bool_binop_done;
3522
}
3523
__pyx_t_6 = ((__pyx_v_f[0]) > (__pyx_v_h[0]));
3524
__pyx_t_4 = __pyx_t_6;
3525
__pyx_L26_bool_binop_done:;
3526
(__pyx_v_f[__pyx_t_1]) = ((__pyx_v_f[__pyx_t_1]) - __pyx_t_4);
3527
3528
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":150
3529
* f[2] -= f[1] > h[1] or (f[1] == h[1] and f[0] > h[0])
3530
* # g = 161*f-g
3531
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56) # <<<<<<<<<<<<<<
3532
* h[1] = 161*f[1] + (161*(f[0]>>8)>>56)
3533
* h[0] = 161*f[0]
3534
*/
3535
(__pyx_v_h[2]) = ((0xA1 * (__pyx_v_f[2])) + ((0xA1 * ((__pyx_v_f[1]) >> 8)) >> 56));
3536
3537
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":151
3538
* # g = 161*f-g
3539
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56)
3540
* h[1] = 161*f[1] + (161*(f[0]>>8)>>56) # <<<<<<<<<<<<<<
3541
* h[0] = 161*f[0]
3542
* g[2] = h[2]-g[2]
3543
*/
3544
(__pyx_v_h[1]) = ((0xA1 * (__pyx_v_f[1])) + ((0xA1 * ((__pyx_v_f[0]) >> 8)) >> 56));
3545
3546
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":152
3547
* h[2] = 161*f[2] + (161*(f[1]>>8)>>56)
3548
* h[1] = 161*f[1] + (161*(f[0]>>8)>>56)
3549
* h[0] = 161*f[0] # <<<<<<<<<<<<<<
3550
* g[2] = h[2]-g[2]
3551
* g[1] = h[1]-g[1]
3552
*/
3553
(__pyx_v_h[0]) = (0xA1 * (__pyx_v_f[0]));
3554
3555
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":153
3556
* h[1] = 161*f[1] + (161*(f[0]>>8)>>56)
3557
* h[0] = 161*f[0]
3558
* g[2] = h[2]-g[2] # <<<<<<<<<<<<<<
3559
* g[1] = h[1]-g[1]
3560
* g[0] = h[0]-g[0]
3561
*/
3562
(__pyx_v_g[2]) = ((__pyx_v_h[2]) - (__pyx_v_g[2]));
3563
3564
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":154
3565
* h[0] = 161*f[0]
3566
* g[2] = h[2]-g[2]
3567
* g[1] = h[1]-g[1] # <<<<<<<<<<<<<<
3568
* g[0] = h[0]-g[0]
3569
* g[1] -= g[0] > h[0]
3570
*/
3571
(__pyx_v_g[1]) = ((__pyx_v_h[1]) - (__pyx_v_g[1]));
3572
3573
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":155
3574
* g[2] = h[2]-g[2]
3575
* g[1] = h[1]-g[1]
3576
* g[0] = h[0]-g[0] # <<<<<<<<<<<<<<
3577
* g[1] -= g[0] > h[0]
3578
* g[2] -= g[1] > h[1] or (g[1] == h[1] and g[0] > h[0])
3579
*/
3580
(__pyx_v_g[0]) = ((__pyx_v_h[0]) - (__pyx_v_g[0]));
3581
3582
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":156
3583
* g[1] = h[1]-g[1]
3584
* g[0] = h[0]-g[0]
3585
* g[1] -= g[0] > h[0] # <<<<<<<<<<<<<<
3586
* g[2] -= g[1] > h[1] or (g[1] == h[1] and g[0] > h[0])
3587
* o[2] = o[3]-o[2]
3588
*/
3589
__pyx_t_1 = 1;
3590
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) - ((__pyx_v_g[0]) > (__pyx_v_h[0])));
3591
3592
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":157
3593
* g[0] = h[0]-g[0]
3594
* g[1] -= g[0] > h[0]
3595
* g[2] -= g[1] > h[1] or (g[1] == h[1] and g[0] > h[0]) # <<<<<<<<<<<<<<
3596
* o[2] = o[3]-o[2]
3597
* o[3] -= o[2]
3598
*/
3599
__pyx_t_1 = 2;
3600
__pyx_t_6 = ((__pyx_v_g[1]) > (__pyx_v_h[1]));
3601
if (!__pyx_t_6) {
3602
} else {
3603
__pyx_t_4 = __pyx_t_6;
3604
goto __pyx_L29_bool_binop_done;
3605
}
3606
__pyx_t_6 = ((__pyx_v_g[1]) == (__pyx_v_h[1]));
3607
if (__pyx_t_6) {
3608
} else {
3609
__pyx_t_4 = __pyx_t_6;
3610
goto __pyx_L29_bool_binop_done;
3611
}
3612
__pyx_t_6 = ((__pyx_v_g[0]) > (__pyx_v_h[0]));
3613
__pyx_t_4 = __pyx_t_6;
3614
__pyx_L29_bool_binop_done:;
3615
(__pyx_v_g[__pyx_t_1]) = ((__pyx_v_g[__pyx_t_1]) - __pyx_t_4);
3616
3617
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":158
3618
* g[1] -= g[0] > h[0]
3619
* g[2] -= g[1] > h[1] or (g[1] == h[1] and g[0] > h[0])
3620
* o[2] = o[3]-o[2] # <<<<<<<<<<<<<<
3621
* o[3] -= o[2]
3622
* o[0] = o[0]-o[1]>>1
3623
*/
3624
(__pyx_v_o[2]) = ((__pyx_v_o[3]) - (__pyx_v_o[2]));
3625
3626
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":159
3627
* g[2] -= g[1] > h[1] or (g[1] == h[1] and g[0] > h[0])
3628
* o[2] = o[3]-o[2]
3629
* o[3] -= o[2] # <<<<<<<<<<<<<<
3630
* o[0] = o[0]-o[1]>>1
3631
* if not o[0]%13 and not o[1]%8 and o[0]/13 == -(o[1]/8):
3632
*/
3633
__pyx_t_1 = 3;
3634
(__pyx_v_o[__pyx_t_1]) = ((__pyx_v_o[__pyx_t_1]) - (__pyx_v_o[2]));
3635
}
3636
3637
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":128
3638
* o[3] += o[2]
3639
* o[2] = o[3]-o[2]
3640
* elif o[1] < 0L: # <<<<<<<<<<<<<<
3641
* # g += h
3642
* g[2] += h[2]
3643
*/
3644
}
3645
__pyx_L7:;
3646
3647
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":160
3648
* o[2] = o[3]-o[2]
3649
* o[3] -= o[2]
3650
* o[0] = o[0]-o[1]>>1 # <<<<<<<<<<<<<<
3651
* if not o[0]%13 and not o[1]%8 and o[0]/13 == -(o[1]/8):
3652
* t = o[0]/13
3653
*/
3654
(__pyx_v_o[0]) = (((__pyx_v_o[0]) - (__pyx_v_o[1])) >> 1);
3655
3656
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":161
3657
* o[3] -= o[2]
3658
* o[0] = o[0]-o[1]>>1
3659
* if not o[0]%13 and not o[1]%8 and o[0]/13 == -(o[1]/8): # <<<<<<<<<<<<<<
3660
* t = o[0]/13
3661
* o[0] = 5*t
3662
*/
3663
__pyx_t_7 = ((!(__Pyx_mod_int64_t((__pyx_v_o[0]), 13) != 0)) != 0);
3664
if (__pyx_t_7) {
3665
} else {
3666
__pyx_t_6 = __pyx_t_7;
3667
goto __pyx_L33_bool_binop_done;
3668
}
3669
__pyx_t_7 = ((!(__Pyx_mod_int64_t((__pyx_v_o[1]), 8) != 0)) != 0);
3670
if (__pyx_t_7) {
3671
} else {
3672
__pyx_t_6 = __pyx_t_7;
3673
goto __pyx_L33_bool_binop_done;
3674
}
3675
__pyx_t_7 = ((__Pyx_div_int64_t((__pyx_v_o[0]), 13) == (-__Pyx_div_int64_t((__pyx_v_o[1]), 8))) != 0);
3676
__pyx_t_6 = __pyx_t_7;
3677
__pyx_L33_bool_binop_done:;
3678
if (__pyx_t_6) {
3679
3680
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":162
3681
* o[0] = o[0]-o[1]>>1
3682
* if not o[0]%13 and not o[1]%8 and o[0]/13 == -(o[1]/8):
3683
* t = o[0]/13 # <<<<<<<<<<<<<<
3684
* o[0] = 5*t
3685
* o[1] = 8*t
3686
*/
3687
__pyx_v_t = __Pyx_div_int64_t((__pyx_v_o[0]), 13);
3688
3689
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":163
3690
* if not o[0]%13 and not o[1]%8 and o[0]/13 == -(o[1]/8):
3691
* t = o[0]/13
3692
* o[0] = 5*t # <<<<<<<<<<<<<<
3693
* o[1] = 8*t
3694
* o[2] = o[3]-o[2]
3695
*/
3696
(__pyx_v_o[0]) = (5 * __pyx_v_t);
3697
3698
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":164
3699
* t = o[0]/13
3700
* o[0] = 5*t
3701
* o[1] = 8*t # <<<<<<<<<<<<<<
3702
* o[2] = o[3]-o[2]
3703
* o[3] -= o[2]
3704
*/
3705
(__pyx_v_o[1]) = (8 * __pyx_v_t);
3706
3707
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":165
3708
* o[0] = 5*t
3709
* o[1] = 8*t
3710
* o[2] = o[3]-o[2] # <<<<<<<<<<<<<<
3711
* o[3] -= o[2]
3712
* elif not o[0]%29 and not o[1]%18 and o[0]/29 == -(o[1]/18):
3713
*/
3714
(__pyx_v_o[2]) = ((__pyx_v_o[3]) - (__pyx_v_o[2]));
3715
3716
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":166
3717
* o[1] = 8*t
3718
* o[2] = o[3]-o[2]
3719
* o[3] -= o[2] # <<<<<<<<<<<<<<
3720
* elif not o[0]%29 and not o[1]%18 and o[0]/29 == -(o[1]/18):
3721
* t = o[1]/18
3722
*/
3723
__pyx_t_1 = 3;
3724
(__pyx_v_o[__pyx_t_1]) = ((__pyx_v_o[__pyx_t_1]) - (__pyx_v_o[2]));
3725
3726
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":161
3727
* o[3] -= o[2]
3728
* o[0] = o[0]-o[1]>>1
3729
* if not o[0]%13 and not o[1]%8 and o[0]/13 == -(o[1]/8): # <<<<<<<<<<<<<<
3730
* t = o[0]/13
3731
* o[0] = 5*t
3732
*/
3733
goto __pyx_L32;
3734
}
3735
3736
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":167
3737
* o[2] = o[3]-o[2]
3738
* o[3] -= o[2]
3739
* elif not o[0]%29 and not o[1]%18 and o[0]/29 == -(o[1]/18): # <<<<<<<<<<<<<<
3740
* t = o[1]/18
3741
* o[0] = 11*t
3742
*/
3743
__pyx_t_7 = ((!(__Pyx_mod_int64_t((__pyx_v_o[0]), 29) != 0)) != 0);
3744
if (__pyx_t_7) {
3745
} else {
3746
__pyx_t_6 = __pyx_t_7;
3747
goto __pyx_L36_bool_binop_done;
3748
}
3749
__pyx_t_7 = ((!(__Pyx_mod_int64_t((__pyx_v_o[1]), 18) != 0)) != 0);
3750
if (__pyx_t_7) {
3751
} else {
3752
__pyx_t_6 = __pyx_t_7;
3753
goto __pyx_L36_bool_binop_done;
3754
}
3755
__pyx_t_7 = ((__Pyx_div_int64_t((__pyx_v_o[0]), 29) == (-__Pyx_div_int64_t((__pyx_v_o[1]), 18))) != 0);
3756
__pyx_t_6 = __pyx_t_7;
3757
__pyx_L36_bool_binop_done:;
3758
if (__pyx_t_6) {
3759
3760
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":168
3761
* o[3] -= o[2]
3762
* elif not o[0]%29 and not o[1]%18 and o[0]/29 == -(o[1]/18):
3763
* t = o[1]/18 # <<<<<<<<<<<<<<
3764
* o[0] = 11*t
3765
* o[1] = 18*t
3766
*/
3767
__pyx_v_t = __Pyx_div_int64_t((__pyx_v_o[1]), 18);
3768
3769
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":169
3770
* elif not o[0]%29 and not o[1]%18 and o[0]/29 == -(o[1]/18):
3771
* t = o[1]/18
3772
* o[0] = 11*t # <<<<<<<<<<<<<<
3773
* o[1] = 18*t
3774
* o[2] = o[3]-o[2]
3775
*/
3776
(__pyx_v_o[0]) = (11 * __pyx_v_t);
3777
3778
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":170
3779
* t = o[1]/18
3780
* o[0] = 11*t
3781
* o[1] = 18*t # <<<<<<<<<<<<<<
3782
* o[2] = o[3]-o[2]
3783
* o[3] -= o[2]
3784
*/
3785
(__pyx_v_o[1]) = (18 * __pyx_v_t);
3786
3787
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":171
3788
* o[0] = 11*t
3789
* o[1] = 18*t
3790
* o[2] = o[3]-o[2] # <<<<<<<<<<<<<<
3791
* o[3] -= o[2]
3792
* o[0] *= 1-2*s
3793
*/
3794
(__pyx_v_o[2]) = ((__pyx_v_o[3]) - (__pyx_v_o[2]));
3795
3796
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":172
3797
* o[1] = 18*t
3798
* o[2] = o[3]-o[2]
3799
* o[3] -= o[2] # <<<<<<<<<<<<<<
3800
* o[0] *= 1-2*s
3801
* o[1] *= 1-2*s
3802
*/
3803
__pyx_t_1 = 3;
3804
(__pyx_v_o[__pyx_t_1]) = ((__pyx_v_o[__pyx_t_1]) - (__pyx_v_o[2]));
3805
3806
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":167
3807
* o[2] = o[3]-o[2]
3808
* o[3] -= o[2]
3809
* elif not o[0]%29 and not o[1]%18 and o[0]/29 == -(o[1]/18): # <<<<<<<<<<<<<<
3810
* t = o[1]/18
3811
* o[0] = 11*t
3812
*/
3813
}
3814
__pyx_L32:;
3815
3816
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":173
3817
* o[2] = o[3]-o[2]
3818
* o[3] -= o[2]
3819
* o[0] *= 1-2*s # <<<<<<<<<<<<<<
3820
* o[1] *= 1-2*s
3821
*
3822
*/
3823
__pyx_t_1 = 0;
3824
(__pyx_v_o[__pyx_t_1]) = ((__pyx_v_o[__pyx_t_1]) * (1 - (2 * __pyx_v_s)));
3825
3826
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":174
3827
* o[3] -= o[2]
3828
* o[0] *= 1-2*s
3829
* o[1] *= 1-2*s # <<<<<<<<<<<<<<
3830
*
3831
* cdef void f_mapC(mpz_t rop1, mpz_t rop2, mpz_t rop3, mpz_t rop4, mpz_t op1, mpz_t op2):
3832
*/
3833
__pyx_t_1 = 1;
3834
(__pyx_v_o[__pyx_t_1]) = ((__pyx_v_o[__pyx_t_1]) * (1 - (2 * __pyx_v_s)));
3835
3836
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":33
3837
* from libc.stdint cimport int64_t, uint64_t
3838
*
3839
* cdef void f_map64(int64_t *o): # <<<<<<<<<<<<<<
3840
* cdef bint s
3841
* cdef uint64_t x[2],y[2],g[3],f[3],h[3],t
3842
*/
3843
3844
/* function exit code */
3845
goto __pyx_L0;
3846
__pyx_L1_error:;
3847
__Pyx_XDECREF(__pyx_t_2);
3848
__Pyx_XDECREF(__pyx_t_3);
3849
__Pyx_XDECREF(__pyx_t_5);
3850
__Pyx_WriteUnraisable("code.alex.psage.psage.ellcurve.minmodel.sqrt5.f_map64", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
3851
__pyx_L0:;
3852
__Pyx_RefNannyFinishContext();
3853
}
3854
3855
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":176
3856
* o[1] *= 1-2*s
3857
*
3858
* cdef void f_mapC(mpz_t rop1, mpz_t rop2, mpz_t rop3, mpz_t rop4, mpz_t op1, mpz_t op2): # <<<<<<<<<<<<<<
3859
* """
3860
* Let `G` be the function
3861
*/
3862
3863
static void __pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_mapC(__mpz_struct *__pyx_v_rop1, __mpz_struct *__pyx_v_rop2, __mpz_struct *__pyx_v_rop3, __mpz_struct *__pyx_v_rop4, __mpz_struct *__pyx_v_op1, __mpz_struct *__pyx_v_op2) {
3864
int __pyx_v_s;
3865
int64_t __pyx_v_o[4];
3866
mpz_t __pyx_v_f;
3867
mpz_t __pyx_v_g;
3868
mpz_t __pyx_v_t;
3869
__Pyx_RefNannyDeclarations
3870
int __pyx_t_1;
3871
long __pyx_t_2;
3872
int __pyx_t_3;
3873
__Pyx_RefNannySetupContext("f_mapC", 0);
3874
3875
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":194
3876
* cdef int64_t o[4]
3877
* cdef mpz_t f,g,t
3878
* mpz_add(rop1,op1,op1) # <<<<<<<<<<<<<<
3879
* mpz_add(rop1,rop1,op2)
3880
* if not mpz_sgn(rop1):
3881
*/
3882
mpz_add(__pyx_v_rop1, __pyx_v_op1, __pyx_v_op1);
3883
3884
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":195
3885
* cdef mpz_t f,g,t
3886
* mpz_add(rop1,op1,op1)
3887
* mpz_add(rop1,rop1,op2) # <<<<<<<<<<<<<<
3888
* if not mpz_sgn(rop1):
3889
* mpz_set(rop1, op1)
3890
*/
3891
mpz_add(__pyx_v_rop1, __pyx_v_rop1, __pyx_v_op2);
3892
3893
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":196
3894
* mpz_add(rop1,op1,op1)
3895
* mpz_add(rop1,rop1,op2)
3896
* if not mpz_sgn(rop1): # <<<<<<<<<<<<<<
3897
* mpz_set(rop1, op1)
3898
* mpz_set(rop2, op2)
3899
*/
3900
__pyx_t_1 = ((!(mpz_sgn(__pyx_v_rop1) != 0)) != 0);
3901
if (__pyx_t_1) {
3902
3903
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":197
3904
* mpz_add(rop1,rop1,op2)
3905
* if not mpz_sgn(rop1):
3906
* mpz_set(rop1, op1) # <<<<<<<<<<<<<<
3907
* mpz_set(rop2, op2)
3908
* mpz_set_si(rop3, 1)
3909
*/
3910
mpz_set(__pyx_v_rop1, __pyx_v_op1);
3911
3912
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":198
3913
* if not mpz_sgn(rop1):
3914
* mpz_set(rop1, op1)
3915
* mpz_set(rop2, op2) # <<<<<<<<<<<<<<
3916
* mpz_set_si(rop3, 1)
3917
* mpz_set_si(rop4, 0)
3918
*/
3919
mpz_set(__pyx_v_rop2, __pyx_v_op2);
3920
3921
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":199
3922
* mpz_set(rop1, op1)
3923
* mpz_set(rop2, op2)
3924
* mpz_set_si(rop3, 1) # <<<<<<<<<<<<<<
3925
* mpz_set_si(rop4, 0)
3926
* return
3927
*/
3928
mpz_set_si(__pyx_v_rop3, 1);
3929
3930
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":200
3931
* mpz_set(rop2, op2)
3932
* mpz_set_si(rop3, 1)
3933
* mpz_set_si(rop4, 0) # <<<<<<<<<<<<<<
3934
* return
3935
* mpz_set(rop2,op2)
3936
*/
3937
mpz_set_si(__pyx_v_rop4, 0);
3938
3939
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":201
3940
* mpz_set_si(rop3, 1)
3941
* mpz_set_si(rop4, 0)
3942
* return # <<<<<<<<<<<<<<
3943
* mpz_set(rop2,op2)
3944
* if mpz_sizeinbase(rop1, 2) < (sizeof(o[0])<<3):
3945
*/
3946
goto __pyx_L0;
3947
3948
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":196
3949
* mpz_add(rop1,op1,op1)
3950
* mpz_add(rop1,rop1,op2)
3951
* if not mpz_sgn(rop1): # <<<<<<<<<<<<<<
3952
* mpz_set(rop1, op1)
3953
* mpz_set(rop2, op2)
3954
*/
3955
}
3956
3957
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":202
3958
* mpz_set_si(rop4, 0)
3959
* return
3960
* mpz_set(rop2,op2) # <<<<<<<<<<<<<<
3961
* if mpz_sizeinbase(rop1, 2) < (sizeof(o[0])<<3):
3962
* if mpz_sizeinbase(rop2, 2) < (sizeof(o[1])<<3):
3963
*/
3964
mpz_set(__pyx_v_rop2, __pyx_v_op2);
3965
3966
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":203
3967
* return
3968
* mpz_set(rop2,op2)
3969
* if mpz_sizeinbase(rop1, 2) < (sizeof(o[0])<<3): # <<<<<<<<<<<<<<
3970
* if mpz_sizeinbase(rop2, 2) < (sizeof(o[1])<<3):
3971
* mpz_export(&o[0], NULL, -1, sizeof(o[0]), -1, 0, rop1)
3972
*/
3973
__pyx_t_1 = ((mpz_sizeinbase(__pyx_v_rop1, 2) < ((sizeof((__pyx_v_o[0]))) << 3)) != 0);
3974
if (__pyx_t_1) {
3975
3976
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":204
3977
* mpz_set(rop2,op2)
3978
* if mpz_sizeinbase(rop1, 2) < (sizeof(o[0])<<3):
3979
* if mpz_sizeinbase(rop2, 2) < (sizeof(o[1])<<3): # <<<<<<<<<<<<<<
3980
* mpz_export(&o[0], NULL, -1, sizeof(o[0]), -1, 0, rop1)
3981
* mpz_export(&o[1], NULL, -1, sizeof(o[1]), -1, 0, rop2)
3982
*/
3983
__pyx_t_1 = ((mpz_sizeinbase(__pyx_v_rop2, 2) < ((sizeof((__pyx_v_o[1]))) << 3)) != 0);
3984
if (__pyx_t_1) {
3985
3986
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":205
3987
* if mpz_sizeinbase(rop1, 2) < (sizeof(o[0])<<3):
3988
* if mpz_sizeinbase(rop2, 2) < (sizeof(o[1])<<3):
3989
* mpz_export(&o[0], NULL, -1, sizeof(o[0]), -1, 0, rop1) # <<<<<<<<<<<<<<
3990
* mpz_export(&o[1], NULL, -1, sizeof(o[1]), -1, 0, rop2)
3991
* o[0] *= mpz_sgn(rop1)
3992
*/
3993
mpz_export((&(__pyx_v_o[0])), NULL, -1, (sizeof((__pyx_v_o[0]))), -1, 0, __pyx_v_rop1);
3994
3995
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":206
3996
* if mpz_sizeinbase(rop2, 2) < (sizeof(o[1])<<3):
3997
* mpz_export(&o[0], NULL, -1, sizeof(o[0]), -1, 0, rop1)
3998
* mpz_export(&o[1], NULL, -1, sizeof(o[1]), -1, 0, rop2) # <<<<<<<<<<<<<<
3999
* o[0] *= mpz_sgn(rop1)
4000
* o[1] *= mpz_sgn(rop2)
4001
*/
4002
mpz_export((&(__pyx_v_o[1])), NULL, -1, (sizeof((__pyx_v_o[1]))), -1, 0, __pyx_v_rop2);
4003
4004
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":207
4005
* mpz_export(&o[0], NULL, -1, sizeof(o[0]), -1, 0, rop1)
4006
* mpz_export(&o[1], NULL, -1, sizeof(o[1]), -1, 0, rop2)
4007
* o[0] *= mpz_sgn(rop1) # <<<<<<<<<<<<<<
4008
* o[1] *= mpz_sgn(rop2)
4009
* f_map64(o)
4010
*/
4011
__pyx_t_2 = 0;
4012
(__pyx_v_o[__pyx_t_2]) = ((__pyx_v_o[__pyx_t_2]) * mpz_sgn(__pyx_v_rop1));
4013
4014
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":208
4015
* mpz_export(&o[1], NULL, -1, sizeof(o[1]), -1, 0, rop2)
4016
* o[0] *= mpz_sgn(rop1)
4017
* o[1] *= mpz_sgn(rop2) # <<<<<<<<<<<<<<
4018
* f_map64(o)
4019
* mpz_set_si(rop1,o[0])
4020
*/
4021
__pyx_t_2 = 1;
4022
(__pyx_v_o[__pyx_t_2]) = ((__pyx_v_o[__pyx_t_2]) * mpz_sgn(__pyx_v_rop2));
4023
4024
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":209
4025
* o[0] *= mpz_sgn(rop1)
4026
* o[1] *= mpz_sgn(rop2)
4027
* f_map64(o) # <<<<<<<<<<<<<<
4028
* mpz_set_si(rop1,o[0])
4029
* mpz_set_si(rop2,o[1])
4030
*/
4031
__pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_map64(__pyx_v_o);
4032
4033
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":210
4034
* o[1] *= mpz_sgn(rop2)
4035
* f_map64(o)
4036
* mpz_set_si(rop1,o[0]) # <<<<<<<<<<<<<<
4037
* mpz_set_si(rop2,o[1])
4038
* mpz_set_si(rop3,o[2])
4039
*/
4040
mpz_set_si(__pyx_v_rop1, (__pyx_v_o[0]));
4041
4042
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":211
4043
* f_map64(o)
4044
* mpz_set_si(rop1,o[0])
4045
* mpz_set_si(rop2,o[1]) # <<<<<<<<<<<<<<
4046
* mpz_set_si(rop3,o[2])
4047
* mpz_set_si(rop4,o[3])
4048
*/
4049
mpz_set_si(__pyx_v_rop2, (__pyx_v_o[1]));
4050
4051
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":212
4052
* mpz_set_si(rop1,o[0])
4053
* mpz_set_si(rop2,o[1])
4054
* mpz_set_si(rop3,o[2]) # <<<<<<<<<<<<<<
4055
* mpz_set_si(rop4,o[3])
4056
* return
4057
*/
4058
mpz_set_si(__pyx_v_rop3, (__pyx_v_o[2]));
4059
4060
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":213
4061
* mpz_set_si(rop2,o[1])
4062
* mpz_set_si(rop3,o[2])
4063
* mpz_set_si(rop4,o[3]) # <<<<<<<<<<<<<<
4064
* return
4065
* mpz_set_si(rop3,1)
4066
*/
4067
mpz_set_si(__pyx_v_rop4, (__pyx_v_o[3]));
4068
4069
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":214
4070
* mpz_set_si(rop3,o[2])
4071
* mpz_set_si(rop4,o[3])
4072
* return # <<<<<<<<<<<<<<
4073
* mpz_set_si(rop3,1)
4074
* mpz_set_si(rop4,0)
4075
*/
4076
goto __pyx_L0;
4077
4078
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":204
4079
* mpz_set(rop2,op2)
4080
* if mpz_sizeinbase(rop1, 2) < (sizeof(o[0])<<3):
4081
* if mpz_sizeinbase(rop2, 2) < (sizeof(o[1])<<3): # <<<<<<<<<<<<<<
4082
* mpz_export(&o[0], NULL, -1, sizeof(o[0]), -1, 0, rop1)
4083
* mpz_export(&o[1], NULL, -1, sizeof(o[1]), -1, 0, rop2)
4084
*/
4085
}
4086
4087
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":203
4088
* return
4089
* mpz_set(rop2,op2)
4090
* if mpz_sizeinbase(rop1, 2) < (sizeof(o[0])<<3): # <<<<<<<<<<<<<<
4091
* if mpz_sizeinbase(rop2, 2) < (sizeof(o[1])<<3):
4092
* mpz_export(&o[0], NULL, -1, sizeof(o[0]), -1, 0, rop1)
4093
*/
4094
}
4095
4096
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":215
4097
* mpz_set_si(rop4,o[3])
4098
* return
4099
* mpz_set_si(rop3,1) # <<<<<<<<<<<<<<
4100
* mpz_set_si(rop4,0)
4101
* s = mpz_sgn(rop1) < 0
4102
*/
4103
mpz_set_si(__pyx_v_rop3, 1);
4104
4105
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":216
4106
* return
4107
* mpz_set_si(rop3,1)
4108
* mpz_set_si(rop4,0) # <<<<<<<<<<<<<<
4109
* s = mpz_sgn(rop1) < 0
4110
* # to simplify boolean checks
4111
*/
4112
mpz_set_si(__pyx_v_rop4, 0);
4113
4114
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":217
4115
* mpz_set_si(rop3,1)
4116
* mpz_set_si(rop4,0)
4117
* s = mpz_sgn(rop1) < 0 # <<<<<<<<<<<<<<
4118
* # to simplify boolean checks
4119
* if s:
4120
*/
4121
__pyx_v_s = (mpz_sgn(__pyx_v_rop1) < 0);
4122
4123
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":219
4124
* s = mpz_sgn(rop1) < 0
4125
* # to simplify boolean checks
4126
* if s: # <<<<<<<<<<<<<<
4127
* mpz_neg(rop1,rop1)
4128
* mpz_neg(rop2,rop2)
4129
*/
4130
__pyx_t_1 = (__pyx_v_s != 0);
4131
if (__pyx_t_1) {
4132
4133
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":220
4134
* # to simplify boolean checks
4135
* if s:
4136
* mpz_neg(rop1,rop1) # <<<<<<<<<<<<<<
4137
* mpz_neg(rop2,rop2)
4138
* mpz_init(f); mpz_init(g); mpz_init(t)
4139
*/
4140
mpz_neg(__pyx_v_rop1, __pyx_v_rop1);
4141
4142
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":221
4143
* if s:
4144
* mpz_neg(rop1,rop1)
4145
* mpz_neg(rop2,rop2) # <<<<<<<<<<<<<<
4146
* mpz_init(f); mpz_init(g); mpz_init(t)
4147
*
4148
*/
4149
mpz_neg(__pyx_v_rop2, __pyx_v_rop2);
4150
4151
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":219
4152
* s = mpz_sgn(rop1) < 0
4153
* # to simplify boolean checks
4154
* if s: # <<<<<<<<<<<<<<
4155
* mpz_neg(rop1,rop1)
4156
* mpz_neg(rop2,rop2)
4157
*/
4158
}
4159
4160
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":222
4161
* mpz_neg(rop1,rop1)
4162
* mpz_neg(rop2,rop2)
4163
* mpz_init(f); mpz_init(g); mpz_init(t) # <<<<<<<<<<<<<<
4164
*
4165
* # g = 36*rop1*rop1+180*rop2*rop2
4166
*/
4167
mpz_init(__pyx_v_f);
4168
mpz_init(__pyx_v_g);
4169
mpz_init(__pyx_v_t);
4170
4171
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":225
4172
*
4173
* # g = 36*rop1*rop1+180*rop2*rop2
4174
* mpz_mul(f,rop2,rop2) # <<<<<<<<<<<<<<
4175
* mpz_mul(g,rop1,rop1)
4176
* mpz_mul_si(g,g,36)
4177
*/
4178
mpz_mul(__pyx_v_f, __pyx_v_rop2, __pyx_v_rop2);
4179
4180
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":226
4181
* # g = 36*rop1*rop1+180*rop2*rop2
4182
* mpz_mul(f,rop2,rop2)
4183
* mpz_mul(g,rop1,rop1) # <<<<<<<<<<<<<<
4184
* mpz_mul_si(g,g,36)
4185
* mpz_addmul_ui(g,f,180)
4186
*/
4187
mpz_mul(__pyx_v_g, __pyx_v_rop1, __pyx_v_rop1);
4188
4189
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":227
4190
* mpz_mul(f,rop2,rop2)
4191
* mpz_mul(g,rop1,rop1)
4192
* mpz_mul_si(g,g,36) # <<<<<<<<<<<<<<
4193
* mpz_addmul_ui(g,f,180)
4194
*
4195
*/
4196
mpz_mul_si(__pyx_v_g, __pyx_v_g, 36);
4197
4198
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":228
4199
* mpz_mul(g,rop1,rop1)
4200
* mpz_mul_si(g,g,36)
4201
* mpz_addmul_ui(g,f,180) # <<<<<<<<<<<<<<
4202
*
4203
* mpz_mul(f,rop1,rop2)
4204
*/
4205
mpz_addmul_ui(__pyx_v_g, __pyx_v_f, 0xB4);
4206
4207
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":230
4208
* mpz_addmul_ui(g,f,180)
4209
*
4210
* mpz_mul(f,rop1,rop2) # <<<<<<<<<<<<<<
4211
* if mpz_sgn(rop2) > 0:
4212
* # g = 36*rop1*rop1-161*rop1*rop2+180*rop2*rop2
4213
*/
4214
mpz_mul(__pyx_v_f, __pyx_v_rop1, __pyx_v_rop2);
4215
4216
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":231
4217
*
4218
* mpz_mul(f,rop1,rop2)
4219
* if mpz_sgn(rop2) > 0: # <<<<<<<<<<<<<<
4220
* # g = 36*rop1*rop1-161*rop1*rop2+180*rop2*rop2
4221
* mpz_submul_ui(g,f,161)
4222
*/
4223
__pyx_t_1 = ((mpz_sgn(__pyx_v_rop2) > 0) != 0);
4224
if (__pyx_t_1) {
4225
4226
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":233
4227
* if mpz_sgn(rop2) > 0:
4228
* # g = 36*rop1*rop1-161*rop1*rop2+180*rop2*rop2
4229
* mpz_submul_ui(g,f,161) # <<<<<<<<<<<<<<
4230
* mpz_mul_si(f,f,2)
4231
* while mpz_sgn(g) < 0:
4232
*/
4233
mpz_submul_ui(__pyx_v_g, __pyx_v_f, 0xA1);
4234
4235
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":234
4236
* # g = 36*rop1*rop1-161*rop1*rop2+180*rop2*rop2
4237
* mpz_submul_ui(g,f,161)
4238
* mpz_mul_si(f,f,2) # <<<<<<<<<<<<<<
4239
* while mpz_sgn(g) < 0:
4240
* # rop1+rop2*g /= g^12
4241
*/
4242
mpz_mul_si(__pyx_v_f, __pyx_v_f, 2);
4243
4244
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":235
4245
* mpz_submul_ui(g,f,161)
4246
* mpz_mul_si(f,f,2)
4247
* while mpz_sgn(g) < 0: # <<<<<<<<<<<<<<
4248
* # rop1+rop2*g /= g^12
4249
* mpz_mul_si(t,rop1,161)
4250
*/
4251
while (1) {
4252
__pyx_t_1 = ((mpz_sgn(__pyx_v_g) < 0) != 0);
4253
if (!__pyx_t_1) break;
4254
4255
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":237
4256
* while mpz_sgn(g) < 0:
4257
* # rop1+rop2*g /= g^12
4258
* mpz_mul_si(t,rop1,161) # <<<<<<<<<<<<<<
4259
* mpz_submul_ui(t,rop2,360)
4260
* mpz_mul_si(rop2,rop2,161)
4261
*/
4262
mpz_mul_si(__pyx_v_t, __pyx_v_rop1, 0xA1);
4263
4264
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":238
4265
* # rop1+rop2*g /= g^12
4266
* mpz_mul_si(t,rop1,161)
4267
* mpz_submul_ui(t,rop2,360) # <<<<<<<<<<<<<<
4268
* mpz_mul_si(rop2,rop2,161)
4269
* mpz_submul_ui(rop2,rop1,72)
4270
*/
4271
mpz_submul_ui(__pyx_v_t, __pyx_v_rop2, 0x168);
4272
4273
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":239
4274
* mpz_mul_si(t,rop1,161)
4275
* mpz_submul_ui(t,rop2,360)
4276
* mpz_mul_si(rop2,rop2,161) # <<<<<<<<<<<<<<
4277
* mpz_submul_ui(rop2,rop1,72)
4278
* mpz_set(rop1,t)
4279
*/
4280
mpz_mul_si(__pyx_v_rop2, __pyx_v_rop2, 0xA1);
4281
4282
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":240
4283
* mpz_submul_ui(t,rop2,360)
4284
* mpz_mul_si(rop2,rop2,161)
4285
* mpz_submul_ui(rop2,rop1,72) # <<<<<<<<<<<<<<
4286
* mpz_set(rop1,t)
4287
*
4288
*/
4289
mpz_submul_ui(__pyx_v_rop2, __pyx_v_rop1, 72);
4290
4291
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":241
4292
* mpz_mul_si(rop2,rop2,161)
4293
* mpz_submul_ui(rop2,rop1,72)
4294
* mpz_set(rop1,t) # <<<<<<<<<<<<<<
4295
*
4296
* # fix f and g for new rop1+rop2*g
4297
*/
4298
mpz_set(__pyx_v_rop1, __pyx_v_t);
4299
4300
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":244
4301
*
4302
* # fix f and g for new rop1+rop2*g
4303
* mpz_addmul_ui(f,g,644) # <<<<<<<<<<<<<<
4304
* mpz_neg(f,f)
4305
* mpz_addmul_ui(g,f,161)
4306
*/
4307
mpz_addmul_ui(__pyx_v_f, __pyx_v_g, 0x284);
4308
4309
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":245
4310
* # fix f and g for new rop1+rop2*g
4311
* mpz_addmul_ui(f,g,644)
4312
* mpz_neg(f,f) # <<<<<<<<<<<<<<
4313
* mpz_addmul_ui(g,f,161)
4314
* mpz_neg(g,g)
4315
*/
4316
mpz_neg(__pyx_v_f, __pyx_v_f);
4317
4318
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":246
4319
* mpz_addmul_ui(f,g,644)
4320
* mpz_neg(f,f)
4321
* mpz_addmul_ui(g,f,161) # <<<<<<<<<<<<<<
4322
* mpz_neg(g,g)
4323
*
4324
*/
4325
mpz_addmul_ui(__pyx_v_g, __pyx_v_f, 0xA1);
4326
4327
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":247
4328
* mpz_neg(f,f)
4329
* mpz_addmul_ui(g,f,161)
4330
* mpz_neg(g,g) # <<<<<<<<<<<<<<
4331
*
4332
* # rop3+rop4*g *= g
4333
*/
4334
mpz_neg(__pyx_v_g, __pyx_v_g);
4335
4336
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":250
4337
*
4338
* # rop3+rop4*g *= g
4339
* mpz_add(rop4,rop3,rop4) # <<<<<<<<<<<<<<
4340
* mpz_sub(rop3,rop4,rop3)
4341
* elif mpz_sgn(rop2) < 0:
4342
*/
4343
mpz_add(__pyx_v_rop4, __pyx_v_rop3, __pyx_v_rop4);
4344
4345
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":251
4346
* # rop3+rop4*g *= g
4347
* mpz_add(rop4,rop3,rop4)
4348
* mpz_sub(rop3,rop4,rop3) # <<<<<<<<<<<<<<
4349
* elif mpz_sgn(rop2) < 0:
4350
* # g = 36*rop1*rop1+161*rop1*rop2+180*rop2*rop2
4351
*/
4352
mpz_sub(__pyx_v_rop3, __pyx_v_rop4, __pyx_v_rop3);
4353
}
4354
4355
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":231
4356
*
4357
* mpz_mul(f,rop1,rop2)
4358
* if mpz_sgn(rop2) > 0: # <<<<<<<<<<<<<<
4359
* # g = 36*rop1*rop1-161*rop1*rop2+180*rop2*rop2
4360
* mpz_submul_ui(g,f,161)
4361
*/
4362
goto __pyx_L7;
4363
}
4364
4365
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":252
4366
* mpz_add(rop4,rop3,rop4)
4367
* mpz_sub(rop3,rop4,rop3)
4368
* elif mpz_sgn(rop2) < 0: # <<<<<<<<<<<<<<
4369
* # g = 36*rop1*rop1+161*rop1*rop2+180*rop2*rop2
4370
* mpz_addmul_ui(g,f,161)
4371
*/
4372
__pyx_t_1 = ((mpz_sgn(__pyx_v_rop2) < 0) != 0);
4373
if (__pyx_t_1) {
4374
4375
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":254
4376
* elif mpz_sgn(rop2) < 0:
4377
* # g = 36*rop1*rop1+161*rop1*rop2+180*rop2*rop2
4378
* mpz_addmul_ui(g,f,161) # <<<<<<<<<<<<<<
4379
* mpz_mul_si(f,f,2)
4380
* while mpz_sgn(g) < 0:
4381
*/
4382
mpz_addmul_ui(__pyx_v_g, __pyx_v_f, 0xA1);
4383
4384
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":255
4385
* # g = 36*rop1*rop1+161*rop1*rop2+180*rop2*rop2
4386
* mpz_addmul_ui(g,f,161)
4387
* mpz_mul_si(f,f,2) # <<<<<<<<<<<<<<
4388
* while mpz_sgn(g) < 0:
4389
* # rop1+rop2*g *= g^12
4390
*/
4391
mpz_mul_si(__pyx_v_f, __pyx_v_f, 2);
4392
4393
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":256
4394
* mpz_addmul_ui(g,f,161)
4395
* mpz_mul_si(f,f,2)
4396
* while mpz_sgn(g) < 0: # <<<<<<<<<<<<<<
4397
* # rop1+rop2*g *= g^12
4398
* mpz_mul_si(t,rop1,161)
4399
*/
4400
while (1) {
4401
__pyx_t_1 = ((mpz_sgn(__pyx_v_g) < 0) != 0);
4402
if (!__pyx_t_1) break;
4403
4404
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":258
4405
* while mpz_sgn(g) < 0:
4406
* # rop1+rop2*g *= g^12
4407
* mpz_mul_si(t,rop1,161) # <<<<<<<<<<<<<<
4408
* mpz_addmul_ui(t,rop2,360)
4409
* mpz_mul_si(rop2,rop2,161)
4410
*/
4411
mpz_mul_si(__pyx_v_t, __pyx_v_rop1, 0xA1);
4412
4413
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":259
4414
* # rop1+rop2*g *= g^12
4415
* mpz_mul_si(t,rop1,161)
4416
* mpz_addmul_ui(t,rop2,360) # <<<<<<<<<<<<<<
4417
* mpz_mul_si(rop2,rop2,161)
4418
* mpz_addmul_ui(rop2,rop1,72)
4419
*/
4420
mpz_addmul_ui(__pyx_v_t, __pyx_v_rop2, 0x168);
4421
4422
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":260
4423
* mpz_mul_si(t,rop1,161)
4424
* mpz_addmul_ui(t,rop2,360)
4425
* mpz_mul_si(rop2,rop2,161) # <<<<<<<<<<<<<<
4426
* mpz_addmul_ui(rop2,rop1,72)
4427
* mpz_set(rop1,t)
4428
*/
4429
mpz_mul_si(__pyx_v_rop2, __pyx_v_rop2, 0xA1);
4430
4431
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":261
4432
* mpz_addmul_ui(t,rop2,360)
4433
* mpz_mul_si(rop2,rop2,161)
4434
* mpz_addmul_ui(rop2,rop1,72) # <<<<<<<<<<<<<<
4435
* mpz_set(rop1,t)
4436
*
4437
*/
4438
mpz_addmul_ui(__pyx_v_rop2, __pyx_v_rop1, 72);
4439
4440
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":262
4441
* mpz_mul_si(rop2,rop2,161)
4442
* mpz_addmul_ui(rop2,rop1,72)
4443
* mpz_set(rop1,t) # <<<<<<<<<<<<<<
4444
*
4445
* # fix f and g for new rop1+rop2*g
4446
*/
4447
mpz_set(__pyx_v_rop1, __pyx_v_t);
4448
4449
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":265
4450
*
4451
* # fix f and g for new rop1+rop2*g
4452
* mpz_submul_ui(f,g,644) # <<<<<<<<<<<<<<
4453
* mpz_neg(f,f)
4454
* mpz_submul_ui(g,f,161)
4455
*/
4456
mpz_submul_ui(__pyx_v_f, __pyx_v_g, 0x284);
4457
4458
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":266
4459
* # fix f and g for new rop1+rop2*g
4460
* mpz_submul_ui(f,g,644)
4461
* mpz_neg(f,f) # <<<<<<<<<<<<<<
4462
* mpz_submul_ui(g,f,161)
4463
* mpz_neg(g,g)
4464
*/
4465
mpz_neg(__pyx_v_f, __pyx_v_f);
4466
4467
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":267
4468
* mpz_submul_ui(f,g,644)
4469
* mpz_neg(f,f)
4470
* mpz_submul_ui(g,f,161) # <<<<<<<<<<<<<<
4471
* mpz_neg(g,g)
4472
*
4473
*/
4474
mpz_submul_ui(__pyx_v_g, __pyx_v_f, 0xA1);
4475
4476
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":268
4477
* mpz_neg(f,f)
4478
* mpz_submul_ui(g,f,161)
4479
* mpz_neg(g,g) # <<<<<<<<<<<<<<
4480
*
4481
* # rop3+rop4*g /= g
4482
*/
4483
mpz_neg(__pyx_v_g, __pyx_v_g);
4484
4485
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":271
4486
*
4487
* # rop3+rop4*g /= g
4488
* mpz_sub(rop3,rop4,rop3) # <<<<<<<<<<<<<<
4489
* mpz_sub(rop4,rop4,rop3)
4490
* # fix sign if needed
4491
*/
4492
mpz_sub(__pyx_v_rop3, __pyx_v_rop4, __pyx_v_rop3);
4493
4494
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":272
4495
* # rop3+rop4*g /= g
4496
* mpz_sub(rop3,rop4,rop3)
4497
* mpz_sub(rop4,rop4,rop3) # <<<<<<<<<<<<<<
4498
* # fix sign if needed
4499
* mpz_clear(f)
4500
*/
4501
mpz_sub(__pyx_v_rop4, __pyx_v_rop4, __pyx_v_rop3);
4502
}
4503
4504
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":252
4505
* mpz_add(rop4,rop3,rop4)
4506
* mpz_sub(rop3,rop4,rop3)
4507
* elif mpz_sgn(rop2) < 0: # <<<<<<<<<<<<<<
4508
* # g = 36*rop1*rop1+161*rop1*rop2+180*rop2*rop2
4509
* mpz_addmul_ui(g,f,161)
4510
*/
4511
}
4512
__pyx_L7:;
4513
4514
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":274
4515
* mpz_sub(rop4,rop4,rop3)
4516
* # fix sign if needed
4517
* mpz_clear(f) # <<<<<<<<<<<<<<
4518
* mpz_sub(rop1,rop1,rop2)
4519
* mpz_divexact_ui(rop1,rop1,2ul)
4520
*/
4521
mpz_clear(__pyx_v_f);
4522
4523
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":275
4524
* # fix sign if needed
4525
* mpz_clear(f)
4526
* mpz_sub(rop1,rop1,rop2) # <<<<<<<<<<<<<<
4527
* mpz_divexact_ui(rop1,rop1,2ul)
4528
* if not mpz_mod_ui(g, rop1, 13ul) and not mpz_mod_ui(t, rop2, 8ul):
4529
*/
4530
mpz_sub(__pyx_v_rop1, __pyx_v_rop1, __pyx_v_rop2);
4531
4532
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":276
4533
* mpz_clear(f)
4534
* mpz_sub(rop1,rop1,rop2)
4535
* mpz_divexact_ui(rop1,rop1,2ul) # <<<<<<<<<<<<<<
4536
* if not mpz_mod_ui(g, rop1, 13ul) and not mpz_mod_ui(t, rop2, 8ul):
4537
* mpz_divexact_ui(t, rop1, 13ul)
4538
*/
4539
mpz_divexact_ui(__pyx_v_rop1, __pyx_v_rop1, 2UL);
4540
4541
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":277
4542
* mpz_sub(rop1,rop1,rop2)
4543
* mpz_divexact_ui(rop1,rop1,2ul)
4544
* if not mpz_mod_ui(g, rop1, 13ul) and not mpz_mod_ui(t, rop2, 8ul): # <<<<<<<<<<<<<<
4545
* mpz_divexact_ui(t, rop1, 13ul)
4546
* mpz_divexact_ui(g, rop2, 11ul)
4547
*/
4548
__pyx_t_3 = ((!(mpz_mod_ui(__pyx_v_g, __pyx_v_rop1, 13UL) != 0)) != 0);
4549
if (__pyx_t_3) {
4550
} else {
4551
__pyx_t_1 = __pyx_t_3;
4552
goto __pyx_L13_bool_binop_done;
4553
}
4554
__pyx_t_3 = ((!(mpz_mod_ui(__pyx_v_t, __pyx_v_rop2, 8UL) != 0)) != 0);
4555
__pyx_t_1 = __pyx_t_3;
4556
__pyx_L13_bool_binop_done:;
4557
if (__pyx_t_1) {
4558
4559
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":278
4560
* mpz_divexact_ui(rop1,rop1,2ul)
4561
* if not mpz_mod_ui(g, rop1, 13ul) and not mpz_mod_ui(t, rop2, 8ul):
4562
* mpz_divexact_ui(t, rop1, 13ul) # <<<<<<<<<<<<<<
4563
* mpz_divexact_ui(g, rop2, 11ul)
4564
* mpz_neg(g,g)
4565
*/
4566
mpz_divexact_ui(__pyx_v_t, __pyx_v_rop1, 13UL);
4567
4568
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":279
4569
* if not mpz_mod_ui(g, rop1, 13ul) and not mpz_mod_ui(t, rop2, 8ul):
4570
* mpz_divexact_ui(t, rop1, 13ul)
4571
* mpz_divexact_ui(g, rop2, 11ul) # <<<<<<<<<<<<<<
4572
* mpz_neg(g,g)
4573
* if not mpz_cmp(t,g):
4574
*/
4575
mpz_divexact_ui(__pyx_v_g, __pyx_v_rop2, 11UL);
4576
4577
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":280
4578
* mpz_divexact_ui(t, rop1, 13ul)
4579
* mpz_divexact_ui(g, rop2, 11ul)
4580
* mpz_neg(g,g) # <<<<<<<<<<<<<<
4581
* if not mpz_cmp(t,g):
4582
* mpz_mul_ui(rop1, t, 5ul)
4583
*/
4584
mpz_neg(__pyx_v_g, __pyx_v_g);
4585
4586
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":281
4587
* mpz_divexact_ui(g, rop2, 11ul)
4588
* mpz_neg(g,g)
4589
* if not mpz_cmp(t,g): # <<<<<<<<<<<<<<
4590
* mpz_mul_ui(rop1, t, 5ul)
4591
* mpz_mul_ui(rop2, t, 8ul)
4592
*/
4593
__pyx_t_1 = ((!(mpz_cmp(__pyx_v_t, __pyx_v_g) != 0)) != 0);
4594
if (__pyx_t_1) {
4595
4596
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":282
4597
* mpz_neg(g,g)
4598
* if not mpz_cmp(t,g):
4599
* mpz_mul_ui(rop1, t, 5ul) # <<<<<<<<<<<<<<
4600
* mpz_mul_ui(rop2, t, 8ul)
4601
* mpz_sub(rop3,rop4,rop3)
4602
*/
4603
mpz_mul_ui(__pyx_v_rop1, __pyx_v_t, 5UL);
4604
4605
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":283
4606
* if not mpz_cmp(t,g):
4607
* mpz_mul_ui(rop1, t, 5ul)
4608
* mpz_mul_ui(rop2, t, 8ul) # <<<<<<<<<<<<<<
4609
* mpz_sub(rop3,rop4,rop3)
4610
* mpz_sub(rop4,rop4,rop3)
4611
*/
4612
mpz_mul_ui(__pyx_v_rop2, __pyx_v_t, 8UL);
4613
4614
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":284
4615
* mpz_mul_ui(rop1, t, 5ul)
4616
* mpz_mul_ui(rop2, t, 8ul)
4617
* mpz_sub(rop3,rop4,rop3) # <<<<<<<<<<<<<<
4618
* mpz_sub(rop4,rop4,rop3)
4619
* elif not mpz_mod_ui(g, rop1, 29ul) and not mpz_mod_ui(t, rop2, 18ul):
4620
*/
4621
mpz_sub(__pyx_v_rop3, __pyx_v_rop4, __pyx_v_rop3);
4622
4623
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":285
4624
* mpz_mul_ui(rop2, t, 8ul)
4625
* mpz_sub(rop3,rop4,rop3)
4626
* mpz_sub(rop4,rop4,rop3) # <<<<<<<<<<<<<<
4627
* elif not mpz_mod_ui(g, rop1, 29ul) and not mpz_mod_ui(t, rop2, 18ul):
4628
* mpz_divexact_ui(g, rop1, 29ul)
4629
*/
4630
mpz_sub(__pyx_v_rop4, __pyx_v_rop4, __pyx_v_rop3);
4631
4632
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":281
4633
* mpz_divexact_ui(g, rop2, 11ul)
4634
* mpz_neg(g,g)
4635
* if not mpz_cmp(t,g): # <<<<<<<<<<<<<<
4636
* mpz_mul_ui(rop1, t, 5ul)
4637
* mpz_mul_ui(rop2, t, 8ul)
4638
*/
4639
}
4640
4641
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":277
4642
* mpz_sub(rop1,rop1,rop2)
4643
* mpz_divexact_ui(rop1,rop1,2ul)
4644
* if not mpz_mod_ui(g, rop1, 13ul) and not mpz_mod_ui(t, rop2, 8ul): # <<<<<<<<<<<<<<
4645
* mpz_divexact_ui(t, rop1, 13ul)
4646
* mpz_divexact_ui(g, rop2, 11ul)
4647
*/
4648
goto __pyx_L12;
4649
}
4650
4651
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":286
4652
* mpz_sub(rop3,rop4,rop3)
4653
* mpz_sub(rop4,rop4,rop3)
4654
* elif not mpz_mod_ui(g, rop1, 29ul) and not mpz_mod_ui(t, rop2, 18ul): # <<<<<<<<<<<<<<
4655
* mpz_divexact_ui(g, rop1, 29ul)
4656
* mpz_divexact_ui(t, rop2, 18ul)
4657
*/
4658
__pyx_t_3 = ((!(mpz_mod_ui(__pyx_v_g, __pyx_v_rop1, 29UL) != 0)) != 0);
4659
if (__pyx_t_3) {
4660
} else {
4661
__pyx_t_1 = __pyx_t_3;
4662
goto __pyx_L16_bool_binop_done;
4663
}
4664
__pyx_t_3 = ((!(mpz_mod_ui(__pyx_v_t, __pyx_v_rop2, 18UL) != 0)) != 0);
4665
__pyx_t_1 = __pyx_t_3;
4666
__pyx_L16_bool_binop_done:;
4667
if (__pyx_t_1) {
4668
4669
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":287
4670
* mpz_sub(rop4,rop4,rop3)
4671
* elif not mpz_mod_ui(g, rop1, 29ul) and not mpz_mod_ui(t, rop2, 18ul):
4672
* mpz_divexact_ui(g, rop1, 29ul) # <<<<<<<<<<<<<<
4673
* mpz_divexact_ui(t, rop2, 18ul)
4674
* mpz_neg(t,t)
4675
*/
4676
mpz_divexact_ui(__pyx_v_g, __pyx_v_rop1, 29UL);
4677
4678
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":288
4679
* elif not mpz_mod_ui(g, rop1, 29ul) and not mpz_mod_ui(t, rop2, 18ul):
4680
* mpz_divexact_ui(g, rop1, 29ul)
4681
* mpz_divexact_ui(t, rop2, 18ul) # <<<<<<<<<<<<<<
4682
* mpz_neg(t,t)
4683
* if not mpz_cmp(t,g):
4684
*/
4685
mpz_divexact_ui(__pyx_v_t, __pyx_v_rop2, 18UL);
4686
4687
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":289
4688
* mpz_divexact_ui(g, rop1, 29ul)
4689
* mpz_divexact_ui(t, rop2, 18ul)
4690
* mpz_neg(t,t) # <<<<<<<<<<<<<<
4691
* if not mpz_cmp(t,g):
4692
* mpz_mul_ui(rop1, g, 11ul)
4693
*/
4694
mpz_neg(__pyx_v_t, __pyx_v_t);
4695
4696
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":290
4697
* mpz_divexact_ui(t, rop2, 18ul)
4698
* mpz_neg(t,t)
4699
* if not mpz_cmp(t,g): # <<<<<<<<<<<<<<
4700
* mpz_mul_ui(rop1, g, 11ul)
4701
* mpz_mul_ui(rop2, g, 18ul)
4702
*/
4703
__pyx_t_1 = ((!(mpz_cmp(__pyx_v_t, __pyx_v_g) != 0)) != 0);
4704
if (__pyx_t_1) {
4705
4706
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":291
4707
* mpz_neg(t,t)
4708
* if not mpz_cmp(t,g):
4709
* mpz_mul_ui(rop1, g, 11ul) # <<<<<<<<<<<<<<
4710
* mpz_mul_ui(rop2, g, 18ul)
4711
* mpz_sub(rop3,rop4,rop3)
4712
*/
4713
mpz_mul_ui(__pyx_v_rop1, __pyx_v_g, 11UL);
4714
4715
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":292
4716
* if not mpz_cmp(t,g):
4717
* mpz_mul_ui(rop1, g, 11ul)
4718
* mpz_mul_ui(rop2, g, 18ul) # <<<<<<<<<<<<<<
4719
* mpz_sub(rop3,rop4,rop3)
4720
* mpz_sub(rop4,rop4,rop3)
4721
*/
4722
mpz_mul_ui(__pyx_v_rop2, __pyx_v_g, 18UL);
4723
4724
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":293
4725
* mpz_mul_ui(rop1, g, 11ul)
4726
* mpz_mul_ui(rop2, g, 18ul)
4727
* mpz_sub(rop3,rop4,rop3) # <<<<<<<<<<<<<<
4728
* mpz_sub(rop4,rop4,rop3)
4729
* mpz_clear(g); mpz_clear(t)
4730
*/
4731
mpz_sub(__pyx_v_rop3, __pyx_v_rop4, __pyx_v_rop3);
4732
4733
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":294
4734
* mpz_mul_ui(rop2, g, 18ul)
4735
* mpz_sub(rop3,rop4,rop3)
4736
* mpz_sub(rop4,rop4,rop3) # <<<<<<<<<<<<<<
4737
* mpz_clear(g); mpz_clear(t)
4738
* if s:
4739
*/
4740
mpz_sub(__pyx_v_rop4, __pyx_v_rop4, __pyx_v_rop3);
4741
4742
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":290
4743
* mpz_divexact_ui(t, rop2, 18ul)
4744
* mpz_neg(t,t)
4745
* if not mpz_cmp(t,g): # <<<<<<<<<<<<<<
4746
* mpz_mul_ui(rop1, g, 11ul)
4747
* mpz_mul_ui(rop2, g, 18ul)
4748
*/
4749
}
4750
4751
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":286
4752
* mpz_sub(rop3,rop4,rop3)
4753
* mpz_sub(rop4,rop4,rop3)
4754
* elif not mpz_mod_ui(g, rop1, 29ul) and not mpz_mod_ui(t, rop2, 18ul): # <<<<<<<<<<<<<<
4755
* mpz_divexact_ui(g, rop1, 29ul)
4756
* mpz_divexact_ui(t, rop2, 18ul)
4757
*/
4758
}
4759
__pyx_L12:;
4760
4761
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":295
4762
* mpz_sub(rop3,rop4,rop3)
4763
* mpz_sub(rop4,rop4,rop3)
4764
* mpz_clear(g); mpz_clear(t) # <<<<<<<<<<<<<<
4765
* if s:
4766
* mpz_neg(rop1,rop1)
4767
*/
4768
mpz_clear(__pyx_v_g);
4769
mpz_clear(__pyx_v_t);
4770
4771
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":296
4772
* mpz_sub(rop4,rop4,rop3)
4773
* mpz_clear(g); mpz_clear(t)
4774
* if s: # <<<<<<<<<<<<<<
4775
* mpz_neg(rop1,rop1)
4776
* mpz_neg(rop2,rop2)
4777
*/
4778
__pyx_t_1 = (__pyx_v_s != 0);
4779
if (__pyx_t_1) {
4780
4781
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":297
4782
* mpz_clear(g); mpz_clear(t)
4783
* if s:
4784
* mpz_neg(rop1,rop1) # <<<<<<<<<<<<<<
4785
* mpz_neg(rop2,rop2)
4786
*
4787
*/
4788
mpz_neg(__pyx_v_rop1, __pyx_v_rop1);
4789
4790
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":298
4791
* if s:
4792
* mpz_neg(rop1,rop1)
4793
* mpz_neg(rop2,rop2) # <<<<<<<<<<<<<<
4794
*
4795
* cpdef f_map(Integer a, Integer b):
4796
*/
4797
mpz_neg(__pyx_v_rop2, __pyx_v_rop2);
4798
4799
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":296
4800
* mpz_sub(rop4,rop4,rop3)
4801
* mpz_clear(g); mpz_clear(t)
4802
* if s: # <<<<<<<<<<<<<<
4803
* mpz_neg(rop1,rop1)
4804
* mpz_neg(rop2,rop2)
4805
*/
4806
}
4807
4808
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":176
4809
* o[1] *= 1-2*s
4810
*
4811
* cdef void f_mapC(mpz_t rop1, mpz_t rop2, mpz_t rop3, mpz_t rop4, mpz_t op1, mpz_t op2): # <<<<<<<<<<<<<<
4812
* """
4813
* Let `G` be the function
4814
*/
4815
4816
/* function exit code */
4817
__pyx_L0:;
4818
__Pyx_RefNannyFinishContext();
4819
}
4820
4821
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":300
4822
* mpz_neg(rop2,rop2)
4823
*
4824
* cpdef f_map(Integer a, Integer b): # <<<<<<<<<<<<<<
4825
* """
4826
* Computes 'cannonical' representitives for the equivalence relation
4827
*/
4828
4829
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_1f_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4830
static PyObject *__pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_map(struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_a, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_b, CYTHON_UNUSED int __pyx_skip_dispatch) {
4831
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_c = 0;
4832
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_d = 0;
4833
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_e = 0;
4834
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_f = 0;
4835
PyObject *__pyx_r = NULL;
4836
__Pyx_RefNannyDeclarations
4837
PyObject *__pyx_t_1 = NULL;
4838
PyObject *__pyx_t_2 = NULL;
4839
__Pyx_RefNannySetupContext("f_map", 0);
4840
4841
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":338
4842
* """
4843
* cdef Integer c,d,e,f
4844
* c = <Integer>PY_NEW(Integer) # <<<<<<<<<<<<<<
4845
* d = <Integer>PY_NEW(Integer)
4846
* e = <Integer>PY_NEW(Integer)
4847
*/
4848
__pyx_t_1 = __pyx_f_4sage_3ext_7stdsage_PY_NEW(__pyx_ptype_4sage_5rings_7integer_Integer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error)
4849
__Pyx_GOTREF(__pyx_t_1);
4850
__pyx_t_2 = __pyx_t_1;
4851
__Pyx_INCREF(__pyx_t_2);
4852
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4853
__pyx_v_c = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)__pyx_t_2);
4854
__pyx_t_2 = 0;
4855
4856
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":339
4857
* cdef Integer c,d,e,f
4858
* c = <Integer>PY_NEW(Integer)
4859
* d = <Integer>PY_NEW(Integer) # <<<<<<<<<<<<<<
4860
* e = <Integer>PY_NEW(Integer)
4861
* f = <Integer>PY_NEW(Integer)
4862
*/
4863
__pyx_t_2 = __pyx_f_4sage_3ext_7stdsage_PY_NEW(__pyx_ptype_4sage_5rings_7integer_Integer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 339, __pyx_L1_error)
4864
__Pyx_GOTREF(__pyx_t_2);
4865
__pyx_t_1 = __pyx_t_2;
4866
__Pyx_INCREF(__pyx_t_1);
4867
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4868
__pyx_v_d = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)__pyx_t_1);
4869
__pyx_t_1 = 0;
4870
4871
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":340
4872
* c = <Integer>PY_NEW(Integer)
4873
* d = <Integer>PY_NEW(Integer)
4874
* e = <Integer>PY_NEW(Integer) # <<<<<<<<<<<<<<
4875
* f = <Integer>PY_NEW(Integer)
4876
* f_mapC(c.value, d.value, e.value, f.value, a.value, b.value)
4877
*/
4878
__pyx_t_1 = __pyx_f_4sage_3ext_7stdsage_PY_NEW(__pyx_ptype_4sage_5rings_7integer_Integer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error)
4879
__Pyx_GOTREF(__pyx_t_1);
4880
__pyx_t_2 = __pyx_t_1;
4881
__Pyx_INCREF(__pyx_t_2);
4882
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4883
__pyx_v_e = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)__pyx_t_2);
4884
__pyx_t_2 = 0;
4885
4886
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":341
4887
* d = <Integer>PY_NEW(Integer)
4888
* e = <Integer>PY_NEW(Integer)
4889
* f = <Integer>PY_NEW(Integer) # <<<<<<<<<<<<<<
4890
* f_mapC(c.value, d.value, e.value, f.value, a.value, b.value)
4891
* return c,d,e,f
4892
*/
4893
__pyx_t_2 = __pyx_f_4sage_3ext_7stdsage_PY_NEW(__pyx_ptype_4sage_5rings_7integer_Integer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 341, __pyx_L1_error)
4894
__Pyx_GOTREF(__pyx_t_2);
4895
__pyx_t_1 = __pyx_t_2;
4896
__Pyx_INCREF(__pyx_t_1);
4897
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4898
__pyx_v_f = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)__pyx_t_1);
4899
__pyx_t_1 = 0;
4900
4901
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":342
4902
* e = <Integer>PY_NEW(Integer)
4903
* f = <Integer>PY_NEW(Integer)
4904
* f_mapC(c.value, d.value, e.value, f.value, a.value, b.value) # <<<<<<<<<<<<<<
4905
* return c,d,e,f
4906
*
4907
*/
4908
__pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_mapC(__pyx_v_c->value, __pyx_v_d->value, __pyx_v_e->value, __pyx_v_f->value, __pyx_v_a->value, __pyx_v_b->value);
4909
4910
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":343
4911
* f = <Integer>PY_NEW(Integer)
4912
* f_mapC(c.value, d.value, e.value, f.value, a.value, b.value)
4913
* return c,d,e,f # <<<<<<<<<<<<<<
4914
*
4915
* def canonical_model(E):
4916
*/
4917
__Pyx_XDECREF(__pyx_r);
4918
__pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
4919
__Pyx_GOTREF(__pyx_t_1);
4920
__Pyx_INCREF(((PyObject *)__pyx_v_c));
4921
__Pyx_GIVEREF(((PyObject *)__pyx_v_c));
4922
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_c));
4923
__Pyx_INCREF(((PyObject *)__pyx_v_d));
4924
__Pyx_GIVEREF(((PyObject *)__pyx_v_d));
4925
PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_d));
4926
__Pyx_INCREF(((PyObject *)__pyx_v_e));
4927
__Pyx_GIVEREF(((PyObject *)__pyx_v_e));
4928
PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_e));
4929
__Pyx_INCREF(((PyObject *)__pyx_v_f));
4930
__Pyx_GIVEREF(((PyObject *)__pyx_v_f));
4931
PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_f));
4932
__pyx_r = __pyx_t_1;
4933
__pyx_t_1 = 0;
4934
goto __pyx_L0;
4935
4936
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":300
4937
* mpz_neg(rop2,rop2)
4938
*
4939
* cpdef f_map(Integer a, Integer b): # <<<<<<<<<<<<<<
4940
* """
4941
* Computes 'cannonical' representitives for the equivalence relation
4942
*/
4943
4944
/* function exit code */
4945
__pyx_L1_error:;
4946
__Pyx_XDECREF(__pyx_t_1);
4947
__Pyx_XDECREF(__pyx_t_2);
4948
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.minmodel.sqrt5.f_map", __pyx_clineno, __pyx_lineno, __pyx_filename);
4949
__pyx_r = 0;
4950
__pyx_L0:;
4951
__Pyx_XDECREF((PyObject *)__pyx_v_c);
4952
__Pyx_XDECREF((PyObject *)__pyx_v_d);
4953
__Pyx_XDECREF((PyObject *)__pyx_v_e);
4954
__Pyx_XDECREF((PyObject *)__pyx_v_f);
4955
__Pyx_XGIVEREF(__pyx_r);
4956
__Pyx_RefNannyFinishContext();
4957
return __pyx_r;
4958
}
4959
4960
/* Python wrapper */
4961
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_1f_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4962
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_map[] = "File: sqrt5.pyx (starting at line 300)\n\n Computes 'cannonical' representitives for the equivalence relation\n `\\lambda / \\mu \\in U_F^{12},`\n on the ring of integers for `F=Q(\\sqrt{5})`.\n \n INPUT:\n \n - ``a+b*\\gamma`` -- an element of the ring of integers of `F`\n \n OUTPUT:\n \n A 'cannonical' element `\\delta*u^{-12}` of the maximal order of `F` and\n the unit `u`\n \n EXAMPLES::\n\n sage: from psage.ellcurve.minmodel.sqrt5 import f_map\n sage: K.<a> = NumberField(x^2-x-1)\n sage: E = EllipticCurve(K,[a,a+1,a+2,a+3,a+4])\n sage: olddelta = E.discriminant()\n sage: olddeltapair = (Integer(olddelta[0]),Integer(olddelta[1]))\n sage: temp = f_map(olddeltapair[0],olddeltapair[1])\n sage: temp[0] == olddeltapair[0] and temp[1] == olddeltapair[1]\n True\n sage: F = E.change_weierstrass_model([a^5,0,0,0])\n sage: delta = F.discriminant()\n sage: deltapair = (Integer(delta[0]),Integer(delta[1]))\n sage: temp = f_map(deltapair[0],deltapair[1])\n sage: temp[0] == deltapair[0] and temp[1] == deltapair[1]\n False\n sage: temp[0] == olddeltapair[0] and temp[1] == olddeltapair[1]\n True\n sage: F.change_weierstrass_model([temp[2]+a*temp[3],0,0,0]) == E\n True\n \n ";
4963
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_1f_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4964
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_a = 0;
4965
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_b = 0;
4966
PyObject *__pyx_r = 0;
4967
__Pyx_RefNannyDeclarations
4968
__Pyx_RefNannySetupContext("f_map (wrapper)", 0);
4969
{
4970
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_b,0};
4971
PyObject* values[2] = {0,0};
4972
if (unlikely(__pyx_kwds)) {
4973
Py_ssize_t kw_args;
4974
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4975
switch (pos_args) {
4976
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4977
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4978
case 0: break;
4979
default: goto __pyx_L5_argtuple_error;
4980
}
4981
kw_args = PyDict_Size(__pyx_kwds);
4982
switch (pos_args) {
4983
case 0:
4984
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
4985
else goto __pyx_L5_argtuple_error;
4986
case 1:
4987
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
4988
else {
4989
__Pyx_RaiseArgtupleInvalid("f_map", 1, 2, 2, 1); __PYX_ERR(0, 300, __pyx_L3_error)
4990
}
4991
}
4992
if (unlikely(kw_args > 0)) {
4993
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f_map") < 0)) __PYX_ERR(0, 300, __pyx_L3_error)
4994
}
4995
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
4996
goto __pyx_L5_argtuple_error;
4997
} else {
4998
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4999
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5000
}
5001
__pyx_v_a = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)values[0]);
5002
__pyx_v_b = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)values[1]);
5003
}
5004
goto __pyx_L4_argument_unpacking_done;
5005
__pyx_L5_argtuple_error:;
5006
__Pyx_RaiseArgtupleInvalid("f_map", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 300, __pyx_L3_error)
5007
__pyx_L3_error:;
5008
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.minmodel.sqrt5.f_map", __pyx_clineno, __pyx_lineno, __pyx_filename);
5009
__Pyx_RefNannyFinishContext();
5010
return NULL;
5011
__pyx_L4_argument_unpacking_done:;
5012
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4sage_5rings_7integer_Integer, 1, "a", 0))) __PYX_ERR(0, 300, __pyx_L1_error)
5013
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4sage_5rings_7integer_Integer, 1, "b", 0))) __PYX_ERR(0, 300, __pyx_L1_error)
5014
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_map(__pyx_self, __pyx_v_a, __pyx_v_b);
5015
5016
/* function exit code */
5017
goto __pyx_L0;
5018
__pyx_L1_error:;
5019
__pyx_r = NULL;
5020
__pyx_L0:;
5021
__Pyx_RefNannyFinishContext();
5022
return __pyx_r;
5023
}
5024
5025
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_map(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_a, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_b) {
5026
PyObject *__pyx_r = NULL;
5027
__Pyx_RefNannyDeclarations
5028
PyObject *__pyx_t_1 = NULL;
5029
__Pyx_RefNannySetupContext("f_map", 0);
5030
__Pyx_XDECREF(__pyx_r);
5031
__pyx_t_1 = __pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_map(__pyx_v_a, __pyx_v_b, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
5032
__Pyx_GOTREF(__pyx_t_1);
5033
__pyx_r = __pyx_t_1;
5034
__pyx_t_1 = 0;
5035
goto __pyx_L0;
5036
5037
/* function exit code */
5038
__pyx_L1_error:;
5039
__Pyx_XDECREF(__pyx_t_1);
5040
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.minmodel.sqrt5.f_map", __pyx_clineno, __pyx_lineno, __pyx_filename);
5041
__pyx_r = NULL;
5042
__pyx_L0:;
5043
__Pyx_XGIVEREF(__pyx_r);
5044
__Pyx_RefNannyFinishContext();
5045
return __pyx_r;
5046
}
5047
5048
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":345
5049
* return c,d,e,f
5050
*
5051
* def canonical_model(E): # <<<<<<<<<<<<<<
5052
* """
5053
* Given a global minimal model E over Q(sqrt5) returns a canonical global
5054
*/
5055
5056
/* Python wrapper */
5057
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_3canonical_model(PyObject *__pyx_self, PyObject *__pyx_v_E); /*proto*/
5058
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_2canonical_model[] = "File: sqrt5.pyx (starting at line 345)\n\n Given a global minimal model E over Q(sqrt5) returns a canonical global\n minimal model.\n\n EXAMPLES::\n\n sage: from psage.ellcurve.minmodel.sqrt5 import canonical_model\n sage: K.<a> = NumberField(x**2-x-1)\n sage: E = EllipticCurve(K,[a,a-1,a,-1,-a+1])\n sage: F = canonical_model(E)\n sage: E == F\n False\n sage: E.is_isomorphic(F)\n True\n sage: F == canonical_model(F)\n True\n ";
5059
static PyMethodDef __pyx_mdef_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_3canonical_model = {"canonical_model", (PyCFunction)__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_3canonical_model, METH_O, __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_2canonical_model};
5060
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_3canonical_model(PyObject *__pyx_self, PyObject *__pyx_v_E) {
5061
PyObject *__pyx_r = 0;
5062
__Pyx_RefNannyDeclarations
5063
__Pyx_RefNannySetupContext("canonical_model (wrapper)", 0);
5064
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_2canonical_model(__pyx_self, ((PyObject *)__pyx_v_E));
5065
5066
/* function exit code */
5067
__Pyx_RefNannyFinishContext();
5068
return __pyx_r;
5069
}
5070
5071
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_2canonical_model(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_E) {
5072
PyObject *__pyx_v_K = NULL;
5073
PyObject *__pyx_v_D1 = NULL;
5074
PyObject *__pyx_v_D2 = NULL;
5075
PyObject *__pyx_v_a1 = NULL;
5076
PyObject *__pyx_v_a2 = NULL;
5077
PyObject *__pyx_v_a3 = NULL;
5078
PyObject *__pyx_v_a4 = NULL;
5079
PyObject *__pyx_v_a6 = NULL;
5080
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_u1 = 0;
5081
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_u2 = 0;
5082
mpz_t __pyx_v_t1;
5083
mpz_t __pyx_v_t2;
5084
PyObject *__pyx_v_u = NULL;
5085
PyObject *__pyx_v_P2 = NULL;
5086
PyObject *__pyx_v_P3 = NULL;
5087
PyObject *__pyx_v_a1p = NULL;
5088
PyObject *__pyx_v_s = NULL;
5089
PyObject *__pyx_v_sa1 = NULL;
5090
PyObject *__pyx_v_a2p = NULL;
5091
PyObject *__pyx_v_r = NULL;
5092
PyObject *__pyx_v_ra1p = NULL;
5093
PyObject *__pyx_v_a3p = NULL;
5094
PyObject *__pyx_v_t = NULL;
5095
PyObject *__pyx_v_a4p = NULL;
5096
PyObject *__pyx_v_a6p = NULL;
5097
PyObject *__pyx_r = NULL;
5098
__Pyx_RefNannyDeclarations
5099
PyObject *__pyx_t_1 = NULL;
5100
PyObject *__pyx_t_2 = NULL;
5101
PyObject *__pyx_t_3 = NULL;
5102
PyObject *__pyx_t_4 = NULL;
5103
PyObject *__pyx_t_5 = NULL;
5104
PyObject *__pyx_t_6 = NULL;
5105
int __pyx_t_7;
5106
PyObject *__pyx_t_8 = NULL;
5107
PyObject *(*__pyx_t_9)(PyObject *);
5108
PyObject *__pyx_t_10 = NULL;
5109
PyObject *__pyx_t_11 = NULL;
5110
PyObject *__pyx_t_12 = NULL;
5111
int __pyx_t_13;
5112
__Pyx_RefNannySetupContext("canonical_model", 0);
5113
5114
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":363
5115
* True
5116
* """
5117
* try: # <<<<<<<<<<<<<<
5118
* K = E.base_field()
5119
* if K.disc() != 5:
5120
*/
5121
{
5122
__Pyx_PyThreadState_declare
5123
__Pyx_PyThreadState_assign
5124
__Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
5125
__Pyx_XGOTREF(__pyx_t_1);
5126
__Pyx_XGOTREF(__pyx_t_2);
5127
__Pyx_XGOTREF(__pyx_t_3);
5128
/*try:*/ {
5129
5130
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":364
5131
* """
5132
* try:
5133
* K = E.base_field() # <<<<<<<<<<<<<<
5134
* if K.disc() != 5:
5135
* raise TypeError, "E must be over Q(sqrt(5))"
5136
*/
5137
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_E, __pyx_n_s_base_field); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 364, __pyx_L3_error)
5138
__Pyx_GOTREF(__pyx_t_5);
5139
__pyx_t_6 = NULL;
5140
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
5141
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
5142
if (likely(__pyx_t_6)) {
5143
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
5144
__Pyx_INCREF(__pyx_t_6);
5145
__Pyx_INCREF(function);
5146
__Pyx_DECREF_SET(__pyx_t_5, function);
5147
}
5148
}
5149
if (__pyx_t_6) {
5150
__pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 364, __pyx_L3_error)
5151
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5152
} else {
5153
__pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 364, __pyx_L3_error)
5154
}
5155
__Pyx_GOTREF(__pyx_t_4);
5156
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5157
__pyx_v_K = __pyx_t_4;
5158
__pyx_t_4 = 0;
5159
5160
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":365
5161
* try:
5162
* K = E.base_field()
5163
* if K.disc() != 5: # <<<<<<<<<<<<<<
5164
* raise TypeError, "E must be over Q(sqrt(5))"
5165
* D1, D2 = E.discriminant()
5166
*/
5167
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_K, __pyx_n_s_disc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L3_error)
5168
__Pyx_GOTREF(__pyx_t_5);
5169
__pyx_t_6 = NULL;
5170
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
5171
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
5172
if (likely(__pyx_t_6)) {
5173
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
5174
__Pyx_INCREF(__pyx_t_6);
5175
__Pyx_INCREF(function);
5176
__Pyx_DECREF_SET(__pyx_t_5, function);
5177
}
5178
}
5179
if (__pyx_t_6) {
5180
__pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 365, __pyx_L3_error)
5181
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5182
} else {
5183
__pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 365, __pyx_L3_error)
5184
}
5185
__Pyx_GOTREF(__pyx_t_4);
5186
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5187
__pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_int_5, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L3_error)
5188
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5189
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 365, __pyx_L3_error)
5190
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5191
if (__pyx_t_7) {
5192
5193
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":366
5194
* K = E.base_field()
5195
* if K.disc() != 5:
5196
* raise TypeError, "E must be over Q(sqrt(5))" # <<<<<<<<<<<<<<
5197
* D1, D2 = E.discriminant()
5198
* a1,a2,a3,a4,a6 = E.a_invariants()
5199
*/
5200
__Pyx_Raise(__pyx_builtin_TypeError, __pyx_kp_s_E_must_be_over_Q_sqrt_5, 0, 0);
5201
__PYX_ERR(0, 366, __pyx_L3_error)
5202
5203
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":365
5204
* try:
5205
* K = E.base_field()
5206
* if K.disc() != 5: # <<<<<<<<<<<<<<
5207
* raise TypeError, "E must be over Q(sqrt(5))"
5208
* D1, D2 = E.discriminant()
5209
*/
5210
}
5211
5212
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":367
5213
* if K.disc() != 5:
5214
* raise TypeError, "E must be over Q(sqrt(5))"
5215
* D1, D2 = E.discriminant() # <<<<<<<<<<<<<<
5216
* a1,a2,a3,a4,a6 = E.a_invariants()
5217
* except AttributeError:
5218
*/
5219
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_E, __pyx_n_s_discriminant); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 367, __pyx_L3_error)
5220
__Pyx_GOTREF(__pyx_t_4);
5221
__pyx_t_6 = NULL;
5222
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
5223
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
5224
if (likely(__pyx_t_6)) {
5225
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
5226
__Pyx_INCREF(__pyx_t_6);
5227
__Pyx_INCREF(function);
5228
__Pyx_DECREF_SET(__pyx_t_4, function);
5229
}
5230
}
5231
if (__pyx_t_6) {
5232
__pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 367, __pyx_L3_error)
5233
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5234
} else {
5235
__pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 367, __pyx_L3_error)
5236
}
5237
__Pyx_GOTREF(__pyx_t_5);
5238
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5239
if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
5240
PyObject* sequence = __pyx_t_5;
5241
#if !CYTHON_COMPILING_IN_PYPY
5242
Py_ssize_t size = Py_SIZE(sequence);
5243
#else
5244
Py_ssize_t size = PySequence_Size(sequence);
5245
#endif
5246
if (unlikely(size != 2)) {
5247
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
5248
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
5249
__PYX_ERR(0, 367, __pyx_L3_error)
5250
}
5251
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5252
if (likely(PyTuple_CheckExact(sequence))) {
5253
__pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
5254
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
5255
} else {
5256
__pyx_t_4 = PyList_GET_ITEM(sequence, 0);
5257
__pyx_t_6 = PyList_GET_ITEM(sequence, 1);
5258
}
5259
__Pyx_INCREF(__pyx_t_4);
5260
__Pyx_INCREF(__pyx_t_6);
5261
#else
5262
__pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 367, __pyx_L3_error)
5263
__Pyx_GOTREF(__pyx_t_4);
5264
__pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L3_error)
5265
__Pyx_GOTREF(__pyx_t_6);
5266
#endif
5267
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5268
} else {
5269
Py_ssize_t index = -1;
5270
__pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 367, __pyx_L3_error)
5271
__Pyx_GOTREF(__pyx_t_8);
5272
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5273
__pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
5274
index = 0; __pyx_t_4 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L12_unpacking_failed;
5275
__Pyx_GOTREF(__pyx_t_4);
5276
index = 1; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L12_unpacking_failed;
5277
__Pyx_GOTREF(__pyx_t_6);
5278
if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(0, 367, __pyx_L3_error)
5279
__pyx_t_9 = NULL;
5280
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5281
goto __pyx_L13_unpacking_done;
5282
__pyx_L12_unpacking_failed:;
5283
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5284
__pyx_t_9 = NULL;
5285
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
5286
__PYX_ERR(0, 367, __pyx_L3_error)
5287
__pyx_L13_unpacking_done:;
5288
}
5289
__pyx_v_D1 = __pyx_t_4;
5290
__pyx_t_4 = 0;
5291
__pyx_v_D2 = __pyx_t_6;
5292
__pyx_t_6 = 0;
5293
5294
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":368
5295
* raise TypeError, "E must be over Q(sqrt(5))"
5296
* D1, D2 = E.discriminant()
5297
* a1,a2,a3,a4,a6 = E.a_invariants() # <<<<<<<<<<<<<<
5298
* except AttributeError:
5299
* raise TypeError, "E must be an elliptic curve"
5300
*/
5301
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_E, __pyx_n_s_a_invariants); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 368, __pyx_L3_error)
5302
__Pyx_GOTREF(__pyx_t_6);
5303
__pyx_t_4 = NULL;
5304
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
5305
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
5306
if (likely(__pyx_t_4)) {
5307
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
5308
__Pyx_INCREF(__pyx_t_4);
5309
__Pyx_INCREF(function);
5310
__Pyx_DECREF_SET(__pyx_t_6, function);
5311
}
5312
}
5313
if (__pyx_t_4) {
5314
__pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 368, __pyx_L3_error)
5315
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5316
} else {
5317
__pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 368, __pyx_L3_error)
5318
}
5319
__Pyx_GOTREF(__pyx_t_5);
5320
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5321
if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
5322
PyObject* sequence = __pyx_t_5;
5323
#if !CYTHON_COMPILING_IN_PYPY
5324
Py_ssize_t size = Py_SIZE(sequence);
5325
#else
5326
Py_ssize_t size = PySequence_Size(sequence);
5327
#endif
5328
if (unlikely(size != 5)) {
5329
if (size > 5) __Pyx_RaiseTooManyValuesError(5);
5330
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
5331
__PYX_ERR(0, 368, __pyx_L3_error)
5332
}
5333
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5334
if (likely(PyTuple_CheckExact(sequence))) {
5335
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
5336
__pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
5337
__pyx_t_8 = PyTuple_GET_ITEM(sequence, 2);
5338
__pyx_t_10 = PyTuple_GET_ITEM(sequence, 3);
5339
__pyx_t_11 = PyTuple_GET_ITEM(sequence, 4);
5340
} else {
5341
__pyx_t_6 = PyList_GET_ITEM(sequence, 0);
5342
__pyx_t_4 = PyList_GET_ITEM(sequence, 1);
5343
__pyx_t_8 = PyList_GET_ITEM(sequence, 2);
5344
__pyx_t_10 = PyList_GET_ITEM(sequence, 3);
5345
__pyx_t_11 = PyList_GET_ITEM(sequence, 4);
5346
}
5347
__Pyx_INCREF(__pyx_t_6);
5348
__Pyx_INCREF(__pyx_t_4);
5349
__Pyx_INCREF(__pyx_t_8);
5350
__Pyx_INCREF(__pyx_t_10);
5351
__Pyx_INCREF(__pyx_t_11);
5352
#else
5353
{
5354
Py_ssize_t i;
5355
PyObject** temps[5] = {&__pyx_t_6,&__pyx_t_4,&__pyx_t_8,&__pyx_t_10,&__pyx_t_11};
5356
for (i=0; i < 5; i++) {
5357
PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 368, __pyx_L3_error)
5358
__Pyx_GOTREF(item);
5359
*(temps[i]) = item;
5360
}
5361
}
5362
#endif
5363
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5364
} else {
5365
Py_ssize_t index = -1;
5366
PyObject** temps[5] = {&__pyx_t_6,&__pyx_t_4,&__pyx_t_8,&__pyx_t_10,&__pyx_t_11};
5367
__pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 368, __pyx_L3_error)
5368
__Pyx_GOTREF(__pyx_t_12);
5369
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5370
__pyx_t_9 = Py_TYPE(__pyx_t_12)->tp_iternext;
5371
for (index=0; index < 5; index++) {
5372
PyObject* item = __pyx_t_9(__pyx_t_12); if (unlikely(!item)) goto __pyx_L14_unpacking_failed;
5373
__Pyx_GOTREF(item);
5374
*(temps[index]) = item;
5375
}
5376
if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_12), 5) < 0) __PYX_ERR(0, 368, __pyx_L3_error)
5377
__pyx_t_9 = NULL;
5378
__Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
5379
goto __pyx_L15_unpacking_done;
5380
__pyx_L14_unpacking_failed:;
5381
__Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
5382
__pyx_t_9 = NULL;
5383
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
5384
__PYX_ERR(0, 368, __pyx_L3_error)
5385
__pyx_L15_unpacking_done:;
5386
}
5387
__pyx_v_a1 = __pyx_t_6;
5388
__pyx_t_6 = 0;
5389
__pyx_v_a2 = __pyx_t_4;
5390
__pyx_t_4 = 0;
5391
__pyx_v_a3 = __pyx_t_8;
5392
__pyx_t_8 = 0;
5393
__pyx_v_a4 = __pyx_t_10;
5394
__pyx_t_10 = 0;
5395
__pyx_v_a6 = __pyx_t_11;
5396
__pyx_t_11 = 0;
5397
5398
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":363
5399
* True
5400
* """
5401
* try: # <<<<<<<<<<<<<<
5402
* K = E.base_field()
5403
* if K.disc() != 5:
5404
*/
5405
}
5406
__Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
5407
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5408
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5409
goto __pyx_L10_try_end;
5410
__pyx_L3_error:;
5411
__Pyx_PyThreadState_assign
5412
__Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
5413
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
5414
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5415
__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
5416
__Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
5417
__Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
5418
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5419
5420
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":369
5421
* D1, D2 = E.discriminant()
5422
* a1,a2,a3,a4,a6 = E.a_invariants()
5423
* except AttributeError: # <<<<<<<<<<<<<<
5424
* raise TypeError, "E must be an elliptic curve"
5425
* cdef Integer u1, u2
5426
*/
5427
__pyx_t_13 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
5428
if (__pyx_t_13) {
5429
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.minmodel.sqrt5.canonical_model", __pyx_clineno, __pyx_lineno, __pyx_filename);
5430
if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_11, &__pyx_t_10) < 0) __PYX_ERR(0, 369, __pyx_L5_except_error)
5431
__Pyx_GOTREF(__pyx_t_5);
5432
__Pyx_GOTREF(__pyx_t_11);
5433
__Pyx_GOTREF(__pyx_t_10);
5434
5435
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":370
5436
* a1,a2,a3,a4,a6 = E.a_invariants()
5437
* except AttributeError:
5438
* raise TypeError, "E must be an elliptic curve" # <<<<<<<<<<<<<<
5439
* cdef Integer u1, u2
5440
* u1 = Integer(D1)
5441
*/
5442
__Pyx_Raise(__pyx_builtin_TypeError, __pyx_kp_s_E_must_be_an_elliptic_curve, 0, 0);
5443
__PYX_ERR(0, 370, __pyx_L5_except_error)
5444
}
5445
goto __pyx_L5_except_error;
5446
__pyx_L5_except_error:;
5447
5448
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":363
5449
* True
5450
* """
5451
* try: # <<<<<<<<<<<<<<
5452
* K = E.base_field()
5453
* if K.disc() != 5:
5454
*/
5455
__Pyx_PyThreadState_assign
5456
__Pyx_XGIVEREF(__pyx_t_1);
5457
__Pyx_XGIVEREF(__pyx_t_2);
5458
__Pyx_XGIVEREF(__pyx_t_3);
5459
__Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
5460
goto __pyx_L1_error;
5461
__pyx_L10_try_end:;
5462
}
5463
5464
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":372
5465
* raise TypeError, "E must be an elliptic curve"
5466
* cdef Integer u1, u2
5467
* u1 = Integer(D1) # <<<<<<<<<<<<<<
5468
* u2 = Integer(D2)
5469
* cdef mpz_t t1,t2
5470
*/
5471
__pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 372, __pyx_L1_error)
5472
__Pyx_GOTREF(__pyx_t_10);
5473
__Pyx_INCREF(__pyx_v_D1);
5474
__Pyx_GIVEREF(__pyx_v_D1);
5475
PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_D1);
5476
__pyx_t_11 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4sage_5rings_7integer_Integer), __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 372, __pyx_L1_error)
5477
__Pyx_GOTREF(__pyx_t_11);
5478
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5479
__pyx_v_u1 = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)__pyx_t_11);
5480
__pyx_t_11 = 0;
5481
5482
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":373
5483
* cdef Integer u1, u2
5484
* u1 = Integer(D1)
5485
* u2 = Integer(D2) # <<<<<<<<<<<<<<
5486
* cdef mpz_t t1,t2
5487
* mpz_init(t1); mpz_init(t2)
5488
*/
5489
__pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 373, __pyx_L1_error)
5490
__Pyx_GOTREF(__pyx_t_11);
5491
__Pyx_INCREF(__pyx_v_D2);
5492
__Pyx_GIVEREF(__pyx_v_D2);
5493
PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_D2);
5494
__pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4sage_5rings_7integer_Integer), __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 373, __pyx_L1_error)
5495
__Pyx_GOTREF(__pyx_t_10);
5496
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
5497
__pyx_v_u2 = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)__pyx_t_10);
5498
__pyx_t_10 = 0;
5499
5500
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":375
5501
* u2 = Integer(D2)
5502
* cdef mpz_t t1,t2
5503
* mpz_init(t1); mpz_init(t2) # <<<<<<<<<<<<<<
5504
* f_mapC(t1, u1.value, t2, u2.value, u1.value, u2.value)
5505
* mpz_add(u1.value, t2, u2.value)
5506
*/
5507
mpz_init(__pyx_v_t1);
5508
mpz_init(__pyx_v_t2);
5509
5510
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":376
5511
* cdef mpz_t t1,t2
5512
* mpz_init(t1); mpz_init(t2)
5513
* f_mapC(t1, u1.value, t2, u2.value, u1.value, u2.value) # <<<<<<<<<<<<<<
5514
* mpz_add(u1.value, t2, u2.value)
5515
* mpz_mul(t1, u1.value, t2)
5516
*/
5517
__pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_mapC(__pyx_v_t1, __pyx_v_u1->value, __pyx_v_t2, __pyx_v_u2->value, __pyx_v_u1->value, __pyx_v_u2->value);
5518
5519
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":377
5520
* mpz_init(t1); mpz_init(t2)
5521
* f_mapC(t1, u1.value, t2, u2.value, u1.value, u2.value)
5522
* mpz_add(u1.value, t2, u2.value) # <<<<<<<<<<<<<<
5523
* mpz_mul(t1, u1.value, t2)
5524
* mpz_submul(t1, u2.value, u2.value)
5525
*/
5526
mpz_add(__pyx_v_u1->value, __pyx_v_t2, __pyx_v_u2->value);
5527
5528
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":378
5529
* f_mapC(t1, u1.value, t2, u2.value, u1.value, u2.value)
5530
* mpz_add(u1.value, t2, u2.value)
5531
* mpz_mul(t1, u1.value, t2) # <<<<<<<<<<<<<<
5532
* mpz_submul(t1, u2.value, u2.value)
5533
* if mpz_sgn(t1) > 0:
5534
*/
5535
mpz_mul(__pyx_v_t1, __pyx_v_u1->value, __pyx_v_t2);
5536
5537
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":379
5538
* mpz_add(u1.value, t2, u2.value)
5539
* mpz_mul(t1, u1.value, t2)
5540
* mpz_submul(t1, u2.value, u2.value) # <<<<<<<<<<<<<<
5541
* if mpz_sgn(t1) > 0:
5542
* mpz_neg(u2.value, u2.value)
5543
*/
5544
mpz_submul(__pyx_v_t1, __pyx_v_u2->value, __pyx_v_u2->value);
5545
5546
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":380
5547
* mpz_mul(t1, u1.value, t2)
5548
* mpz_submul(t1, u2.value, u2.value)
5549
* if mpz_sgn(t1) > 0: # <<<<<<<<<<<<<<
5550
* mpz_neg(u2.value, u2.value)
5551
* else:
5552
*/
5553
__pyx_t_7 = ((mpz_sgn(__pyx_v_t1) > 0) != 0);
5554
if (__pyx_t_7) {
5555
5556
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":381
5557
* mpz_submul(t1, u2.value, u2.value)
5558
* if mpz_sgn(t1) > 0:
5559
* mpz_neg(u2.value, u2.value) # <<<<<<<<<<<<<<
5560
* else:
5561
* mpz_neg(u1.value, u1.value)
5562
*/
5563
mpz_neg(__pyx_v_u2->value, __pyx_v_u2->value);
5564
5565
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":380
5566
* mpz_mul(t1, u1.value, t2)
5567
* mpz_submul(t1, u2.value, u2.value)
5568
* if mpz_sgn(t1) > 0: # <<<<<<<<<<<<<<
5569
* mpz_neg(u2.value, u2.value)
5570
* else:
5571
*/
5572
goto __pyx_L18;
5573
}
5574
5575
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":383
5576
* mpz_neg(u2.value, u2.value)
5577
* else:
5578
* mpz_neg(u1.value, u1.value) # <<<<<<<<<<<<<<
5579
* mpz_clear(t1); mpz_clear(t2)
5580
* u = K(u1)+K.gen(0)*K(u2)
5581
*/
5582
/*else*/ {
5583
mpz_neg(__pyx_v_u1->value, __pyx_v_u1->value);
5584
}
5585
__pyx_L18:;
5586
5587
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":384
5588
* else:
5589
* mpz_neg(u1.value, u1.value)
5590
* mpz_clear(t1); mpz_clear(t2) # <<<<<<<<<<<<<<
5591
* u = K(u1)+K.gen(0)*K(u2)
5592
* a1,a2,a3,a4,a6 = u*a1,u*u*a2,u*u*u*a3,a4*u**4,a6*u**6
5593
*/
5594
mpz_clear(__pyx_v_t1);
5595
mpz_clear(__pyx_v_t2);
5596
5597
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":385
5598
* mpz_neg(u1.value, u1.value)
5599
* mpz_clear(t1); mpz_clear(t2)
5600
* u = K(u1)+K.gen(0)*K(u2) # <<<<<<<<<<<<<<
5601
* a1,a2,a3,a4,a6 = u*a1,u*u*a2,u*u*u*a3,a4*u**4,a6*u**6
5602
* P2 = K.ideal(2)
5603
*/
5604
__Pyx_INCREF(__pyx_v_K);
5605
__pyx_t_11 = __pyx_v_K; __pyx_t_5 = NULL;
5606
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
5607
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_11);
5608
if (likely(__pyx_t_5)) {
5609
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
5610
__Pyx_INCREF(__pyx_t_5);
5611
__Pyx_INCREF(function);
5612
__Pyx_DECREF_SET(__pyx_t_11, function);
5613
}
5614
}
5615
if (!__pyx_t_5) {
5616
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_11, ((PyObject *)__pyx_v_u1)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 385, __pyx_L1_error)
5617
__Pyx_GOTREF(__pyx_t_10);
5618
} else {
5619
#if CYTHON_FAST_PYCALL
5620
if (PyFunction_Check(__pyx_t_11)) {
5621
PyObject *__pyx_temp[2] = {__pyx_t_5, ((PyObject *)__pyx_v_u1)};
5622
__pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 385, __pyx_L1_error)
5623
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5624
__Pyx_GOTREF(__pyx_t_10);
5625
} else
5626
#endif
5627
#if CYTHON_FAST_PYCCALL
5628
if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
5629
PyObject *__pyx_temp[2] = {__pyx_t_5, ((PyObject *)__pyx_v_u1)};
5630
__pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 385, __pyx_L1_error)
5631
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5632
__Pyx_GOTREF(__pyx_t_10);
5633
} else
5634
#endif
5635
{
5636
__pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 385, __pyx_L1_error)
5637
__Pyx_GOTREF(__pyx_t_8);
5638
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
5639
__Pyx_INCREF(((PyObject *)__pyx_v_u1));
5640
__Pyx_GIVEREF(((PyObject *)__pyx_v_u1));
5641
PyTuple_SET_ITEM(__pyx_t_8, 0+1, ((PyObject *)__pyx_v_u1));
5642
__pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_8, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 385, __pyx_L1_error)
5643
__Pyx_GOTREF(__pyx_t_10);
5644
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5645
}
5646
}
5647
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
5648
__pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_K, __pyx_n_s_gen); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 385, __pyx_L1_error)
5649
__Pyx_GOTREF(__pyx_t_11);
5650
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 385, __pyx_L1_error)
5651
__Pyx_GOTREF(__pyx_t_8);
5652
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
5653
__Pyx_INCREF(__pyx_v_K);
5654
__pyx_t_5 = __pyx_v_K; __pyx_t_4 = NULL;
5655
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
5656
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
5657
if (likely(__pyx_t_4)) {
5658
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
5659
__Pyx_INCREF(__pyx_t_4);
5660
__Pyx_INCREF(function);
5661
__Pyx_DECREF_SET(__pyx_t_5, function);
5662
}
5663
}
5664
if (!__pyx_t_4) {
5665
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_u2)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 385, __pyx_L1_error)
5666
__Pyx_GOTREF(__pyx_t_11);
5667
} else {
5668
#if CYTHON_FAST_PYCALL
5669
if (PyFunction_Check(__pyx_t_5)) {
5670
PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_u2)};
5671
__pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 385, __pyx_L1_error)
5672
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5673
__Pyx_GOTREF(__pyx_t_11);
5674
} else
5675
#endif
5676
#if CYTHON_FAST_PYCCALL
5677
if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
5678
PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_u2)};
5679
__pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 385, __pyx_L1_error)
5680
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5681
__Pyx_GOTREF(__pyx_t_11);
5682
} else
5683
#endif
5684
{
5685
__pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 385, __pyx_L1_error)
5686
__Pyx_GOTREF(__pyx_t_6);
5687
__Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
5688
__Pyx_INCREF(((PyObject *)__pyx_v_u2));
5689
__Pyx_GIVEREF(((PyObject *)__pyx_v_u2));
5690
PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)__pyx_v_u2));
5691
__pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 385, __pyx_L1_error)
5692
__Pyx_GOTREF(__pyx_t_11);
5693
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5694
}
5695
}
5696
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5697
__pyx_t_5 = PyNumber_Multiply(__pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 385, __pyx_L1_error)
5698
__Pyx_GOTREF(__pyx_t_5);
5699
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5700
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
5701
__pyx_t_11 = PyNumber_Add(__pyx_t_10, __pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 385, __pyx_L1_error)
5702
__Pyx_GOTREF(__pyx_t_11);
5703
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5704
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5705
__pyx_v_u = __pyx_t_11;
5706
__pyx_t_11 = 0;
5707
5708
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":386
5709
* mpz_clear(t1); mpz_clear(t2)
5710
* u = K(u1)+K.gen(0)*K(u2)
5711
* a1,a2,a3,a4,a6 = u*a1,u*u*a2,u*u*u*a3,a4*u**4,a6*u**6 # <<<<<<<<<<<<<<
5712
* P2 = K.ideal(2)
5713
* P3 = K.ideal(3)
5714
*/
5715
__pyx_t_11 = PyNumber_Multiply(__pyx_v_u, __pyx_v_a1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 386, __pyx_L1_error)
5716
__Pyx_GOTREF(__pyx_t_11);
5717
__pyx_t_5 = PyNumber_Multiply(__pyx_v_u, __pyx_v_u); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 386, __pyx_L1_error)
5718
__Pyx_GOTREF(__pyx_t_5);
5719
__pyx_t_10 = PyNumber_Multiply(__pyx_t_5, __pyx_v_a2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 386, __pyx_L1_error)
5720
__Pyx_GOTREF(__pyx_t_10);
5721
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5722
__pyx_t_5 = PyNumber_Multiply(__pyx_v_u, __pyx_v_u); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 386, __pyx_L1_error)
5723
__Pyx_GOTREF(__pyx_t_5);
5724
__pyx_t_8 = PyNumber_Multiply(__pyx_t_5, __pyx_v_u); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 386, __pyx_L1_error)
5725
__Pyx_GOTREF(__pyx_t_8);
5726
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5727
__pyx_t_5 = PyNumber_Multiply(__pyx_t_8, __pyx_v_a3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 386, __pyx_L1_error)
5728
__Pyx_GOTREF(__pyx_t_5);
5729
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5730
__pyx_t_8 = PyNumber_Power(__pyx_v_u, __pyx_int_4, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 386, __pyx_L1_error)
5731
__Pyx_GOTREF(__pyx_t_8);
5732
__pyx_t_6 = PyNumber_Multiply(__pyx_v_a4, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 386, __pyx_L1_error)
5733
__Pyx_GOTREF(__pyx_t_6);
5734
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5735
__pyx_t_8 = PyNumber_Power(__pyx_v_u, __pyx_int_6, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 386, __pyx_L1_error)
5736
__Pyx_GOTREF(__pyx_t_8);
5737
__pyx_t_4 = PyNumber_Multiply(__pyx_v_a6, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 386, __pyx_L1_error)
5738
__Pyx_GOTREF(__pyx_t_4);
5739
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5740
__Pyx_DECREF_SET(__pyx_v_a1, __pyx_t_11);
5741
__pyx_t_11 = 0;
5742
__Pyx_DECREF_SET(__pyx_v_a2, __pyx_t_10);
5743
__pyx_t_10 = 0;
5744
__Pyx_DECREF_SET(__pyx_v_a3, __pyx_t_5);
5745
__pyx_t_5 = 0;
5746
__Pyx_DECREF_SET(__pyx_v_a4, __pyx_t_6);
5747
__pyx_t_6 = 0;
5748
__Pyx_DECREF_SET(__pyx_v_a6, __pyx_t_4);
5749
__pyx_t_4 = 0;
5750
5751
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":387
5752
* u = K(u1)+K.gen(0)*K(u2)
5753
* a1,a2,a3,a4,a6 = u*a1,u*u*a2,u*u*u*a3,a4*u**4,a6*u**6
5754
* P2 = K.ideal(2) # <<<<<<<<<<<<<<
5755
* P3 = K.ideal(3)
5756
* a1p = a1.mod(P2)
5757
*/
5758
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_K, __pyx_n_s_ideal); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 387, __pyx_L1_error)
5759
__Pyx_GOTREF(__pyx_t_4);
5760
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 387, __pyx_L1_error)
5761
__Pyx_GOTREF(__pyx_t_6);
5762
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5763
__pyx_v_P2 = __pyx_t_6;
5764
__pyx_t_6 = 0;
5765
5766
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":388
5767
* a1,a2,a3,a4,a6 = u*a1,u*u*a2,u*u*u*a3,a4*u**4,a6*u**6
5768
* P2 = K.ideal(2)
5769
* P3 = K.ideal(3) # <<<<<<<<<<<<<<
5770
* a1p = a1.mod(P2)
5771
* s = (a1p - a1)/K(2)
5772
*/
5773
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_K, __pyx_n_s_ideal); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 388, __pyx_L1_error)
5774
__Pyx_GOTREF(__pyx_t_6);
5775
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 388, __pyx_L1_error)
5776
__Pyx_GOTREF(__pyx_t_4);
5777
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5778
__pyx_v_P3 = __pyx_t_4;
5779
__pyx_t_4 = 0;
5780
5781
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":389
5782
* P2 = K.ideal(2)
5783
* P3 = K.ideal(3)
5784
* a1p = a1.mod(P2) # <<<<<<<<<<<<<<
5785
* s = (a1p - a1)/K(2)
5786
* sa1 = s*a1
5787
*/
5788
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_a1, __pyx_n_s_mod); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 389, __pyx_L1_error)
5789
__Pyx_GOTREF(__pyx_t_6);
5790
__pyx_t_5 = NULL;
5791
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
5792
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
5793
if (likely(__pyx_t_5)) {
5794
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
5795
__Pyx_INCREF(__pyx_t_5);
5796
__Pyx_INCREF(function);
5797
__Pyx_DECREF_SET(__pyx_t_6, function);
5798
}
5799
}
5800
if (!__pyx_t_5) {
5801
__pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_P2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L1_error)
5802
__Pyx_GOTREF(__pyx_t_4);
5803
} else {
5804
#if CYTHON_FAST_PYCALL
5805
if (PyFunction_Check(__pyx_t_6)) {
5806
PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_P2};
5807
__pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L1_error)
5808
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5809
__Pyx_GOTREF(__pyx_t_4);
5810
} else
5811
#endif
5812
#if CYTHON_FAST_PYCCALL
5813
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
5814
PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_P2};
5815
__pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L1_error)
5816
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5817
__Pyx_GOTREF(__pyx_t_4);
5818
} else
5819
#endif
5820
{
5821
__pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 389, __pyx_L1_error)
5822
__Pyx_GOTREF(__pyx_t_10);
5823
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
5824
__Pyx_INCREF(__pyx_v_P2);
5825
__Pyx_GIVEREF(__pyx_v_P2);
5826
PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_P2);
5827
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L1_error)
5828
__Pyx_GOTREF(__pyx_t_4);
5829
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5830
}
5831
}
5832
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5833
__pyx_v_a1p = __pyx_t_4;
5834
__pyx_t_4 = 0;
5835
5836
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":390
5837
* P3 = K.ideal(3)
5838
* a1p = a1.mod(P2)
5839
* s = (a1p - a1)/K(2) # <<<<<<<<<<<<<<
5840
* sa1 = s*a1
5841
* a2p = (a2 - sa1 - s**2).mod(P3)
5842
*/
5843
__pyx_t_4 = PyNumber_Subtract(__pyx_v_a1p, __pyx_v_a1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 390, __pyx_L1_error)
5844
__Pyx_GOTREF(__pyx_t_4);
5845
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_v_K, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 390, __pyx_L1_error)
5846
__Pyx_GOTREF(__pyx_t_6);
5847
__pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 390, __pyx_L1_error)
5848
__Pyx_GOTREF(__pyx_t_10);
5849
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5850
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5851
__pyx_v_s = __pyx_t_10;
5852
__pyx_t_10 = 0;
5853
5854
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":391
5855
* a1p = a1.mod(P2)
5856
* s = (a1p - a1)/K(2)
5857
* sa1 = s*a1 # <<<<<<<<<<<<<<
5858
* a2p = (a2 - sa1 - s**2).mod(P3)
5859
* r = (a2p - a2 + sa1 + s**2)/K(3)
5860
*/
5861
__pyx_t_10 = PyNumber_Multiply(__pyx_v_s, __pyx_v_a1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 391, __pyx_L1_error)
5862
__Pyx_GOTREF(__pyx_t_10);
5863
__pyx_v_sa1 = __pyx_t_10;
5864
__pyx_t_10 = 0;
5865
5866
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":392
5867
* s = (a1p - a1)/K(2)
5868
* sa1 = s*a1
5869
* a2p = (a2 - sa1 - s**2).mod(P3) # <<<<<<<<<<<<<<
5870
* r = (a2p - a2 + sa1 + s**2)/K(3)
5871
* ra1p = r*a1p
5872
*/
5873
__pyx_t_6 = PyNumber_Subtract(__pyx_v_a2, __pyx_v_sa1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 392, __pyx_L1_error)
5874
__Pyx_GOTREF(__pyx_t_6);
5875
__pyx_t_4 = PyNumber_Power(__pyx_v_s, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 392, __pyx_L1_error)
5876
__Pyx_GOTREF(__pyx_t_4);
5877
__pyx_t_5 = PyNumber_Subtract(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 392, __pyx_L1_error)
5878
__Pyx_GOTREF(__pyx_t_5);
5879
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5880
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5881
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_mod); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 392, __pyx_L1_error)
5882
__Pyx_GOTREF(__pyx_t_4);
5883
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5884
__pyx_t_5 = NULL;
5885
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
5886
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
5887
if (likely(__pyx_t_5)) {
5888
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
5889
__Pyx_INCREF(__pyx_t_5);
5890
__Pyx_INCREF(function);
5891
__Pyx_DECREF_SET(__pyx_t_4, function);
5892
}
5893
}
5894
if (!__pyx_t_5) {
5895
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_P3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 392, __pyx_L1_error)
5896
__Pyx_GOTREF(__pyx_t_10);
5897
} else {
5898
#if CYTHON_FAST_PYCALL
5899
if (PyFunction_Check(__pyx_t_4)) {
5900
PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_P3};
5901
__pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 392, __pyx_L1_error)
5902
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5903
__Pyx_GOTREF(__pyx_t_10);
5904
} else
5905
#endif
5906
#if CYTHON_FAST_PYCCALL
5907
if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
5908
PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_P3};
5909
__pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 392, __pyx_L1_error)
5910
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5911
__Pyx_GOTREF(__pyx_t_10);
5912
} else
5913
#endif
5914
{
5915
__pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 392, __pyx_L1_error)
5916
__Pyx_GOTREF(__pyx_t_6);
5917
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
5918
__Pyx_INCREF(__pyx_v_P3);
5919
__Pyx_GIVEREF(__pyx_v_P3);
5920
PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_P3);
5921
__pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 392, __pyx_L1_error)
5922
__Pyx_GOTREF(__pyx_t_10);
5923
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5924
}
5925
}
5926
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5927
__pyx_v_a2p = __pyx_t_10;
5928
__pyx_t_10 = 0;
5929
5930
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":393
5931
* sa1 = s*a1
5932
* a2p = (a2 - sa1 - s**2).mod(P3)
5933
* r = (a2p - a2 + sa1 + s**2)/K(3) # <<<<<<<<<<<<<<
5934
* ra1p = r*a1p
5935
* a3p = (a3+ra1p).mod(P2)
5936
*/
5937
__pyx_t_10 = PyNumber_Subtract(__pyx_v_a2p, __pyx_v_a2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 393, __pyx_L1_error)
5938
__Pyx_GOTREF(__pyx_t_10);
5939
__pyx_t_4 = PyNumber_Add(__pyx_t_10, __pyx_v_sa1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 393, __pyx_L1_error)
5940
__Pyx_GOTREF(__pyx_t_4);
5941
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5942
__pyx_t_10 = PyNumber_Power(__pyx_v_s, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 393, __pyx_L1_error)
5943
__Pyx_GOTREF(__pyx_t_10);
5944
__pyx_t_6 = PyNumber_Add(__pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 393, __pyx_L1_error)
5945
__Pyx_GOTREF(__pyx_t_6);
5946
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5947
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5948
__pyx_t_10 = __Pyx_PyObject_Call(__pyx_v_K, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 393, __pyx_L1_error)
5949
__Pyx_GOTREF(__pyx_t_10);
5950
__pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 393, __pyx_L1_error)
5951
__Pyx_GOTREF(__pyx_t_4);
5952
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5953
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5954
__pyx_v_r = __pyx_t_4;
5955
__pyx_t_4 = 0;
5956
5957
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":394
5958
* a2p = (a2 - sa1 - s**2).mod(P3)
5959
* r = (a2p - a2 + sa1 + s**2)/K(3)
5960
* ra1p = r*a1p # <<<<<<<<<<<<<<
5961
* a3p = (a3+ra1p).mod(P2)
5962
* t = r*s + (a3p - a3 - ra1p)/K(2)
5963
*/
5964
__pyx_t_4 = PyNumber_Multiply(__pyx_v_r, __pyx_v_a1p); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 394, __pyx_L1_error)
5965
__Pyx_GOTREF(__pyx_t_4);
5966
__pyx_v_ra1p = __pyx_t_4;
5967
__pyx_t_4 = 0;
5968
5969
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":395
5970
* r = (a2p - a2 + sa1 + s**2)/K(3)
5971
* ra1p = r*a1p
5972
* a3p = (a3+ra1p).mod(P2) # <<<<<<<<<<<<<<
5973
* t = r*s + (a3p - a3 - ra1p)/K(2)
5974
* a4p = a4 - s*a3 + 2*r*a2 - (t+r*s)*a1 + 3*r**2 - 2*s*t
5975
*/
5976
__pyx_t_10 = PyNumber_Add(__pyx_v_a3, __pyx_v_ra1p); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 395, __pyx_L1_error)
5977
__Pyx_GOTREF(__pyx_t_10);
5978
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_mod); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 395, __pyx_L1_error)
5979
__Pyx_GOTREF(__pyx_t_6);
5980
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5981
__pyx_t_10 = NULL;
5982
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
5983
__pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
5984
if (likely(__pyx_t_10)) {
5985
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
5986
__Pyx_INCREF(__pyx_t_10);
5987
__Pyx_INCREF(function);
5988
__Pyx_DECREF_SET(__pyx_t_6, function);
5989
}
5990
}
5991
if (!__pyx_t_10) {
5992
__pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_P2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 395, __pyx_L1_error)
5993
__Pyx_GOTREF(__pyx_t_4);
5994
} else {
5995
#if CYTHON_FAST_PYCALL
5996
if (PyFunction_Check(__pyx_t_6)) {
5997
PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_P2};
5998
__pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 395, __pyx_L1_error)
5999
__Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
6000
__Pyx_GOTREF(__pyx_t_4);
6001
} else
6002
#endif
6003
#if CYTHON_FAST_PYCCALL
6004
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
6005
PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_P2};
6006
__pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 395, __pyx_L1_error)
6007
__Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
6008
__Pyx_GOTREF(__pyx_t_4);
6009
} else
6010
#endif
6011
{
6012
__pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 395, __pyx_L1_error)
6013
__Pyx_GOTREF(__pyx_t_5);
6014
__Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10); __pyx_t_10 = NULL;
6015
__Pyx_INCREF(__pyx_v_P2);
6016
__Pyx_GIVEREF(__pyx_v_P2);
6017
PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_P2);
6018
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 395, __pyx_L1_error)
6019
__Pyx_GOTREF(__pyx_t_4);
6020
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6021
}
6022
}
6023
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6024
__pyx_v_a3p = __pyx_t_4;
6025
__pyx_t_4 = 0;
6026
6027
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":396
6028
* ra1p = r*a1p
6029
* a3p = (a3+ra1p).mod(P2)
6030
* t = r*s + (a3p - a3 - ra1p)/K(2) # <<<<<<<<<<<<<<
6031
* a4p = a4 - s*a3 + 2*r*a2 - (t+r*s)*a1 + 3*r**2 - 2*s*t
6032
* a6p = a6 + r*a4 + r**2*a2 + r**3 - t*a3 - t**2 - r*t*a1
6033
*/
6034
__pyx_t_4 = PyNumber_Multiply(__pyx_v_r, __pyx_v_s); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 396, __pyx_L1_error)
6035
__Pyx_GOTREF(__pyx_t_4);
6036
__pyx_t_6 = PyNumber_Subtract(__pyx_v_a3p, __pyx_v_a3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 396, __pyx_L1_error)
6037
__Pyx_GOTREF(__pyx_t_6);
6038
__pyx_t_5 = PyNumber_Subtract(__pyx_t_6, __pyx_v_ra1p); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 396, __pyx_L1_error)
6039
__Pyx_GOTREF(__pyx_t_5);
6040
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6041
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_v_K, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 396, __pyx_L1_error)
6042
__Pyx_GOTREF(__pyx_t_6);
6043
__pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 396, __pyx_L1_error)
6044
__Pyx_GOTREF(__pyx_t_10);
6045
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6046
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6047
__pyx_t_6 = PyNumber_Add(__pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 396, __pyx_L1_error)
6048
__Pyx_GOTREF(__pyx_t_6);
6049
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6050
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6051
__pyx_v_t = __pyx_t_6;
6052
__pyx_t_6 = 0;
6053
6054
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":397
6055
* a3p = (a3+ra1p).mod(P2)
6056
* t = r*s + (a3p - a3 - ra1p)/K(2)
6057
* a4p = a4 - s*a3 + 2*r*a2 - (t+r*s)*a1 + 3*r**2 - 2*s*t # <<<<<<<<<<<<<<
6058
* a6p = a6 + r*a4 + r**2*a2 + r**3 - t*a3 - t**2 - r*t*a1
6059
* return EllipticCurve(K, [a1p, a2p, a3p, a4p, a6p])
6060
*/
6061
__pyx_t_6 = PyNumber_Multiply(__pyx_v_s, __pyx_v_a3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 397, __pyx_L1_error)
6062
__Pyx_GOTREF(__pyx_t_6);
6063
__pyx_t_10 = PyNumber_Subtract(__pyx_v_a4, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 397, __pyx_L1_error)
6064
__Pyx_GOTREF(__pyx_t_10);
6065
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6066
__pyx_t_6 = PyNumber_Multiply(__pyx_int_2, __pyx_v_r); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 397, __pyx_L1_error)
6067
__Pyx_GOTREF(__pyx_t_6);
6068
__pyx_t_4 = PyNumber_Multiply(__pyx_t_6, __pyx_v_a2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 397, __pyx_L1_error)
6069
__Pyx_GOTREF(__pyx_t_4);
6070
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6071
__pyx_t_6 = PyNumber_Add(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 397, __pyx_L1_error)
6072
__Pyx_GOTREF(__pyx_t_6);
6073
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6074
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6075
__pyx_t_4 = PyNumber_Multiply(__pyx_v_r, __pyx_v_s); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 397, __pyx_L1_error)
6076
__Pyx_GOTREF(__pyx_t_4);
6077
__pyx_t_10 = PyNumber_Add(__pyx_v_t, __pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 397, __pyx_L1_error)
6078
__Pyx_GOTREF(__pyx_t_10);
6079
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6080
__pyx_t_4 = PyNumber_Multiply(__pyx_t_10, __pyx_v_a1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 397, __pyx_L1_error)
6081
__Pyx_GOTREF(__pyx_t_4);
6082
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6083
__pyx_t_10 = PyNumber_Subtract(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 397, __pyx_L1_error)
6084
__Pyx_GOTREF(__pyx_t_10);
6085
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6086
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6087
__pyx_t_4 = PyNumber_Power(__pyx_v_r, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 397, __pyx_L1_error)
6088
__Pyx_GOTREF(__pyx_t_4);
6089
__pyx_t_6 = PyNumber_Multiply(__pyx_int_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 397, __pyx_L1_error)
6090
__Pyx_GOTREF(__pyx_t_6);
6091
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6092
__pyx_t_4 = PyNumber_Add(__pyx_t_10, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 397, __pyx_L1_error)
6093
__Pyx_GOTREF(__pyx_t_4);
6094
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6095
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6096
__pyx_t_6 = PyNumber_Multiply(__pyx_int_2, __pyx_v_s); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 397, __pyx_L1_error)
6097
__Pyx_GOTREF(__pyx_t_6);
6098
__pyx_t_10 = PyNumber_Multiply(__pyx_t_6, __pyx_v_t); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 397, __pyx_L1_error)
6099
__Pyx_GOTREF(__pyx_t_10);
6100
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6101
__pyx_t_6 = PyNumber_Subtract(__pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 397, __pyx_L1_error)
6102
__Pyx_GOTREF(__pyx_t_6);
6103
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6104
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6105
__pyx_v_a4p = __pyx_t_6;
6106
__pyx_t_6 = 0;
6107
6108
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":398
6109
* t = r*s + (a3p - a3 - ra1p)/K(2)
6110
* a4p = a4 - s*a3 + 2*r*a2 - (t+r*s)*a1 + 3*r**2 - 2*s*t
6111
* a6p = a6 + r*a4 + r**2*a2 + r**3 - t*a3 - t**2 - r*t*a1 # <<<<<<<<<<<<<<
6112
* return EllipticCurve(K, [a1p, a2p, a3p, a4p, a6p])
6113
*
6114
*/
6115
__pyx_t_6 = PyNumber_Multiply(__pyx_v_r, __pyx_v_a4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 398, __pyx_L1_error)
6116
__Pyx_GOTREF(__pyx_t_6);
6117
__pyx_t_10 = PyNumber_Add(__pyx_v_a6, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 398, __pyx_L1_error)
6118
__Pyx_GOTREF(__pyx_t_10);
6119
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6120
__pyx_t_6 = PyNumber_Power(__pyx_v_r, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 398, __pyx_L1_error)
6121
__Pyx_GOTREF(__pyx_t_6);
6122
__pyx_t_4 = PyNumber_Multiply(__pyx_t_6, __pyx_v_a2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error)
6123
__Pyx_GOTREF(__pyx_t_4);
6124
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6125
__pyx_t_6 = PyNumber_Add(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 398, __pyx_L1_error)
6126
__Pyx_GOTREF(__pyx_t_6);
6127
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6128
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6129
__pyx_t_4 = PyNumber_Power(__pyx_v_r, __pyx_int_3, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error)
6130
__Pyx_GOTREF(__pyx_t_4);
6131
__pyx_t_10 = PyNumber_Add(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 398, __pyx_L1_error)
6132
__Pyx_GOTREF(__pyx_t_10);
6133
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6134
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6135
__pyx_t_4 = PyNumber_Multiply(__pyx_v_t, __pyx_v_a3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error)
6136
__Pyx_GOTREF(__pyx_t_4);
6137
__pyx_t_6 = PyNumber_Subtract(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 398, __pyx_L1_error)
6138
__Pyx_GOTREF(__pyx_t_6);
6139
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6140
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6141
__pyx_t_4 = PyNumber_Power(__pyx_v_t, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error)
6142
__Pyx_GOTREF(__pyx_t_4);
6143
__pyx_t_10 = PyNumber_Subtract(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 398, __pyx_L1_error)
6144
__Pyx_GOTREF(__pyx_t_10);
6145
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6146
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6147
__pyx_t_4 = PyNumber_Multiply(__pyx_v_r, __pyx_v_t); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error)
6148
__Pyx_GOTREF(__pyx_t_4);
6149
__pyx_t_6 = PyNumber_Multiply(__pyx_t_4, __pyx_v_a1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 398, __pyx_L1_error)
6150
__Pyx_GOTREF(__pyx_t_6);
6151
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6152
__pyx_t_4 = PyNumber_Subtract(__pyx_t_10, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error)
6153
__Pyx_GOTREF(__pyx_t_4);
6154
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6155
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6156
__pyx_v_a6p = __pyx_t_4;
6157
__pyx_t_4 = 0;
6158
6159
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":399
6160
* a4p = a4 - s*a3 + 2*r*a2 - (t+r*s)*a1 + 3*r**2 - 2*s*t
6161
* a6p = a6 + r*a4 + r**2*a2 + r**3 - t*a3 - t**2 - r*t*a1
6162
* return EllipticCurve(K, [a1p, a2p, a3p, a4p, a6p]) # <<<<<<<<<<<<<<
6163
*
6164
* cpdef canonical_model_c_invariants(Integer a, Integer b, Integer c, Integer d):
6165
*/
6166
__Pyx_XDECREF(__pyx_r);
6167
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_EllipticCurve); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 399, __pyx_L1_error)
6168
__Pyx_GOTREF(__pyx_t_6);
6169
__pyx_t_10 = PyList_New(5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 399, __pyx_L1_error)
6170
__Pyx_GOTREF(__pyx_t_10);
6171
__Pyx_INCREF(__pyx_v_a1p);
6172
__Pyx_GIVEREF(__pyx_v_a1p);
6173
PyList_SET_ITEM(__pyx_t_10, 0, __pyx_v_a1p);
6174
__Pyx_INCREF(__pyx_v_a2p);
6175
__Pyx_GIVEREF(__pyx_v_a2p);
6176
PyList_SET_ITEM(__pyx_t_10, 1, __pyx_v_a2p);
6177
__Pyx_INCREF(__pyx_v_a3p);
6178
__Pyx_GIVEREF(__pyx_v_a3p);
6179
PyList_SET_ITEM(__pyx_t_10, 2, __pyx_v_a3p);
6180
__Pyx_INCREF(__pyx_v_a4p);
6181
__Pyx_GIVEREF(__pyx_v_a4p);
6182
PyList_SET_ITEM(__pyx_t_10, 3, __pyx_v_a4p);
6183
__Pyx_INCREF(__pyx_v_a6p);
6184
__Pyx_GIVEREF(__pyx_v_a6p);
6185
PyList_SET_ITEM(__pyx_t_10, 4, __pyx_v_a6p);
6186
__pyx_t_5 = NULL;
6187
__pyx_t_13 = 0;
6188
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
6189
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
6190
if (likely(__pyx_t_5)) {
6191
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
6192
__Pyx_INCREF(__pyx_t_5);
6193
__Pyx_INCREF(function);
6194
__Pyx_DECREF_SET(__pyx_t_6, function);
6195
__pyx_t_13 = 1;
6196
}
6197
}
6198
#if CYTHON_FAST_PYCALL
6199
if (PyFunction_Check(__pyx_t_6)) {
6200
PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_K, __pyx_t_10};
6201
__pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 399, __pyx_L1_error)
6202
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
6203
__Pyx_GOTREF(__pyx_t_4);
6204
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6205
} else
6206
#endif
6207
#if CYTHON_FAST_PYCCALL
6208
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
6209
PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_K, __pyx_t_10};
6210
__pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 399, __pyx_L1_error)
6211
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
6212
__Pyx_GOTREF(__pyx_t_4);
6213
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
6214
} else
6215
#endif
6216
{
6217
__pyx_t_11 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 399, __pyx_L1_error)
6218
__Pyx_GOTREF(__pyx_t_11);
6219
if (__pyx_t_5) {
6220
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); __pyx_t_5 = NULL;
6221
}
6222
__Pyx_INCREF(__pyx_v_K);
6223
__Pyx_GIVEREF(__pyx_v_K);
6224
PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_13, __pyx_v_K);
6225
__Pyx_GIVEREF(__pyx_t_10);
6226
PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_13, __pyx_t_10);
6227
__pyx_t_10 = 0;
6228
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 399, __pyx_L1_error)
6229
__Pyx_GOTREF(__pyx_t_4);
6230
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
6231
}
6232
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6233
__pyx_r = __pyx_t_4;
6234
__pyx_t_4 = 0;
6235
goto __pyx_L0;
6236
6237
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":345
6238
* return c,d,e,f
6239
*
6240
* def canonical_model(E): # <<<<<<<<<<<<<<
6241
* """
6242
* Given a global minimal model E over Q(sqrt5) returns a canonical global
6243
*/
6244
6245
/* function exit code */
6246
__pyx_L1_error:;
6247
__Pyx_XDECREF(__pyx_t_4);
6248
__Pyx_XDECREF(__pyx_t_5);
6249
__Pyx_XDECREF(__pyx_t_6);
6250
__Pyx_XDECREF(__pyx_t_8);
6251
__Pyx_XDECREF(__pyx_t_10);
6252
__Pyx_XDECREF(__pyx_t_11);
6253
__Pyx_XDECREF(__pyx_t_12);
6254
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.minmodel.sqrt5.canonical_model", __pyx_clineno, __pyx_lineno, __pyx_filename);
6255
__pyx_r = NULL;
6256
__pyx_L0:;
6257
__Pyx_XDECREF(__pyx_v_K);
6258
__Pyx_XDECREF(__pyx_v_D1);
6259
__Pyx_XDECREF(__pyx_v_D2);
6260
__Pyx_XDECREF(__pyx_v_a1);
6261
__Pyx_XDECREF(__pyx_v_a2);
6262
__Pyx_XDECREF(__pyx_v_a3);
6263
__Pyx_XDECREF(__pyx_v_a4);
6264
__Pyx_XDECREF(__pyx_v_a6);
6265
__Pyx_XDECREF((PyObject *)__pyx_v_u1);
6266
__Pyx_XDECREF((PyObject *)__pyx_v_u2);
6267
__Pyx_XDECREF(__pyx_v_u);
6268
__Pyx_XDECREF(__pyx_v_P2);
6269
__Pyx_XDECREF(__pyx_v_P3);
6270
__Pyx_XDECREF(__pyx_v_a1p);
6271
__Pyx_XDECREF(__pyx_v_s);
6272
__Pyx_XDECREF(__pyx_v_sa1);
6273
__Pyx_XDECREF(__pyx_v_a2p);
6274
__Pyx_XDECREF(__pyx_v_r);
6275
__Pyx_XDECREF(__pyx_v_ra1p);
6276
__Pyx_XDECREF(__pyx_v_a3p);
6277
__Pyx_XDECREF(__pyx_v_t);
6278
__Pyx_XDECREF(__pyx_v_a4p);
6279
__Pyx_XDECREF(__pyx_v_a6p);
6280
__Pyx_XGIVEREF(__pyx_r);
6281
__Pyx_RefNannyFinishContext();
6282
return __pyx_r;
6283
}
6284
6285
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":401
6286
* return EllipticCurve(K, [a1p, a2p, a3p, a4p, a6p])
6287
*
6288
* cpdef canonical_model_c_invariants(Integer a, Integer b, Integer c, Integer d): # <<<<<<<<<<<<<<
6289
* """
6290
* Given the pair (c4,c6) of a global minimal model, canonical_model returns
6291
*/
6292
6293
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_5canonical_model_c_invariants(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6294
static PyObject *__pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_canonical_model_c_invariants(struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_a, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_b, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_c, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_d, CYTHON_UNUSED int __pyx_skip_dispatch) {
6295
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_x = 0;
6296
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_y = 0;
6297
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_z = 0;
6298
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_w = 0;
6299
mpz_t __pyx_v_p;
6300
mpz_t __pyx_v_q;
6301
PyObject *__pyx_r = NULL;
6302
__Pyx_RefNannyDeclarations
6303
PyObject *__pyx_t_1 = NULL;
6304
PyObject *__pyx_t_2 = NULL;
6305
__Pyx_RefNannySetupContext("canonical_model_c_invariants", 0);
6306
6307
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":436
6308
* cdef Integer x,y,z,w
6309
* cdef mpz_t p,q
6310
* x = <Integer>PY_NEW(Integer) # <<<<<<<<<<<<<<
6311
* y = <Integer>PY_NEW(Integer)
6312
* z = <Integer>PY_NEW(Integer)
6313
*/
6314
__pyx_t_1 = __pyx_f_4sage_3ext_7stdsage_PY_NEW(__pyx_ptype_4sage_5rings_7integer_Integer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 436, __pyx_L1_error)
6315
__Pyx_GOTREF(__pyx_t_1);
6316
__pyx_t_2 = __pyx_t_1;
6317
__Pyx_INCREF(__pyx_t_2);
6318
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6319
__pyx_v_x = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)__pyx_t_2);
6320
__pyx_t_2 = 0;
6321
6322
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":437
6323
* cdef mpz_t p,q
6324
* x = <Integer>PY_NEW(Integer)
6325
* y = <Integer>PY_NEW(Integer) # <<<<<<<<<<<<<<
6326
* z = <Integer>PY_NEW(Integer)
6327
* w = <Integer>PY_NEW(Integer)
6328
*/
6329
__pyx_t_2 = __pyx_f_4sage_3ext_7stdsage_PY_NEW(__pyx_ptype_4sage_5rings_7integer_Integer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 437, __pyx_L1_error)
6330
__Pyx_GOTREF(__pyx_t_2);
6331
__pyx_t_1 = __pyx_t_2;
6332
__Pyx_INCREF(__pyx_t_1);
6333
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6334
__pyx_v_y = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)__pyx_t_1);
6335
__pyx_t_1 = 0;
6336
6337
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":438
6338
* x = <Integer>PY_NEW(Integer)
6339
* y = <Integer>PY_NEW(Integer)
6340
* z = <Integer>PY_NEW(Integer) # <<<<<<<<<<<<<<
6341
* w = <Integer>PY_NEW(Integer)
6342
* mpz_init(p)
6343
*/
6344
__pyx_t_1 = __pyx_f_4sage_3ext_7stdsage_PY_NEW(__pyx_ptype_4sage_5rings_7integer_Integer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
6345
__Pyx_GOTREF(__pyx_t_1);
6346
__pyx_t_2 = __pyx_t_1;
6347
__Pyx_INCREF(__pyx_t_2);
6348
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6349
__pyx_v_z = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)__pyx_t_2);
6350
__pyx_t_2 = 0;
6351
6352
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":439
6353
* y = <Integer>PY_NEW(Integer)
6354
* z = <Integer>PY_NEW(Integer)
6355
* w = <Integer>PY_NEW(Integer) # <<<<<<<<<<<<<<
6356
* mpz_init(p)
6357
* mpz_init(q)
6358
*/
6359
__pyx_t_2 = __pyx_f_4sage_3ext_7stdsage_PY_NEW(__pyx_ptype_4sage_5rings_7integer_Integer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error)
6360
__Pyx_GOTREF(__pyx_t_2);
6361
__pyx_t_1 = __pyx_t_2;
6362
__Pyx_INCREF(__pyx_t_1);
6363
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6364
__pyx_v_w = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)__pyx_t_1);
6365
__pyx_t_1 = 0;
6366
6367
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":440
6368
* z = <Integer>PY_NEW(Integer)
6369
* w = <Integer>PY_NEW(Integer)
6370
* mpz_init(p) # <<<<<<<<<<<<<<
6371
* mpz_init(q)
6372
*
6373
*/
6374
mpz_init(__pyx_v_p);
6375
6376
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":441
6377
* w = <Integer>PY_NEW(Integer)
6378
* mpz_init(p)
6379
* mpz_init(q) # <<<<<<<<<<<<<<
6380
*
6381
* # p+q*g = (a+b*g)^3
6382
*/
6383
mpz_init(__pyx_v_q);
6384
6385
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":444
6386
*
6387
* # p+q*g = (a+b*g)^3
6388
* mpz_mul(x.value,a.value,a.value) # <<<<<<<<<<<<<<
6389
* mpz_mul(y.value,b.value,b.value)
6390
* mpz_mul(p,y.value,a.value)
6391
*/
6392
mpz_mul(__pyx_v_x->value, __pyx_v_a->value, __pyx_v_a->value);
6393
6394
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":445
6395
* # p+q*g = (a+b*g)^3
6396
* mpz_mul(x.value,a.value,a.value)
6397
* mpz_mul(y.value,b.value,b.value) # <<<<<<<<<<<<<<
6398
* mpz_mul(p,y.value,a.value)
6399
* mpz_mul_si(p,p,3)
6400
*/
6401
mpz_mul(__pyx_v_y->value, __pyx_v_b->value, __pyx_v_b->value);
6402
6403
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":446
6404
* mpz_mul(x.value,a.value,a.value)
6405
* mpz_mul(y.value,b.value,b.value)
6406
* mpz_mul(p,y.value,a.value) # <<<<<<<<<<<<<<
6407
* mpz_mul_si(p,p,3)
6408
* mpz_mul(q,x.value,b.value)
6409
*/
6410
mpz_mul(__pyx_v_p, __pyx_v_y->value, __pyx_v_a->value);
6411
6412
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":447
6413
* mpz_mul(y.value,b.value,b.value)
6414
* mpz_mul(p,y.value,a.value)
6415
* mpz_mul_si(p,p,3) # <<<<<<<<<<<<<<
6416
* mpz_mul(q,x.value,b.value)
6417
* mpz_mul_si(q,q,3)
6418
*/
6419
mpz_mul_si(__pyx_v_p, __pyx_v_p, 3);
6420
6421
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":448
6422
* mpz_mul(p,y.value,a.value)
6423
* mpz_mul_si(p,p,3)
6424
* mpz_mul(q,x.value,b.value) # <<<<<<<<<<<<<<
6425
* mpz_mul_si(q,q,3)
6426
* mpz_add(q,q,p)
6427
*/
6428
mpz_mul(__pyx_v_q, __pyx_v_x->value, __pyx_v_b->value);
6429
6430
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":449
6431
* mpz_mul_si(p,p,3)
6432
* mpz_mul(q,x.value,b.value)
6433
* mpz_mul_si(q,q,3) # <<<<<<<<<<<<<<
6434
* mpz_add(q,q,p)
6435
* mpz_addmul(p,x.value,a.value)
6436
*/
6437
mpz_mul_si(__pyx_v_q, __pyx_v_q, 3);
6438
6439
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":450
6440
* mpz_mul(q,x.value,b.value)
6441
* mpz_mul_si(q,q,3)
6442
* mpz_add(q,q,p) # <<<<<<<<<<<<<<
6443
* mpz_addmul(p,x.value,a.value)
6444
* mpz_mul(y.value,y.value,b.value)
6445
*/
6446
mpz_add(__pyx_v_q, __pyx_v_q, __pyx_v_p);
6447
6448
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":451
6449
* mpz_mul_si(q,q,3)
6450
* mpz_add(q,q,p)
6451
* mpz_addmul(p,x.value,a.value) # <<<<<<<<<<<<<<
6452
* mpz_mul(y.value,y.value,b.value)
6453
* mpz_add(p,p,y.value)
6454
*/
6455
mpz_addmul(__pyx_v_p, __pyx_v_x->value, __pyx_v_a->value);
6456
6457
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":452
6458
* mpz_add(q,q,p)
6459
* mpz_addmul(p,x.value,a.value)
6460
* mpz_mul(y.value,y.value,b.value) # <<<<<<<<<<<<<<
6461
* mpz_add(p,p,y.value)
6462
* mpz_addmul_ui(q,y.value,2)
6463
*/
6464
mpz_mul(__pyx_v_y->value, __pyx_v_y->value, __pyx_v_b->value);
6465
6466
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":453
6467
* mpz_addmul(p,x.value,a.value)
6468
* mpz_mul(y.value,y.value,b.value)
6469
* mpz_add(p,p,y.value) # <<<<<<<<<<<<<<
6470
* mpz_addmul_ui(q,y.value,2)
6471
*
6472
*/
6473
mpz_add(__pyx_v_p, __pyx_v_p, __pyx_v_y->value);
6474
6475
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":454
6476
* mpz_mul(y.value,y.value,b.value)
6477
* mpz_add(p,p,y.value)
6478
* mpz_addmul_ui(q,y.value,2) # <<<<<<<<<<<<<<
6479
*
6480
*
6481
*/
6482
mpz_addmul_ui(__pyx_v_q, __pyx_v_y->value, 2);
6483
6484
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":460
6485
*
6486
* # p+q*g -= (c+d*g)^2
6487
* mpz_submul(p,c.value,c.value) # <<<<<<<<<<<<<<
6488
* mpz_mul(x.value,c.value,d.value)
6489
* mpz_submul_ui(q,x.value,2)
6490
*/
6491
mpz_submul(__pyx_v_p, __pyx_v_c->value, __pyx_v_c->value);
6492
6493
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":461
6494
* # p+q*g -= (c+d*g)^2
6495
* mpz_submul(p,c.value,c.value)
6496
* mpz_mul(x.value,c.value,d.value) # <<<<<<<<<<<<<<
6497
* mpz_submul_ui(q,x.value,2)
6498
* mpz_mul(x.value,d.value,d.value)
6499
*/
6500
mpz_mul(__pyx_v_x->value, __pyx_v_c->value, __pyx_v_d->value);
6501
6502
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":462
6503
* mpz_submul(p,c.value,c.value)
6504
* mpz_mul(x.value,c.value,d.value)
6505
* mpz_submul_ui(q,x.value,2) # <<<<<<<<<<<<<<
6506
* mpz_mul(x.value,d.value,d.value)
6507
* mpz_sub(p,p,x.value)
6508
*/
6509
mpz_submul_ui(__pyx_v_q, __pyx_v_x->value, 2);
6510
6511
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":463
6512
* mpz_mul(x.value,c.value,d.value)
6513
* mpz_submul_ui(q,x.value,2)
6514
* mpz_mul(x.value,d.value,d.value) # <<<<<<<<<<<<<<
6515
* mpz_sub(p,p,x.value)
6516
* mpz_sub(q,q,x.value)
6517
*/
6518
mpz_mul(__pyx_v_x->value, __pyx_v_d->value, __pyx_v_d->value);
6519
6520
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":464
6521
* mpz_submul_ui(q,x.value,2)
6522
* mpz_mul(x.value,d.value,d.value)
6523
* mpz_sub(p,p,x.value) # <<<<<<<<<<<<<<
6524
* mpz_sub(q,q,x.value)
6525
*
6526
*/
6527
mpz_sub(__pyx_v_p, __pyx_v_p, __pyx_v_x->value);
6528
6529
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":465
6530
* mpz_mul(x.value,d.value,d.value)
6531
* mpz_sub(p,p,x.value)
6532
* mpz_sub(q,q,x.value) # <<<<<<<<<<<<<<
6533
*
6534
* # p+q*g /= 1728
6535
*/
6536
mpz_sub(__pyx_v_q, __pyx_v_q, __pyx_v_x->value);
6537
6538
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":468
6539
*
6540
* # p+q*g /= 1728
6541
* mpz_divexact_ui(p,p,1728) # <<<<<<<<<<<<<<
6542
* mpz_divexact_ui(q,q,1728)
6543
*
6544
*/
6545
mpz_divexact_ui(__pyx_v_p, __pyx_v_p, 0x6C0);
6546
6547
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":469
6548
* # p+q*g /= 1728
6549
* mpz_divexact_ui(p,p,1728)
6550
* mpz_divexact_ui(q,q,1728) # <<<<<<<<<<<<<<
6551
*
6552
*
6553
*/
6554
mpz_divexact_ui(__pyx_v_q, __pyx_v_q, 0x6C0);
6555
6556
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":473
6557
*
6558
* # find the needed transformation, and x+y*g to corresponding unit
6559
* f_mapC(p,q,x.value,y.value,p,q) # <<<<<<<<<<<<<<
6560
*
6561
*
6562
*/
6563
__pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_mapC(__pyx_v_p, __pyx_v_q, __pyx_v_x->value, __pyx_v_y->value, __pyx_v_p, __pyx_v_q);
6564
6565
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":479
6566
*
6567
* # p+q*g = (x+y*g)^-2
6568
* mpz_add(x.value,x.value,y.value) # <<<<<<<<<<<<<<
6569
* mpz_mul(p,y.value,y.value)
6570
* mpz_mul(q,x.value,y.value)
6571
*/
6572
mpz_add(__pyx_v_x->value, __pyx_v_x->value, __pyx_v_y->value);
6573
6574
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":480
6575
* # p+q*g = (x+y*g)^-2
6576
* mpz_add(x.value,x.value,y.value)
6577
* mpz_mul(p,y.value,y.value) # <<<<<<<<<<<<<<
6578
* mpz_mul(q,x.value,y.value)
6579
* mpz_mul_si(q,q,2)
6580
*/
6581
mpz_mul(__pyx_v_p, __pyx_v_y->value, __pyx_v_y->value);
6582
6583
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":481
6584
* mpz_add(x.value,x.value,y.value)
6585
* mpz_mul(p,y.value,y.value)
6586
* mpz_mul(q,x.value,y.value) # <<<<<<<<<<<<<<
6587
* mpz_mul_si(q,q,2)
6588
* mpz_sub(q,q,p)
6589
*/
6590
mpz_mul(__pyx_v_q, __pyx_v_x->value, __pyx_v_y->value);
6591
6592
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":482
6593
* mpz_mul(p,y.value,y.value)
6594
* mpz_mul(q,x.value,y.value)
6595
* mpz_mul_si(q,q,2) # <<<<<<<<<<<<<<
6596
* mpz_sub(q,q,p)
6597
* mpz_addmul(p,x.value,x.value)
6598
*/
6599
mpz_mul_si(__pyx_v_q, __pyx_v_q, 2);
6600
6601
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":483
6602
* mpz_mul(q,x.value,y.value)
6603
* mpz_mul_si(q,q,2)
6604
* mpz_sub(q,q,p) # <<<<<<<<<<<<<<
6605
* mpz_addmul(p,x.value,x.value)
6606
* mpz_neg(q,q)
6607
*/
6608
mpz_sub(__pyx_v_q, __pyx_v_q, __pyx_v_p);
6609
6610
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":484
6611
* mpz_mul_si(q,q,2)
6612
* mpz_sub(q,q,p)
6613
* mpz_addmul(p,x.value,x.value) # <<<<<<<<<<<<<<
6614
* mpz_neg(q,q)
6615
*
6616
*/
6617
mpz_addmul(__pyx_v_p, __pyx_v_x->value, __pyx_v_x->value);
6618
6619
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":485
6620
* mpz_sub(q,q,p)
6621
* mpz_addmul(p,x.value,x.value)
6622
* mpz_neg(q,q) # <<<<<<<<<<<<<<
6623
*
6624
* # x+y*g = (p+q*g)^3
6625
*/
6626
mpz_neg(__pyx_v_q, __pyx_v_q);
6627
6628
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":488
6629
*
6630
* # x+y*g = (p+q*g)^3
6631
* mpz_mul(z.value,p,p) # <<<<<<<<<<<<<<
6632
* mpz_mul(w.value,q,q)
6633
* mpz_mul(x.value,w.value,p)
6634
*/
6635
mpz_mul(__pyx_v_z->value, __pyx_v_p, __pyx_v_p);
6636
6637
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":489
6638
* # x+y*g = (p+q*g)^3
6639
* mpz_mul(z.value,p,p)
6640
* mpz_mul(w.value,q,q) # <<<<<<<<<<<<<<
6641
* mpz_mul(x.value,w.value,p)
6642
* mpz_mul_si(x.value,x.value,3)
6643
*/
6644
mpz_mul(__pyx_v_w->value, __pyx_v_q, __pyx_v_q);
6645
6646
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":490
6647
* mpz_mul(z.value,p,p)
6648
* mpz_mul(w.value,q,q)
6649
* mpz_mul(x.value,w.value,p) # <<<<<<<<<<<<<<
6650
* mpz_mul_si(x.value,x.value,3)
6651
* mpz_mul(y.value,z.value,q)
6652
*/
6653
mpz_mul(__pyx_v_x->value, __pyx_v_w->value, __pyx_v_p);
6654
6655
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":491
6656
* mpz_mul(w.value,q,q)
6657
* mpz_mul(x.value,w.value,p)
6658
* mpz_mul_si(x.value,x.value,3) # <<<<<<<<<<<<<<
6659
* mpz_mul(y.value,z.value,q)
6660
* mpz_mul_si(y.value,y.value,3)
6661
*/
6662
mpz_mul_si(__pyx_v_x->value, __pyx_v_x->value, 3);
6663
6664
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":492
6665
* mpz_mul(x.value,w.value,p)
6666
* mpz_mul_si(x.value,x.value,3)
6667
* mpz_mul(y.value,z.value,q) # <<<<<<<<<<<<<<
6668
* mpz_mul_si(y.value,y.value,3)
6669
* mpz_add(y.value,y.value,x.value)
6670
*/
6671
mpz_mul(__pyx_v_y->value, __pyx_v_z->value, __pyx_v_q);
6672
6673
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":493
6674
* mpz_mul_si(x.value,x.value,3)
6675
* mpz_mul(y.value,z.value,q)
6676
* mpz_mul_si(y.value,y.value,3) # <<<<<<<<<<<<<<
6677
* mpz_add(y.value,y.value,x.value)
6678
* mpz_addmul(x.value,z.value,p)
6679
*/
6680
mpz_mul_si(__pyx_v_y->value, __pyx_v_y->value, 3);
6681
6682
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":494
6683
* mpz_mul(y.value,z.value,q)
6684
* mpz_mul_si(y.value,y.value,3)
6685
* mpz_add(y.value,y.value,x.value) # <<<<<<<<<<<<<<
6686
* mpz_addmul(x.value,z.value,p)
6687
* mpz_mul(w.value,w.value,q)
6688
*/
6689
mpz_add(__pyx_v_y->value, __pyx_v_y->value, __pyx_v_x->value);
6690
6691
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":495
6692
* mpz_mul_si(y.value,y.value,3)
6693
* mpz_add(y.value,y.value,x.value)
6694
* mpz_addmul(x.value,z.value,p) # <<<<<<<<<<<<<<
6695
* mpz_mul(w.value,w.value,q)
6696
* mpz_add(x.value,x.value,w.value)
6697
*/
6698
mpz_addmul(__pyx_v_x->value, __pyx_v_z->value, __pyx_v_p);
6699
6700
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":496
6701
* mpz_add(y.value,y.value,x.value)
6702
* mpz_addmul(x.value,z.value,p)
6703
* mpz_mul(w.value,w.value,q) # <<<<<<<<<<<<<<
6704
* mpz_add(x.value,x.value,w.value)
6705
* mpz_addmul_ui(y.value,w.value,2)
6706
*/
6707
mpz_mul(__pyx_v_w->value, __pyx_v_w->value, __pyx_v_q);
6708
6709
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":497
6710
* mpz_addmul(x.value,z.value,p)
6711
* mpz_mul(w.value,w.value,q)
6712
* mpz_add(x.value,x.value,w.value) # <<<<<<<<<<<<<<
6713
* mpz_addmul_ui(y.value,w.value,2)
6714
*
6715
*/
6716
mpz_add(__pyx_v_x->value, __pyx_v_x->value, __pyx_v_w->value);
6717
6718
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":498
6719
* mpz_mul(w.value,w.value,q)
6720
* mpz_add(x.value,x.value,w.value)
6721
* mpz_addmul_ui(y.value,w.value,2) # <<<<<<<<<<<<<<
6722
*
6723
* # z+w*g = (x+y*g)*(c+d*g)
6724
*/
6725
mpz_addmul_ui(__pyx_v_y->value, __pyx_v_w->value, 2);
6726
6727
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":501
6728
*
6729
* # z+w*g = (x+y*g)*(c+d*g)
6730
* mpz_mul(z.value,y.value,d.value) # <<<<<<<<<<<<<<
6731
* mpz_mul(w.value,x.value,d.value)
6732
* mpz_addmul(w.value,y.value,c.value)
6733
*/
6734
mpz_mul(__pyx_v_z->value, __pyx_v_y->value, __pyx_v_d->value);
6735
6736
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":502
6737
* # z+w*g = (x+y*g)*(c+d*g)
6738
* mpz_mul(z.value,y.value,d.value)
6739
* mpz_mul(w.value,x.value,d.value) # <<<<<<<<<<<<<<
6740
* mpz_addmul(w.value,y.value,c.value)
6741
* mpz_add(w.value,w.value,z.value)
6742
*/
6743
mpz_mul(__pyx_v_w->value, __pyx_v_x->value, __pyx_v_d->value);
6744
6745
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":503
6746
* mpz_mul(z.value,y.value,d.value)
6747
* mpz_mul(w.value,x.value,d.value)
6748
* mpz_addmul(w.value,y.value,c.value) # <<<<<<<<<<<<<<
6749
* mpz_add(w.value,w.value,z.value)
6750
* mpz_addmul(z.value,x.value,c.value)
6751
*/
6752
mpz_addmul(__pyx_v_w->value, __pyx_v_y->value, __pyx_v_c->value);
6753
6754
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":504
6755
* mpz_mul(w.value,x.value,d.value)
6756
* mpz_addmul(w.value,y.value,c.value)
6757
* mpz_add(w.value,w.value,z.value) # <<<<<<<<<<<<<<
6758
* mpz_addmul(z.value,x.value,c.value)
6759
*
6760
*/
6761
mpz_add(__pyx_v_w->value, __pyx_v_w->value, __pyx_v_z->value);
6762
6763
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":505
6764
* mpz_addmul(w.value,y.value,c.value)
6765
* mpz_add(w.value,w.value,z.value)
6766
* mpz_addmul(z.value,x.value,c.value) # <<<<<<<<<<<<<<
6767
*
6768
* # p+q*g *= p+q*g
6769
*/
6770
mpz_addmul(__pyx_v_z->value, __pyx_v_x->value, __pyx_v_c->value);
6771
6772
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":508
6773
*
6774
* # p+q*g *= p+q*g
6775
* mpz_mul(x.value,p,q) # <<<<<<<<<<<<<<
6776
* mpz_mul(q,q,q)
6777
* mpz_mul(p,p,p)
6778
*/
6779
mpz_mul(__pyx_v_x->value, __pyx_v_p, __pyx_v_q);
6780
6781
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":509
6782
* # p+q*g *= p+q*g
6783
* mpz_mul(x.value,p,q)
6784
* mpz_mul(q,q,q) # <<<<<<<<<<<<<<
6785
* mpz_mul(p,p,p)
6786
* mpz_add(p,p,q)
6787
*/
6788
mpz_mul(__pyx_v_q, __pyx_v_q, __pyx_v_q);
6789
6790
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":510
6791
* mpz_mul(x.value,p,q)
6792
* mpz_mul(q,q,q)
6793
* mpz_mul(p,p,p) # <<<<<<<<<<<<<<
6794
* mpz_add(p,p,q)
6795
* mpz_addmul_ui(q,x.value,2)
6796
*/
6797
mpz_mul(__pyx_v_p, __pyx_v_p, __pyx_v_p);
6798
6799
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":511
6800
* mpz_mul(q,q,q)
6801
* mpz_mul(p,p,p)
6802
* mpz_add(p,p,q) # <<<<<<<<<<<<<<
6803
* mpz_addmul_ui(q,x.value,2)
6804
*
6805
*/
6806
mpz_add(__pyx_v_p, __pyx_v_p, __pyx_v_q);
6807
6808
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":512
6809
* mpz_mul(p,p,p)
6810
* mpz_add(p,p,q)
6811
* mpz_addmul_ui(q,x.value,2) # <<<<<<<<<<<<<<
6812
*
6813
* # x+y*g = (p+q*g)*(a+b*g)
6814
*/
6815
mpz_addmul_ui(__pyx_v_q, __pyx_v_x->value, 2);
6816
6817
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":515
6818
*
6819
* # x+y*g = (p+q*g)*(a+b*g)
6820
* mpz_mul(x.value,q,b.value) # <<<<<<<<<<<<<<
6821
* mpz_mul(y.value,p,b.value)
6822
* mpz_addmul(y.value,q,a.value)
6823
*/
6824
mpz_mul(__pyx_v_x->value, __pyx_v_q, __pyx_v_b->value);
6825
6826
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":516
6827
* # x+y*g = (p+q*g)*(a+b*g)
6828
* mpz_mul(x.value,q,b.value)
6829
* mpz_mul(y.value,p,b.value) # <<<<<<<<<<<<<<
6830
* mpz_addmul(y.value,q,a.value)
6831
* mpz_add(y.value,y.value,x.value)
6832
*/
6833
mpz_mul(__pyx_v_y->value, __pyx_v_p, __pyx_v_b->value);
6834
6835
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":517
6836
* mpz_mul(x.value,q,b.value)
6837
* mpz_mul(y.value,p,b.value)
6838
* mpz_addmul(y.value,q,a.value) # <<<<<<<<<<<<<<
6839
* mpz_add(y.value,y.value,x.value)
6840
* mpz_addmul(x.value,p,a.value)
6841
*/
6842
mpz_addmul(__pyx_v_y->value, __pyx_v_q, __pyx_v_a->value);
6843
6844
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":518
6845
* mpz_mul(y.value,p,b.value)
6846
* mpz_addmul(y.value,q,a.value)
6847
* mpz_add(y.value,y.value,x.value) # <<<<<<<<<<<<<<
6848
* mpz_addmul(x.value,p,a.value)
6849
*
6850
*/
6851
mpz_add(__pyx_v_y->value, __pyx_v_y->value, __pyx_v_x->value);
6852
6853
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":519
6854
* mpz_addmul(y.value,q,a.value)
6855
* mpz_add(y.value,y.value,x.value)
6856
* mpz_addmul(x.value,p,a.value) # <<<<<<<<<<<<<<
6857
*
6858
* mpz_clear(p)
6859
*/
6860
mpz_addmul(__pyx_v_x->value, __pyx_v_p, __pyx_v_a->value);
6861
6862
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":521
6863
* mpz_addmul(x.value,p,a.value)
6864
*
6865
* mpz_clear(p) # <<<<<<<<<<<<<<
6866
* mpz_clear(q)
6867
*
6868
*/
6869
mpz_clear(__pyx_v_p);
6870
6871
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":522
6872
*
6873
* mpz_clear(p)
6874
* mpz_clear(q) # <<<<<<<<<<<<<<
6875
*
6876
* return x,y,z,w
6877
*/
6878
mpz_clear(__pyx_v_q);
6879
6880
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":524
6881
* mpz_clear(q)
6882
*
6883
* return x,y,z,w # <<<<<<<<<<<<<<
6884
*/
6885
__Pyx_XDECREF(__pyx_r);
6886
__pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
6887
__Pyx_GOTREF(__pyx_t_1);
6888
__Pyx_INCREF(((PyObject *)__pyx_v_x));
6889
__Pyx_GIVEREF(((PyObject *)__pyx_v_x));
6890
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_x));
6891
__Pyx_INCREF(((PyObject *)__pyx_v_y));
6892
__Pyx_GIVEREF(((PyObject *)__pyx_v_y));
6893
PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_y));
6894
__Pyx_INCREF(((PyObject *)__pyx_v_z));
6895
__Pyx_GIVEREF(((PyObject *)__pyx_v_z));
6896
PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_z));
6897
__Pyx_INCREF(((PyObject *)__pyx_v_w));
6898
__Pyx_GIVEREF(((PyObject *)__pyx_v_w));
6899
PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_w));
6900
__pyx_r = __pyx_t_1;
6901
__pyx_t_1 = 0;
6902
goto __pyx_L0;
6903
6904
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":401
6905
* return EllipticCurve(K, [a1p, a2p, a3p, a4p, a6p])
6906
*
6907
* cpdef canonical_model_c_invariants(Integer a, Integer b, Integer c, Integer d): # <<<<<<<<<<<<<<
6908
* """
6909
* Given the pair (c4,c6) of a global minimal model, canonical_model returns
6910
*/
6911
6912
/* function exit code */
6913
__pyx_L1_error:;
6914
__Pyx_XDECREF(__pyx_t_1);
6915
__Pyx_XDECREF(__pyx_t_2);
6916
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.minmodel.sqrt5.canonical_model_c_invariants", __pyx_clineno, __pyx_lineno, __pyx_filename);
6917
__pyx_r = 0;
6918
__pyx_L0:;
6919
__Pyx_XDECREF((PyObject *)__pyx_v_x);
6920
__Pyx_XDECREF((PyObject *)__pyx_v_y);
6921
__Pyx_XDECREF((PyObject *)__pyx_v_z);
6922
__Pyx_XDECREF((PyObject *)__pyx_v_w);
6923
__Pyx_XGIVEREF(__pyx_r);
6924
__Pyx_RefNannyFinishContext();
6925
return __pyx_r;
6926
}
6927
6928
/* Python wrapper */
6929
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_5canonical_model_c_invariants(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6930
static char __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_4canonical_model_c_invariants[] = "File: sqrt5.pyx (starting at line 401)\n\n Given the pair (c4,c6) of a global minimal model, canonical_model returns\n a 'cannonical' representation of the curve in terms of (c4,c6).\n \n INPUT:\n \n - ``c4=a+b*\\gamma`` -- an element of the ring of integers of `F=Q(\\sqrt{5})`\n - ``c6=c+d*\\gamma`` -- an element of the ring of integers of `F`\n \n OUTPUT:\n \n A 'cannonical' model of a curve in terms of (c4,c6)\n \n EXAMPLES::\n \n sage: K.<a> = NumberField(x^2-x-1)\n sage: E = EllipticCurve(K,[a,a+1,a+2,a+3,a+4])\n sage: F = E.change_weierstrass_model(a,a+1,a+2,a+3)\n sage: E.c_invariants() == F.c_invariants()\n False\n sage: Ecs = [Integer(i) for i in E.c4()]\n sage: Ecs += [Integer(i) for i in E.c6()]\n sage: Fcs = [Integer(i) for i in F.c4()]\n sage: Fcs += [Integer(i) for i in F.c6()]\n sage: from psage.ellcurve.minmodel.sqrt5 import canonical_model_c_invariants\n sage: canonical_model_c_invariants(Ecs[0],Ecs[1],Ecs[2],Ecs[3])\n (-118, -45, -3001, 116)\n sage: canonical_model_c_invariants(Fcs[0],Fcs[1],Fcs[2],Fcs[3])\n (-118, -45, -3001, 116)\n \n\n ";
6931
static PyObject *__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_5canonical_model_c_invariants(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6932
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_a = 0;
6933
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_b = 0;
6934
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_c = 0;
6935
struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_d = 0;
6936
PyObject *__pyx_r = 0;
6937
__Pyx_RefNannyDeclarations
6938
__Pyx_RefNannySetupContext("canonical_model_c_invariants (wrapper)", 0);
6939
{
6940
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_b,&__pyx_n_s_c,&__pyx_n_s_d,0};
6941
PyObject* values[4] = {0,0,0,0};
6942
if (unlikely(__pyx_kwds)) {
6943
Py_ssize_t kw_args;
6944
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6945
switch (pos_args) {
6946
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6947
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6948
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6949
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6950
case 0: break;
6951
default: goto __pyx_L5_argtuple_error;
6952
}
6953
kw_args = PyDict_Size(__pyx_kwds);
6954
switch (pos_args) {
6955
case 0:
6956
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
6957
else goto __pyx_L5_argtuple_error;
6958
case 1:
6959
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
6960
else {
6961
__Pyx_RaiseArgtupleInvalid("canonical_model_c_invariants", 1, 4, 4, 1); __PYX_ERR(0, 401, __pyx_L3_error)
6962
}
6963
case 2:
6964
if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_c)) != 0)) kw_args--;
6965
else {
6966
__Pyx_RaiseArgtupleInvalid("canonical_model_c_invariants", 1, 4, 4, 2); __PYX_ERR(0, 401, __pyx_L3_error)
6967
}
6968
case 3:
6969
if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_d)) != 0)) kw_args--;
6970
else {
6971
__Pyx_RaiseArgtupleInvalid("canonical_model_c_invariants", 1, 4, 4, 3); __PYX_ERR(0, 401, __pyx_L3_error)
6972
}
6973
}
6974
if (unlikely(kw_args > 0)) {
6975
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "canonical_model_c_invariants") < 0)) __PYX_ERR(0, 401, __pyx_L3_error)
6976
}
6977
} else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
6978
goto __pyx_L5_argtuple_error;
6979
} else {
6980
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6981
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6982
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6983
values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6984
}
6985
__pyx_v_a = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)values[0]);
6986
__pyx_v_b = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)values[1]);
6987
__pyx_v_c = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)values[2]);
6988
__pyx_v_d = ((struct __pyx_obj_4sage_5rings_7integer_Integer *)values[3]);
6989
}
6990
goto __pyx_L4_argument_unpacking_done;
6991
__pyx_L5_argtuple_error:;
6992
__Pyx_RaiseArgtupleInvalid("canonical_model_c_invariants", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 401, __pyx_L3_error)
6993
__pyx_L3_error:;
6994
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.minmodel.sqrt5.canonical_model_c_invariants", __pyx_clineno, __pyx_lineno, __pyx_filename);
6995
__Pyx_RefNannyFinishContext();
6996
return NULL;
6997
__pyx_L4_argument_unpacking_done:;
6998
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4sage_5rings_7integer_Integer, 1, "a", 0))) __PYX_ERR(0, 401, __pyx_L1_error)
6999
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4sage_5rings_7integer_Integer, 1, "b", 0))) __PYX_ERR(0, 401, __pyx_L1_error)
7000
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c), __pyx_ptype_4sage_5rings_7integer_Integer, 1, "c", 0))) __PYX_ERR(0, 401, __pyx_L1_error)
7001
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_d), __pyx_ptype_4sage_5rings_7integer_Integer, 1, "d", 0))) __PYX_ERR(0, 401, __pyx_L1_error)
7002
__pyx_r = __pyx_pf_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_4canonical_model_c_invariants(__pyx_self, __pyx_v_a, __pyx_v_b, __pyx_v_c, __pyx_v_d);
7003
7004
/* function exit code */
7005
goto __pyx_L0;
7006
__pyx_L1_error:;
7007
__pyx_r = NULL;
7008
__pyx_L0:;
7009
__Pyx_RefNannyFinishContext();
7010
return __pyx_r;
7011
}
7012
7013
static PyObject *__pyx_pf_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_4canonical_model_c_invariants(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_a, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_b, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_c, struct __pyx_obj_4sage_5rings_7integer_Integer *__pyx_v_d) {
7014
PyObject *__pyx_r = NULL;
7015
__Pyx_RefNannyDeclarations
7016
PyObject *__pyx_t_1 = NULL;
7017
__Pyx_RefNannySetupContext("canonical_model_c_invariants", 0);
7018
__Pyx_XDECREF(__pyx_r);
7019
__pyx_t_1 = __pyx_f_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_canonical_model_c_invariants(__pyx_v_a, __pyx_v_b, __pyx_v_c, __pyx_v_d, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error)
7020
__Pyx_GOTREF(__pyx_t_1);
7021
__pyx_r = __pyx_t_1;
7022
__pyx_t_1 = 0;
7023
goto __pyx_L0;
7024
7025
/* function exit code */
7026
__pyx_L1_error:;
7027
__Pyx_XDECREF(__pyx_t_1);
7028
__Pyx_AddTraceback("code.alex.psage.psage.ellcurve.minmodel.sqrt5.canonical_model_c_invariants", __pyx_clineno, __pyx_lineno, __pyx_filename);
7029
__pyx_r = NULL;
7030
__pyx_L0:;
7031
__Pyx_XGIVEREF(__pyx_r);
7032
__Pyx_RefNannyFinishContext();
7033
return __pyx_r;
7034
}
7035
7036
/* "sage/structure/element.pxd":7
7037
*
7038
*
7039
* cpdef inline parent(x): # <<<<<<<<<<<<<<
7040
* """
7041
* Return the parent of the element ``x``.
7042
*/
7043
7044
static PyObject *__pyx_pw_4sage_9structure_7element_1parent(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/
7045
static CYTHON_INLINE PyObject *__pyx_f_4sage_9structure_7element_parent(PyObject *__pyx_v_x, CYTHON_UNUSED int __pyx_skip_dispatch) {
7046
PyObject *__pyx_v_p = NULL;
7047
PyObject *__pyx_r = NULL;
7048
__Pyx_RefNannyDeclarations
7049
int __pyx_t_1;
7050
int __pyx_t_2;
7051
PyObject *__pyx_t_3 = NULL;
7052
PyObject *__pyx_t_4 = NULL;
7053
PyObject *__pyx_t_5 = NULL;
7054
PyObject *__pyx_t_6 = NULL;
7055
PyObject *__pyx_t_7 = NULL;
7056
PyObject *__pyx_t_8 = NULL;
7057
int __pyx_t_9;
7058
__Pyx_RefNannySetupContext("parent", 0);
7059
7060
/* "sage/structure/element.pxd":63
7061
* <... 'list'>
7062
* """
7063
* if isinstance(x, Element): # <<<<<<<<<<<<<<
7064
* return (<Element>x)._parent
7065
* # Fast check for "number" types, including int and float
7066
*/
7067
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4sage_9structure_7element_Element);
7068
__pyx_t_2 = (__pyx_t_1 != 0);
7069
if (__pyx_t_2) {
7070
7071
/* "sage/structure/element.pxd":64
7072
* """
7073
* if isinstance(x, Element):
7074
* return (<Element>x)._parent # <<<<<<<<<<<<<<
7075
* # Fast check for "number" types, including int and float
7076
* if PyNumber_Check(x):
7077
*/
7078
__Pyx_XDECREF(__pyx_r);
7079
__Pyx_INCREF(((PyObject *)((struct __pyx_obj_4sage_9structure_7element_Element *)__pyx_v_x)->_parent));
7080
__pyx_r = ((PyObject *)((struct __pyx_obj_4sage_9structure_7element_Element *)__pyx_v_x)->_parent);
7081
goto __pyx_L0;
7082
7083
/* "sage/structure/element.pxd":63
7084
* <... 'list'>
7085
* """
7086
* if isinstance(x, Element): # <<<<<<<<<<<<<<
7087
* return (<Element>x)._parent
7088
* # Fast check for "number" types, including int and float
7089
*/
7090
}
7091
7092
/* "sage/structure/element.pxd":66
7093
* return (<Element>x)._parent
7094
* # Fast check for "number" types, including int and float
7095
* if PyNumber_Check(x): # <<<<<<<<<<<<<<
7096
* return type(x)
7097
* try:
7098
*/
7099
__pyx_t_2 = (PyNumber_Check(__pyx_v_x) != 0);
7100
if (__pyx_t_2) {
7101
7102
/* "sage/structure/element.pxd":67
7103
* # Fast check for "number" types, including int and float
7104
* if PyNumber_Check(x):
7105
* return type(x) # <<<<<<<<<<<<<<
7106
* try:
7107
* p = x.parent
7108
*/
7109
__Pyx_XDECREF(__pyx_r);
7110
__Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_x)));
7111
__pyx_r = ((PyObject *)Py_TYPE(__pyx_v_x));
7112
goto __pyx_L0;
7113
7114
/* "sage/structure/element.pxd":66
7115
* return (<Element>x)._parent
7116
* # Fast check for "number" types, including int and float
7117
* if PyNumber_Check(x): # <<<<<<<<<<<<<<
7118
* return type(x)
7119
* try:
7120
*/
7121
}
7122
7123
/* "sage/structure/element.pxd":68
7124
* if PyNumber_Check(x):
7125
* return type(x)
7126
* try: # <<<<<<<<<<<<<<
7127
* p = x.parent
7128
* except AttributeError:
7129
*/
7130
{
7131
__Pyx_PyThreadState_declare
7132
__Pyx_PyThreadState_assign
7133
__Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
7134
__Pyx_XGOTREF(__pyx_t_3);
7135
__Pyx_XGOTREF(__pyx_t_4);
7136
__Pyx_XGOTREF(__pyx_t_5);
7137
/*try:*/ {
7138
7139
/* "sage/structure/element.pxd":69
7140
* return type(x)
7141
* try:
7142
* p = x.parent # <<<<<<<<<<<<<<
7143
* except AttributeError:
7144
* return type(x)
7145
*/
7146
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_parent); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 69, __pyx_L5_error)
7147
__Pyx_GOTREF(__pyx_t_6);
7148
__pyx_v_p = __pyx_t_6;
7149
__pyx_t_6 = 0;
7150
7151
/* "sage/structure/element.pxd":68
7152
* if PyNumber_Check(x):
7153
* return type(x)
7154
* try: # <<<<<<<<<<<<<<
7155
* p = x.parent
7156
* except AttributeError:
7157
*/
7158
}
7159
7160
/* "sage/structure/element.pxd":73
7161
* return type(x)
7162
* else:
7163
* return p() # <<<<<<<<<<<<<<
7164
*
7165
*
7166
*/
7167
/*else:*/ {
7168
__Pyx_XDECREF(__pyx_r);
7169
__Pyx_INCREF(__pyx_v_p);
7170
__pyx_t_7 = __pyx_v_p; __pyx_t_8 = NULL;
7171
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
7172
__pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
7173
if (likely(__pyx_t_8)) {
7174
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
7175
__Pyx_INCREF(__pyx_t_8);
7176
__Pyx_INCREF(function);
7177
__Pyx_DECREF_SET(__pyx_t_7, function);
7178
}
7179
}
7180
if (__pyx_t_8) {
7181
__pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 73, __pyx_L7_except_error)
7182
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7183
} else {
7184
__pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 73, __pyx_L7_except_error)
7185
}
7186
__Pyx_GOTREF(__pyx_t_6);
7187
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
7188
__pyx_r = __pyx_t_6;
7189
__pyx_t_6 = 0;
7190
goto __pyx_L8_except_return;
7191
}
7192
__pyx_L5_error:;
7193
__Pyx_PyThreadState_assign
7194
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7195
7196
/* "sage/structure/element.pxd":70
7197
* try:
7198
* p = x.parent
7199
* except AttributeError: # <<<<<<<<<<<<<<
7200
* return type(x)
7201
* else:
7202
*/
7203
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
7204
if (__pyx_t_9) {
7205
__Pyx_AddTraceback("sage.structure.element.parent", __pyx_clineno, __pyx_lineno, __pyx_filename);
7206
if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(1, 70, __pyx_L7_except_error)
7207
__Pyx_GOTREF(__pyx_t_6);
7208
__Pyx_GOTREF(__pyx_t_7);
7209
__Pyx_GOTREF(__pyx_t_8);
7210
7211
/* "sage/structure/element.pxd":71
7212
* p = x.parent
7213
* except AttributeError:
7214
* return type(x) # <<<<<<<<<<<<<<
7215
* else:
7216
* return p()
7217
*/
7218
__Pyx_XDECREF(__pyx_r);
7219
__Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_x)));
7220
__pyx_r = ((PyObject *)Py_TYPE(__pyx_v_x));
7221
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7222
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
7223
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7224
goto __pyx_L8_except_return;
7225
}
7226
goto __pyx_L7_except_error;
7227
__pyx_L7_except_error:;
7228
7229
/* "sage/structure/element.pxd":68
7230
* if PyNumber_Check(x):
7231
* return type(x)
7232
* try: # <<<<<<<<<<<<<<
7233
* p = x.parent
7234
* except AttributeError:
7235
*/
7236
__Pyx_PyThreadState_assign
7237
__Pyx_XGIVEREF(__pyx_t_3);
7238
__Pyx_XGIVEREF(__pyx_t_4);
7239
__Pyx_XGIVEREF(__pyx_t_5);
7240
__Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
7241
goto __pyx_L1_error;
7242
__pyx_L8_except_return:;
7243
__Pyx_PyThreadState_assign
7244
__Pyx_XGIVEREF(__pyx_t_3);
7245
__Pyx_XGIVEREF(__pyx_t_4);
7246
__Pyx_XGIVEREF(__pyx_t_5);
7247
__Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
7248
goto __pyx_L0;
7249
}
7250
7251
/* "sage/structure/element.pxd":7
7252
*
7253
*
7254
* cpdef inline parent(x): # <<<<<<<<<<<<<<
7255
* """
7256
* Return the parent of the element ``x``.
7257
*/
7258
7259
/* function exit code */
7260
__pyx_L1_error:;
7261
__Pyx_XDECREF(__pyx_t_6);
7262
__Pyx_XDECREF(__pyx_t_7);
7263
__Pyx_XDECREF(__pyx_t_8);
7264
__Pyx_AddTraceback("sage.structure.element.parent", __pyx_clineno, __pyx_lineno, __pyx_filename);
7265
__pyx_r = 0;
7266
__pyx_L0:;
7267
__Pyx_XDECREF(__pyx_v_p);
7268
__Pyx_XGIVEREF(__pyx_r);
7269
__Pyx_RefNannyFinishContext();
7270
return __pyx_r;
7271
}
7272
7273
/* Python wrapper */
7274
static PyObject *__pyx_pw_4sage_9structure_7element_1parent(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/
7275
static char __pyx_doc_4sage_9structure_7element_parent[] = "File: (starting at line 7)\n\n Return the parent of the element ``x``.\n\n Usually, this means the mathematical object of which ``x`` is an\n element.\n\n INPUT:\n\n - ``x`` -- an element\n\n OUTPUT:\n\n - If ``x`` is a Sage :class:`Element`, return ``x.parent()``.\n\n - If ``x`` has a ``parent`` method and ``x`` does not have an\n ``__int__`` or ``__float__`` method, return ``x.parent()``.\n\n - Otherwise, return ``type(x)``.\n\n .. SEEALSO::\n\n `Parents, Conversion and Coercion <http://doc.sagemath.org/html/en/tutorial/tour_coercion.html>`_\n Section in the Sage Tutorial\n\n EXAMPLES::\n\n sage: a = 42\n sage: parent(a)\n Integer Ring\n sage: b = 42/1\n sage: parent(b)\n Rational Field\n sage: c = 42.0\n sage: parent(c)\n Real Field with 53 bits of precision\n\n Some more complicated examples::\n\n sage: x = Partition([3,2,1,1,1])\n sage: parent(x)\n Partitions\n sage: v = vector(RDF, [1,2,3])\n sage: parent(v)\n Vector space of dimension 3 over Real Double Field\n\n The following are not considered to be elements, so the type is\n returned::\n\n sage: d = int(42) # Python int\n sage: parent(d)\n <type 'int'>\n sage: L = list(range(10))\n sage: parent(L)\n <... 'list'>\n ";
7276
static PyObject *__pyx_pw_4sage_9structure_7element_1parent(PyObject *__pyx_self, PyObject *__pyx_v_x) {
7277
PyObject *__pyx_r = 0;
7278
__Pyx_RefNannyDeclarations
7279
__Pyx_RefNannySetupContext("parent (wrapper)", 0);
7280
__pyx_r = __pyx_pf_4sage_9structure_7element_parent(__pyx_self, ((PyObject *)__pyx_v_x));
7281
7282
/* function exit code */
7283
__Pyx_RefNannyFinishContext();
7284
return __pyx_r;
7285
}
7286
7287
static PyObject *__pyx_pf_4sage_9structure_7element_parent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x) {
7288
PyObject *__pyx_r = NULL;
7289
__Pyx_RefNannyDeclarations
7290
PyObject *__pyx_t_1 = NULL;
7291
__Pyx_RefNannySetupContext("parent", 0);
7292
__Pyx_XDECREF(__pyx_r);
7293
__pyx_t_1 = __pyx_f_4sage_9structure_7element_parent(__pyx_v_x, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
7294
__Pyx_GOTREF(__pyx_t_1);
7295
__pyx_r = __pyx_t_1;
7296
__pyx_t_1 = 0;
7297
goto __pyx_L0;
7298
7299
/* function exit code */
7300
__pyx_L1_error:;
7301
__Pyx_XDECREF(__pyx_t_1);
7302
__Pyx_AddTraceback("sage.structure.element.parent", __pyx_clineno, __pyx_lineno, __pyx_filename);
7303
__pyx_r = NULL;
7304
__pyx_L0:;
7305
__Pyx_XGIVEREF(__pyx_r);
7306
__Pyx_RefNannyFinishContext();
7307
return __pyx_r;
7308
}
7309
7310
/* "sage/structure/element.pxd":76
7311
*
7312
*
7313
* cdef inline int classify_elements(left, right): # <<<<<<<<<<<<<<
7314
* """
7315
* Given two objects, at least one which is an :class:`Element`,
7316
*/
7317
7318
static CYTHON_INLINE int __pyx_f_4sage_9structure_7element_classify_elements(PyObject *__pyx_v_left, PyObject *__pyx_v_right) {
7319
int __pyx_r;
7320
__Pyx_RefNannyDeclarations
7321
int __pyx_t_1;
7322
int __pyx_t_2;
7323
__Pyx_RefNannySetupContext("classify_elements", 0);
7324
7325
/* "sage/structure/element.pxd":99
7326
* - 0o37: both are Element, same type, same parent
7327
* """
7328
* if type(left) is type(right): # <<<<<<<<<<<<<<
7329
* # We know at least one of the arguments is an Element. So if
7330
* # their types are *equal* (fast to check) then they are both
7331
*/
7332
__pyx_t_1 = (((PyObject *)Py_TYPE(__pyx_v_left)) == ((PyObject *)Py_TYPE(__pyx_v_right)));
7333
__pyx_t_2 = (__pyx_t_1 != 0);
7334
if (__pyx_t_2) {
7335
7336
/* "sage/structure/element.pxd":103
7337
* # their types are *equal* (fast to check) then they are both
7338
* # Elements.
7339
* if (<Element>left)._parent is (<Element>right)._parent: # <<<<<<<<<<<<<<
7340
* return 0o37
7341
* else:
7342
*/
7343
__pyx_t_2 = (((struct __pyx_obj_4sage_9structure_7element_Element *)__pyx_v_left)->_parent == ((struct __pyx_obj_4sage_9structure_7element_Element *)__pyx_v_right)->_parent);
7344
__pyx_t_1 = (__pyx_t_2 != 0);
7345
if (__pyx_t_1) {
7346
7347
/* "sage/structure/element.pxd":104
7348
* # Elements.
7349
* if (<Element>left)._parent is (<Element>right)._parent:
7350
* return 0o37 # <<<<<<<<<<<<<<
7351
* else:
7352
* return 0o17
7353
*/
7354
__pyx_r = 037;
7355
goto __pyx_L0;
7356
7357
/* "sage/structure/element.pxd":103
7358
* # their types are *equal* (fast to check) then they are both
7359
* # Elements.
7360
* if (<Element>left)._parent is (<Element>right)._parent: # <<<<<<<<<<<<<<
7361
* return 0o37
7362
* else:
7363
*/
7364
}
7365
7366
/* "sage/structure/element.pxd":106
7367
* return 0o37
7368
* else:
7369
* return 0o17 # <<<<<<<<<<<<<<
7370
* if not isinstance(right, Element):
7371
* return 0o01
7372
*/
7373
/*else*/ {
7374
__pyx_r = 017;
7375
goto __pyx_L0;
7376
}
7377
7378
/* "sage/structure/element.pxd":99
7379
* - 0o37: both are Element, same type, same parent
7380
* """
7381
* if type(left) is type(right): # <<<<<<<<<<<<<<
7382
* # We know at least one of the arguments is an Element. So if
7383
* # their types are *equal* (fast to check) then they are both
7384
*/
7385
}
7386
7387
/* "sage/structure/element.pxd":107
7388
* else:
7389
* return 0o17
7390
* if not isinstance(right, Element): # <<<<<<<<<<<<<<
7391
* return 0o01
7392
* if not isinstance(left, Element):
7393
*/
7394
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_right, __pyx_ptype_4sage_9structure_7element_Element);
7395
__pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
7396
if (__pyx_t_2) {
7397
7398
/* "sage/structure/element.pxd":108
7399
* return 0o17
7400
* if not isinstance(right, Element):
7401
* return 0o01 # <<<<<<<<<<<<<<
7402
* if not isinstance(left, Element):
7403
* return 0o02
7404
*/
7405
__pyx_r = 001;
7406
goto __pyx_L0;
7407
7408
/* "sage/structure/element.pxd":107
7409
* else:
7410
* return 0o17
7411
* if not isinstance(right, Element): # <<<<<<<<<<<<<<
7412
* return 0o01
7413
* if not isinstance(left, Element):
7414
*/
7415
}
7416
7417
/* "sage/structure/element.pxd":109
7418
* if not isinstance(right, Element):
7419
* return 0o01
7420
* if not isinstance(left, Element): # <<<<<<<<<<<<<<
7421
* return 0o02
7422
* if (<Element>left)._parent is (<Element>right)._parent:
7423
*/
7424
__pyx_t_2 = __Pyx_TypeCheck(__pyx_v_left, __pyx_ptype_4sage_9structure_7element_Element);
7425
__pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
7426
if (__pyx_t_1) {
7427
7428
/* "sage/structure/element.pxd":110
7429
* return 0o01
7430
* if not isinstance(left, Element):
7431
* return 0o02 # <<<<<<<<<<<<<<
7432
* if (<Element>left)._parent is (<Element>right)._parent:
7433
* return 0o27
7434
*/
7435
__pyx_r = 002;
7436
goto __pyx_L0;
7437
7438
/* "sage/structure/element.pxd":109
7439
* if not isinstance(right, Element):
7440
* return 0o01
7441
* if not isinstance(left, Element): # <<<<<<<<<<<<<<
7442
* return 0o02
7443
* if (<Element>left)._parent is (<Element>right)._parent:
7444
*/
7445
}
7446
7447
/* "sage/structure/element.pxd":111
7448
* if not isinstance(left, Element):
7449
* return 0o02
7450
* if (<Element>left)._parent is (<Element>right)._parent: # <<<<<<<<<<<<<<
7451
* return 0o27
7452
* else:
7453
*/
7454
__pyx_t_1 = (((struct __pyx_obj_4sage_9structure_7element_Element *)__pyx_v_left)->_parent == ((struct __pyx_obj_4sage_9structure_7element_Element *)__pyx_v_right)->_parent);
7455
__pyx_t_2 = (__pyx_t_1 != 0);
7456
if (__pyx_t_2) {
7457
7458
/* "sage/structure/element.pxd":112
7459
* return 0o02
7460
* if (<Element>left)._parent is (<Element>right)._parent:
7461
* return 0o27 # <<<<<<<<<<<<<<
7462
* else:
7463
* return 0o07
7464
*/
7465
__pyx_r = 027;
7466
goto __pyx_L0;
7467
7468
/* "sage/structure/element.pxd":111
7469
* if not isinstance(left, Element):
7470
* return 0o02
7471
* if (<Element>left)._parent is (<Element>right)._parent: # <<<<<<<<<<<<<<
7472
* return 0o27
7473
* else:
7474
*/
7475
}
7476
7477
/* "sage/structure/element.pxd":114
7478
* return 0o27
7479
* else:
7480
* return 0o07 # <<<<<<<<<<<<<<
7481
*
7482
* # Functions to help understand the result of classify_elements()
7483
*/
7484
/*else*/ {
7485
__pyx_r = 007;
7486
goto __pyx_L0;
7487
}
7488
7489
/* "sage/structure/element.pxd":76
7490
*
7491
*
7492
* cdef inline int classify_elements(left, right): # <<<<<<<<<<<<<<
7493
* """
7494
* Given two objects, at least one which is an :class:`Element`,
7495
*/
7496
7497
/* function exit code */
7498
__pyx_L0:;
7499
__Pyx_RefNannyFinishContext();
7500
return __pyx_r;
7501
}
7502
7503
/* "sage/structure/element.pxd":117
7504
*
7505
* # Functions to help understand the result of classify_elements()
7506
* cdef inline bint BOTH_ARE_ELEMENT(int cl): # <<<<<<<<<<<<<<
7507
* return cl & 0o04
7508
* cdef inline bint HAVE_SAME_PARENT(int cl):
7509
*/
7510
7511
static CYTHON_INLINE int __pyx_f_4sage_9structure_7element_BOTH_ARE_ELEMENT(int __pyx_v_cl) {
7512
int __pyx_r;
7513
__Pyx_RefNannyDeclarations
7514
__Pyx_RefNannySetupContext("BOTH_ARE_ELEMENT", 0);
7515
7516
/* "sage/structure/element.pxd":118
7517
* # Functions to help understand the result of classify_elements()
7518
* cdef inline bint BOTH_ARE_ELEMENT(int cl):
7519
* return cl & 0o04 # <<<<<<<<<<<<<<
7520
* cdef inline bint HAVE_SAME_PARENT(int cl):
7521
* return cl & 0o20
7522
*/
7523
__pyx_r = (__pyx_v_cl & 004);
7524
goto __pyx_L0;
7525
7526
/* "sage/structure/element.pxd":117
7527
*
7528
* # Functions to help understand the result of classify_elements()
7529
* cdef inline bint BOTH_ARE_ELEMENT(int cl): # <<<<<<<<<<<<<<
7530
* return cl & 0o04
7531
* cdef inline bint HAVE_SAME_PARENT(int cl):
7532
*/
7533
7534
/* function exit code */
7535
__pyx_L0:;
7536
__Pyx_RefNannyFinishContext();
7537
return __pyx_r;
7538
}
7539
7540
/* "sage/structure/element.pxd":119
7541
* cdef inline bint BOTH_ARE_ELEMENT(int cl):
7542
* return cl & 0o04
7543
* cdef inline bint HAVE_SAME_PARENT(int cl): # <<<<<<<<<<<<<<
7544
* return cl & 0o20
7545
*
7546
*/
7547
7548
static CYTHON_INLINE int __pyx_f_4sage_9structure_7element_HAVE_SAME_PARENT(int __pyx_v_cl) {
7549
int __pyx_r;
7550
__Pyx_RefNannyDeclarations
7551
__Pyx_RefNannySetupContext("HAVE_SAME_PARENT", 0);
7552
7553
/* "sage/structure/element.pxd":120
7554
* return cl & 0o04
7555
* cdef inline bint HAVE_SAME_PARENT(int cl):
7556
* return cl & 0o20 # <<<<<<<<<<<<<<
7557
*
7558
*
7559
*/
7560
__pyx_r = (__pyx_v_cl & 020);
7561
goto __pyx_L0;
7562
7563
/* "sage/structure/element.pxd":119
7564
* cdef inline bint BOTH_ARE_ELEMENT(int cl):
7565
* return cl & 0o04
7566
* cdef inline bint HAVE_SAME_PARENT(int cl): # <<<<<<<<<<<<<<
7567
* return cl & 0o20
7568
*
7569
*/
7570
7571
/* function exit code */
7572
__pyx_L0:;
7573
__Pyx_RefNannyFinishContext();
7574
return __pyx_r;
7575
}
7576
7577
/* "sage/structure/element.pxd":123
7578
*
7579
*
7580
* cpdef inline bint have_same_parent(left, right): # <<<<<<<<<<<<<<
7581
* """
7582
* Return ``True`` if and only if ``left`` and ``right`` have the
7583
*/
7584
7585
static PyObject *__pyx_pw_4sage_9structure_7element_3have_same_parent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
7586
static CYTHON_INLINE int __pyx_f_4sage_9structure_7element_have_same_parent(PyObject *__pyx_v_left, PyObject *__pyx_v_right, CYTHON_UNUSED int __pyx_skip_dispatch) {
7587
int __pyx_r;
7588
__Pyx_RefNannyDeclarations
7589
__Pyx_RefNannySetupContext("have_same_parent", 0);
7590
7591
/* "sage/structure/element.pxd":155
7592
* True
7593
* """
7594
* return HAVE_SAME_PARENT(classify_elements(left, right)) # <<<<<<<<<<<<<<
7595
*
7596
*
7597
*/
7598
__pyx_r = __pyx_f_4sage_9structure_7element_HAVE_SAME_PARENT(__pyx_f_4sage_9structure_7element_classify_elements(__pyx_v_left, __pyx_v_right));
7599
goto __pyx_L0;
7600
7601
/* "sage/structure/element.pxd":123
7602
*
7603
*
7604
* cpdef inline bint have_same_parent(left, right): # <<<<<<<<<<<<<<
7605
* """
7606
* Return ``True`` if and only if ``left`` and ``right`` have the
7607
*/
7608
7609
/* function exit code */
7610
__pyx_L0:;
7611
__Pyx_RefNannyFinishContext();
7612
return __pyx_r;
7613
}
7614
7615
/* Python wrapper */
7616
static PyObject *__pyx_pw_4sage_9structure_7element_3have_same_parent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
7617
static char __pyx_doc_4sage_9structure_7element_2have_same_parent[] = "File: (starting at line 123)\n\n Return ``True`` if and only if ``left`` and ``right`` have the\n same parent.\n\n .. WARNING::\n\n This function assumes that at least one of the arguments is a\n Sage :class:`Element`. When in doubt, use the slower\n ``parent(left) is parent(right)`` instead.\n\n EXAMPLES::\n\n sage: from sage.structure.element import have_same_parent\n sage: have_same_parent(1, 3)\n True\n sage: have_same_parent(1, 1/2)\n False\n sage: have_same_parent(gap(1), gap(1/2))\n True\n\n These have different types but the same parent::\n\n sage: a = RLF(2)\n sage: b = exp(a)\n sage: type(a)\n <type 'sage.rings.real_lazy.LazyWrapper'>\n sage: type(b)\n <type 'sage.rings.real_lazy.LazyNamedUnop'>\n sage: have_same_parent(a, b)\n True\n ";
7618
static PyObject *__pyx_pw_4sage_9structure_7element_3have_same_parent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7619
PyObject *__pyx_v_left = 0;
7620
PyObject *__pyx_v_right = 0;
7621
PyObject *__pyx_r = 0;
7622
__Pyx_RefNannyDeclarations
7623
__Pyx_RefNannySetupContext("have_same_parent (wrapper)", 0);
7624
{
7625
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_left,&__pyx_n_s_right,0};
7626
PyObject* values[2] = {0,0};
7627
if (unlikely(__pyx_kwds)) {
7628
Py_ssize_t kw_args;
7629
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7630
switch (pos_args) {
7631
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7632
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7633
case 0: break;
7634
default: goto __pyx_L5_argtuple_error;
7635
}
7636
kw_args = PyDict_Size(__pyx_kwds);
7637
switch (pos_args) {
7638
case 0:
7639
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_left)) != 0)) kw_args--;
7640
else goto __pyx_L5_argtuple_error;
7641
case 1:
7642
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_right)) != 0)) kw_args--;
7643
else {
7644
__Pyx_RaiseArgtupleInvalid("have_same_parent", 1, 2, 2, 1); __PYX_ERR(1, 123, __pyx_L3_error)
7645
}
7646
}
7647
if (unlikely(kw_args > 0)) {
7648
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "have_same_parent") < 0)) __PYX_ERR(1, 123, __pyx_L3_error)
7649
}
7650
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
7651
goto __pyx_L5_argtuple_error;
7652
} else {
7653
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7654
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7655
}
7656
__pyx_v_left = values[0];
7657
__pyx_v_right = values[1];
7658
}
7659
goto __pyx_L4_argument_unpacking_done;
7660
__pyx_L5_argtuple_error:;
7661
__Pyx_RaiseArgtupleInvalid("have_same_parent", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 123, __pyx_L3_error)
7662
__pyx_L3_error:;
7663
__Pyx_AddTraceback("sage.structure.element.have_same_parent", __pyx_clineno, __pyx_lineno, __pyx_filename);
7664
__Pyx_RefNannyFinishContext();
7665
return NULL;
7666
__pyx_L4_argument_unpacking_done:;
7667
__pyx_r = __pyx_pf_4sage_9structure_7element_2have_same_parent(__pyx_self, __pyx_v_left, __pyx_v_right);
7668
7669
/* function exit code */
7670
__Pyx_RefNannyFinishContext();
7671
return __pyx_r;
7672
}
7673
7674
static PyObject *__pyx_pf_4sage_9structure_7element_2have_same_parent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_left, PyObject *__pyx_v_right) {
7675
PyObject *__pyx_r = NULL;
7676
__Pyx_RefNannyDeclarations
7677
PyObject *__pyx_t_1 = NULL;
7678
__Pyx_RefNannySetupContext("have_same_parent", 0);
7679
__Pyx_XDECREF(__pyx_r);
7680
__pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_4sage_9structure_7element_have_same_parent(__pyx_v_left, __pyx_v_right, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 123, __pyx_L1_error)
7681
__Pyx_GOTREF(__pyx_t_1);
7682
__pyx_r = __pyx_t_1;
7683
__pyx_t_1 = 0;
7684
goto __pyx_L0;
7685
7686
/* function exit code */
7687
__pyx_L1_error:;
7688
__Pyx_XDECREF(__pyx_t_1);
7689
__Pyx_AddTraceback("sage.structure.element.have_same_parent", __pyx_clineno, __pyx_lineno, __pyx_filename);
7690
__pyx_r = NULL;
7691
__pyx_L0:;
7692
__Pyx_XGIVEREF(__pyx_r);
7693
__Pyx_RefNannyFinishContext();
7694
return __pyx_r;
7695
}
7696
7697
/* "sage/structure/element.pxd":158
7698
*
7699
*
7700
* cdef inline parent_c(x): # <<<<<<<<<<<<<<
7701
* """
7702
* Deprecated alias for :func:`parent`.
7703
*/
7704
7705
static CYTHON_INLINE PyObject *__pyx_f_4sage_9structure_7element_parent_c(PyObject *__pyx_v_x) {
7706
PyObject *__pyx_r = NULL;
7707
__Pyx_RefNannyDeclarations
7708
PyObject *__pyx_t_1 = NULL;
7709
__Pyx_RefNannySetupContext("parent_c", 0);
7710
7711
/* "sage/structure/element.pxd":162
7712
* Deprecated alias for :func:`parent`.
7713
* """
7714
* return parent(x) # <<<<<<<<<<<<<<
7715
*
7716
*
7717
*/
7718
__Pyx_XDECREF(__pyx_r);
7719
__pyx_t_1 = __pyx_f_4sage_9structure_7element_parent(__pyx_v_x, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 162, __pyx_L1_error)
7720
__Pyx_GOTREF(__pyx_t_1);
7721
__pyx_r = __pyx_t_1;
7722
__pyx_t_1 = 0;
7723
goto __pyx_L0;
7724
7725
/* "sage/structure/element.pxd":158
7726
*
7727
*
7728
* cdef inline parent_c(x): # <<<<<<<<<<<<<<
7729
* """
7730
* Deprecated alias for :func:`parent`.
7731
*/
7732
7733
/* function exit code */
7734
__pyx_L1_error:;
7735
__Pyx_XDECREF(__pyx_t_1);
7736
__Pyx_AddTraceback("sage.structure.element.parent_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
7737
__pyx_r = 0;
7738
__pyx_L0:;
7739
__Pyx_XGIVEREF(__pyx_r);
7740
__Pyx_RefNannyFinishContext();
7741
return __pyx_r;
7742
}
7743
7744
/* "cysignals/memory.pxd":40
7745
*
7746
*
7747
* cdef inline void* sig_malloc "sig_malloc"(size_t n) nogil: # <<<<<<<<<<<<<<
7748
* sig_block()
7749
* cdef void* ret = malloc(n)
7750
*/
7751
7752
static CYTHON_INLINE void *sig_malloc(size_t __pyx_v_n) {
7753
void *__pyx_v_ret;
7754
void *__pyx_r;
7755
7756
/* "cysignals/memory.pxd":41
7757
*
7758
* cdef inline void* sig_malloc "sig_malloc"(size_t n) nogil:
7759
* sig_block() # <<<<<<<<<<<<<<
7760
* cdef void* ret = malloc(n)
7761
* sig_unblock()
7762
*/
7763
sig_block();
7764
7765
/* "cysignals/memory.pxd":42
7766
* cdef inline void* sig_malloc "sig_malloc"(size_t n) nogil:
7767
* sig_block()
7768
* cdef void* ret = malloc(n) # <<<<<<<<<<<<<<
7769
* sig_unblock()
7770
* return ret
7771
*/
7772
__pyx_v_ret = malloc(__pyx_v_n);
7773
7774
/* "cysignals/memory.pxd":43
7775
* sig_block()
7776
* cdef void* ret = malloc(n)
7777
* sig_unblock() # <<<<<<<<<<<<<<
7778
* return ret
7779
*
7780
*/
7781
sig_unblock();
7782
7783
/* "cysignals/memory.pxd":44
7784
* cdef void* ret = malloc(n)
7785
* sig_unblock()
7786
* return ret # <<<<<<<<<<<<<<
7787
*
7788
*
7789
*/
7790
__pyx_r = __pyx_v_ret;
7791
goto __pyx_L0;
7792
7793
/* "cysignals/memory.pxd":40
7794
*
7795
*
7796
* cdef inline void* sig_malloc "sig_malloc"(size_t n) nogil: # <<<<<<<<<<<<<<
7797
* sig_block()
7798
* cdef void* ret = malloc(n)
7799
*/
7800
7801
/* function exit code */
7802
__pyx_L0:;
7803
return __pyx_r;
7804
}
7805
7806
/* "cysignals/memory.pxd":47
7807
*
7808
*
7809
* cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) nogil: # <<<<<<<<<<<<<<
7810
* sig_block()
7811
* cdef void* ret = realloc(ptr, size)
7812
*/
7813
7814
static CYTHON_INLINE void *sig_realloc(void *__pyx_v_ptr, size_t __pyx_v_size) {
7815
void *__pyx_v_ret;
7816
void *__pyx_r;
7817
7818
/* "cysignals/memory.pxd":48
7819
*
7820
* cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) nogil:
7821
* sig_block() # <<<<<<<<<<<<<<
7822
* cdef void* ret = realloc(ptr, size)
7823
* sig_unblock()
7824
*/
7825
sig_block();
7826
7827
/* "cysignals/memory.pxd":49
7828
* cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) nogil:
7829
* sig_block()
7830
* cdef void* ret = realloc(ptr, size) # <<<<<<<<<<<<<<
7831
* sig_unblock()
7832
* return ret
7833
*/
7834
__pyx_v_ret = realloc(__pyx_v_ptr, __pyx_v_size);
7835
7836
/* "cysignals/memory.pxd":50
7837
* sig_block()
7838
* cdef void* ret = realloc(ptr, size)
7839
* sig_unblock() # <<<<<<<<<<<<<<
7840
* return ret
7841
*
7842
*/
7843
sig_unblock();
7844
7845
/* "cysignals/memory.pxd":51
7846
* cdef void* ret = realloc(ptr, size)
7847
* sig_unblock()
7848
* return ret # <<<<<<<<<<<<<<
7849
*
7850
*
7851
*/
7852
__pyx_r = __pyx_v_ret;
7853
goto __pyx_L0;
7854
7855
/* "cysignals/memory.pxd":47
7856
*
7857
*
7858
* cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) nogil: # <<<<<<<<<<<<<<
7859
* sig_block()
7860
* cdef void* ret = realloc(ptr, size)
7861
*/
7862
7863
/* function exit code */
7864
__pyx_L0:;
7865
return __pyx_r;
7866
}
7867
7868
/* "cysignals/memory.pxd":54
7869
*
7870
*
7871
* cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) nogil: # <<<<<<<<<<<<<<
7872
* sig_block()
7873
* cdef void* ret = calloc(nmemb, size)
7874
*/
7875
7876
static CYTHON_INLINE void *sig_calloc(size_t __pyx_v_nmemb, size_t __pyx_v_size) {
7877
void *__pyx_v_ret;
7878
void *__pyx_r;
7879
7880
/* "cysignals/memory.pxd":55
7881
*
7882
* cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) nogil:
7883
* sig_block() # <<<<<<<<<<<<<<
7884
* cdef void* ret = calloc(nmemb, size)
7885
* sig_unblock()
7886
*/
7887
sig_block();
7888
7889
/* "cysignals/memory.pxd":56
7890
* cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) nogil:
7891
* sig_block()
7892
* cdef void* ret = calloc(nmemb, size) # <<<<<<<<<<<<<<
7893
* sig_unblock()
7894
* return ret
7895
*/
7896
__pyx_v_ret = calloc(__pyx_v_nmemb, __pyx_v_size);
7897
7898
/* "cysignals/memory.pxd":57
7899
* sig_block()
7900
* cdef void* ret = calloc(nmemb, size)
7901
* sig_unblock() # <<<<<<<<<<<<<<
7902
* return ret
7903
*
7904
*/
7905
sig_unblock();
7906
7907
/* "cysignals/memory.pxd":58
7908
* cdef void* ret = calloc(nmemb, size)
7909
* sig_unblock()
7910
* return ret # <<<<<<<<<<<<<<
7911
*
7912
*
7913
*/
7914
__pyx_r = __pyx_v_ret;
7915
goto __pyx_L0;
7916
7917
/* "cysignals/memory.pxd":54
7918
*
7919
*
7920
* cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) nogil: # <<<<<<<<<<<<<<
7921
* sig_block()
7922
* cdef void* ret = calloc(nmemb, size)
7923
*/
7924
7925
/* function exit code */
7926
__pyx_L0:;
7927
return __pyx_r;
7928
}
7929
7930
/* "cysignals/memory.pxd":61
7931
*
7932
*
7933
* cdef inline void sig_free "sig_free"(void* ptr) nogil: # <<<<<<<<<<<<<<
7934
* sig_block()
7935
* free(ptr)
7936
*/
7937
7938
static CYTHON_INLINE void sig_free(void *__pyx_v_ptr) {
7939
7940
/* "cysignals/memory.pxd":62
7941
*
7942
* cdef inline void sig_free "sig_free"(void* ptr) nogil:
7943
* sig_block() # <<<<<<<<<<<<<<
7944
* free(ptr)
7945
* sig_unblock()
7946
*/
7947
sig_block();
7948
7949
/* "cysignals/memory.pxd":63
7950
* cdef inline void sig_free "sig_free"(void* ptr) nogil:
7951
* sig_block()
7952
* free(ptr) # <<<<<<<<<<<<<<
7953
* sig_unblock()
7954
*
7955
*/
7956
free(__pyx_v_ptr);
7957
7958
/* "cysignals/memory.pxd":64
7959
* sig_block()
7960
* free(ptr)
7961
* sig_unblock() # <<<<<<<<<<<<<<
7962
*
7963
*
7964
*/
7965
sig_unblock();
7966
7967
/* "cysignals/memory.pxd":61
7968
*
7969
*
7970
* cdef inline void sig_free "sig_free"(void* ptr) nogil: # <<<<<<<<<<<<<<
7971
* sig_block()
7972
* free(ptr)
7973
*/
7974
7975
/* function exit code */
7976
}
7977
7978
/* "cysignals/memory.pxd":68
7979
*
7980
* @cython.cdivision(True)
7981
* cdef inline size_t mul_overflowcheck(size_t a, size_t b) nogil: # <<<<<<<<<<<<<<
7982
* """
7983
* Return a*b, checking for overflow. Assume that a > 0.
7984
*/
7985
7986
static CYTHON_INLINE size_t __pyx_f_9cysignals_6memory_mul_overflowcheck(size_t __pyx_v_a, size_t __pyx_v_b) {
7987
size_t __pyx_v_MUL_NO_OVERFLOW;
7988
size_t __pyx_r;
7989
int __pyx_t_1;
7990
int __pyx_t_2;
7991
7992
/* "cysignals/memory.pxd":75
7993
* """
7994
* # If a and b both less than MUL_NO_OVERFLOW, no overflow can occur
7995
* cdef size_t MUL_NO_OVERFLOW = ((<size_t>1) << (4*sizeof(size_t))) # <<<<<<<<<<<<<<
7996
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW:
7997
* if unlikely(b > (<size_t>-1) // a):
7998
*/
7999
__pyx_v_MUL_NO_OVERFLOW = (((size_t)1) << (4 * (sizeof(size_t))));
8000
8001
/* "cysignals/memory.pxd":76
8002
* # If a and b both less than MUL_NO_OVERFLOW, no overflow can occur
8003
* cdef size_t MUL_NO_OVERFLOW = ((<size_t>1) << (4*sizeof(size_t)))
8004
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW: # <<<<<<<<<<<<<<
8005
* if unlikely(b > (<size_t>-1) // a):
8006
* return <size_t>(-1)
8007
*/
8008
__pyx_t_2 = ((__pyx_v_a >= __pyx_v_MUL_NO_OVERFLOW) != 0);
8009
if (!__pyx_t_2) {
8010
} else {
8011
__pyx_t_1 = __pyx_t_2;
8012
goto __pyx_L4_bool_binop_done;
8013
}
8014
__pyx_t_2 = ((__pyx_v_b >= __pyx_v_MUL_NO_OVERFLOW) != 0);
8015
__pyx_t_1 = __pyx_t_2;
8016
__pyx_L4_bool_binop_done:;
8017
if (__pyx_t_1) {
8018
8019
/* "cysignals/memory.pxd":77
8020
* cdef size_t MUL_NO_OVERFLOW = ((<size_t>1) << (4*sizeof(size_t)))
8021
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW:
8022
* if unlikely(b > (<size_t>-1) // a): # <<<<<<<<<<<<<<
8023
* return <size_t>(-1)
8024
* return a*b
8025
*/
8026
__pyx_t_1 = (unlikely((__pyx_v_b > (((size_t)-1L) / __pyx_v_a))) != 0);
8027
if (__pyx_t_1) {
8028
8029
/* "cysignals/memory.pxd":78
8030
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW:
8031
* if unlikely(b > (<size_t>-1) // a):
8032
* return <size_t>(-1) # <<<<<<<<<<<<<<
8033
* return a*b
8034
*
8035
*/
8036
__pyx_r = ((size_t)-1L);
8037
goto __pyx_L0;
8038
8039
/* "cysignals/memory.pxd":77
8040
* cdef size_t MUL_NO_OVERFLOW = ((<size_t>1) << (4*sizeof(size_t)))
8041
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW:
8042
* if unlikely(b > (<size_t>-1) // a): # <<<<<<<<<<<<<<
8043
* return <size_t>(-1)
8044
* return a*b
8045
*/
8046
}
8047
8048
/* "cysignals/memory.pxd":76
8049
* # If a and b both less than MUL_NO_OVERFLOW, no overflow can occur
8050
* cdef size_t MUL_NO_OVERFLOW = ((<size_t>1) << (4*sizeof(size_t)))
8051
* if a >= MUL_NO_OVERFLOW or b >= MUL_NO_OVERFLOW: # <<<<<<<<<<<<<<
8052
* if unlikely(b > (<size_t>-1) // a):
8053
* return <size_t>(-1)
8054
*/
8055
}
8056
8057
/* "cysignals/memory.pxd":79
8058
* if unlikely(b > (<size_t>-1) // a):
8059
* return <size_t>(-1)
8060
* return a*b # <<<<<<<<<<<<<<
8061
*
8062
*
8063
*/
8064
__pyx_r = (__pyx_v_a * __pyx_v_b);
8065
goto __pyx_L0;
8066
8067
/* "cysignals/memory.pxd":68
8068
*
8069
* @cython.cdivision(True)
8070
* cdef inline size_t mul_overflowcheck(size_t a, size_t b) nogil: # <<<<<<<<<<<<<<
8071
* """
8072
* Return a*b, checking for overflow. Assume that a > 0.
8073
*/
8074
8075
/* function exit code */
8076
__pyx_L0:;
8077
return __pyx_r;
8078
}
8079
8080
/* "cysignals/memory.pxd":82
8081
*
8082
*
8083
* cdef inline void* check_allocarray(size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
8084
* """
8085
* Allocate memory for ``nmemb`` elements of size ``size``.
8086
*/
8087
8088
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_allocarray(size_t __pyx_v_nmemb, size_t __pyx_v_size) {
8089
size_t __pyx_v_n;
8090
void *__pyx_v_ret;
8091
void *__pyx_r;
8092
__Pyx_RefNannyDeclarations
8093
int __pyx_t_1;
8094
PyObject *__pyx_t_2 = NULL;
8095
PyObject *__pyx_t_3 = NULL;
8096
PyObject *__pyx_t_4 = NULL;
8097
__Pyx_RefNannySetupContext("check_allocarray", 0);
8098
8099
/* "cysignals/memory.pxd":86
8100
* Allocate memory for ``nmemb`` elements of size ``size``.
8101
* """
8102
* if nmemb == 0: # <<<<<<<<<<<<<<
8103
* return NULL
8104
* cdef size_t n = mul_overflowcheck(nmemb, size)
8105
*/
8106
__pyx_t_1 = ((__pyx_v_nmemb == 0) != 0);
8107
if (__pyx_t_1) {
8108
8109
/* "cysignals/memory.pxd":87
8110
* """
8111
* if nmemb == 0:
8112
* return NULL # <<<<<<<<<<<<<<
8113
* cdef size_t n = mul_overflowcheck(nmemb, size)
8114
* cdef void* ret = sig_malloc(n)
8115
*/
8116
__pyx_r = NULL;
8117
goto __pyx_L0;
8118
8119
/* "cysignals/memory.pxd":86
8120
* Allocate memory for ``nmemb`` elements of size ``size``.
8121
* """
8122
* if nmemb == 0: # <<<<<<<<<<<<<<
8123
* return NULL
8124
* cdef size_t n = mul_overflowcheck(nmemb, size)
8125
*/
8126
}
8127
8128
/* "cysignals/memory.pxd":88
8129
* if nmemb == 0:
8130
* return NULL
8131
* cdef size_t n = mul_overflowcheck(nmemb, size) # <<<<<<<<<<<<<<
8132
* cdef void* ret = sig_malloc(n)
8133
* if unlikely(ret == NULL):
8134
*/
8135
__pyx_v_n = __pyx_f_9cysignals_6memory_mul_overflowcheck(__pyx_v_nmemb, __pyx_v_size);
8136
8137
/* "cysignals/memory.pxd":89
8138
* return NULL
8139
* cdef size_t n = mul_overflowcheck(nmemb, size)
8140
* cdef void* ret = sig_malloc(n) # <<<<<<<<<<<<<<
8141
* if unlikely(ret == NULL):
8142
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8143
*/
8144
__pyx_v_ret = sig_malloc(__pyx_v_n);
8145
8146
/* "cysignals/memory.pxd":90
8147
* cdef size_t n = mul_overflowcheck(nmemb, size)
8148
* cdef void* ret = sig_malloc(n)
8149
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
8150
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8151
* return ret
8152
*/
8153
__pyx_t_1 = (unlikely((__pyx_v_ret == NULL)) != 0);
8154
if (__pyx_t_1) {
8155
8156
/* "cysignals/memory.pxd":91
8157
* cdef void* ret = sig_malloc(n)
8158
* if unlikely(ret == NULL):
8159
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size)) # <<<<<<<<<<<<<<
8160
* return ret
8161
*
8162
*/
8163
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_nmemb); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 91, __pyx_L1_error)
8164
__Pyx_GOTREF(__pyx_t_2);
8165
__pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 91, __pyx_L1_error)
8166
__Pyx_GOTREF(__pyx_t_3);
8167
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 91, __pyx_L1_error)
8168
__Pyx_GOTREF(__pyx_t_4);
8169
__Pyx_GIVEREF(__pyx_t_2);
8170
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
8171
__Pyx_GIVEREF(__pyx_t_3);
8172
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
8173
__pyx_t_2 = 0;
8174
__pyx_t_3 = 0;
8175
__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)
8176
__Pyx_GOTREF(__pyx_t_3);
8177
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8178
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 91, __pyx_L1_error)
8179
__Pyx_GOTREF(__pyx_t_4);
8180
__Pyx_GIVEREF(__pyx_t_3);
8181
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
8182
__pyx_t_3 = 0;
8183
__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)
8184
__Pyx_GOTREF(__pyx_t_3);
8185
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8186
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
8187
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8188
__PYX_ERR(2, 91, __pyx_L1_error)
8189
8190
/* "cysignals/memory.pxd":90
8191
* cdef size_t n = mul_overflowcheck(nmemb, size)
8192
* cdef void* ret = sig_malloc(n)
8193
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
8194
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8195
* return ret
8196
*/
8197
}
8198
8199
/* "cysignals/memory.pxd":92
8200
* if unlikely(ret == NULL):
8201
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8202
* return ret # <<<<<<<<<<<<<<
8203
*
8204
*
8205
*/
8206
__pyx_r = __pyx_v_ret;
8207
goto __pyx_L0;
8208
8209
/* "cysignals/memory.pxd":82
8210
*
8211
*
8212
* cdef inline void* check_allocarray(size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
8213
* """
8214
* Allocate memory for ``nmemb`` elements of size ``size``.
8215
*/
8216
8217
/* function exit code */
8218
__pyx_L1_error:;
8219
__Pyx_XDECREF(__pyx_t_2);
8220
__Pyx_XDECREF(__pyx_t_3);
8221
__Pyx_XDECREF(__pyx_t_4);
8222
__Pyx_AddTraceback("cysignals.memory.check_allocarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
8223
__pyx_r = NULL;
8224
__pyx_L0:;
8225
__Pyx_RefNannyFinishContext();
8226
return __pyx_r;
8227
}
8228
8229
/* "cysignals/memory.pxd":95
8230
*
8231
*
8232
* cdef inline void* check_reallocarray(void* ptr, size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
8233
* """
8234
* Re-allocate memory at ``ptr`` to hold ``nmemb`` elements of size
8235
*/
8236
8237
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_reallocarray(void *__pyx_v_ptr, size_t __pyx_v_nmemb, size_t __pyx_v_size) {
8238
size_t __pyx_v_n;
8239
void *__pyx_v_ret;
8240
void *__pyx_r;
8241
__Pyx_RefNannyDeclarations
8242
int __pyx_t_1;
8243
PyObject *__pyx_t_2 = NULL;
8244
PyObject *__pyx_t_3 = NULL;
8245
PyObject *__pyx_t_4 = NULL;
8246
__Pyx_RefNannySetupContext("check_reallocarray", 0);
8247
8248
/* "cysignals/memory.pxd":103
8249
* When ``nmemb`` equals 0, then free the memory at ``ptr``.
8250
* """
8251
* if nmemb == 0: # <<<<<<<<<<<<<<
8252
* sig_free(ptr)
8253
* return NULL
8254
*/
8255
__pyx_t_1 = ((__pyx_v_nmemb == 0) != 0);
8256
if (__pyx_t_1) {
8257
8258
/* "cysignals/memory.pxd":104
8259
* """
8260
* if nmemb == 0:
8261
* sig_free(ptr) # <<<<<<<<<<<<<<
8262
* return NULL
8263
* cdef size_t n = mul_overflowcheck(nmemb, size)
8264
*/
8265
sig_free(__pyx_v_ptr);
8266
8267
/* "cysignals/memory.pxd":105
8268
* if nmemb == 0:
8269
* sig_free(ptr)
8270
* return NULL # <<<<<<<<<<<<<<
8271
* cdef size_t n = mul_overflowcheck(nmemb, size)
8272
* cdef void* ret = sig_realloc(ptr, n)
8273
*/
8274
__pyx_r = NULL;
8275
goto __pyx_L0;
8276
8277
/* "cysignals/memory.pxd":103
8278
* When ``nmemb`` equals 0, then free the memory at ``ptr``.
8279
* """
8280
* if nmemb == 0: # <<<<<<<<<<<<<<
8281
* sig_free(ptr)
8282
* return NULL
8283
*/
8284
}
8285
8286
/* "cysignals/memory.pxd":106
8287
* sig_free(ptr)
8288
* return NULL
8289
* cdef size_t n = mul_overflowcheck(nmemb, size) # <<<<<<<<<<<<<<
8290
* cdef void* ret = sig_realloc(ptr, n)
8291
* if unlikely(ret == NULL):
8292
*/
8293
__pyx_v_n = __pyx_f_9cysignals_6memory_mul_overflowcheck(__pyx_v_nmemb, __pyx_v_size);
8294
8295
/* "cysignals/memory.pxd":107
8296
* return NULL
8297
* cdef size_t n = mul_overflowcheck(nmemb, size)
8298
* cdef void* ret = sig_realloc(ptr, n) # <<<<<<<<<<<<<<
8299
* if unlikely(ret == NULL):
8300
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8301
*/
8302
__pyx_v_ret = sig_realloc(__pyx_v_ptr, __pyx_v_n);
8303
8304
/* "cysignals/memory.pxd":108
8305
* cdef size_t n = mul_overflowcheck(nmemb, size)
8306
* cdef void* ret = sig_realloc(ptr, n)
8307
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
8308
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8309
* return ret
8310
*/
8311
__pyx_t_1 = (unlikely((__pyx_v_ret == NULL)) != 0);
8312
if (__pyx_t_1) {
8313
8314
/* "cysignals/memory.pxd":109
8315
* cdef void* ret = sig_realloc(ptr, n)
8316
* if unlikely(ret == NULL):
8317
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size)) # <<<<<<<<<<<<<<
8318
* return ret
8319
*
8320
*/
8321
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_nmemb); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 109, __pyx_L1_error)
8322
__Pyx_GOTREF(__pyx_t_2);
8323
__pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 109, __pyx_L1_error)
8324
__Pyx_GOTREF(__pyx_t_3);
8325
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 109, __pyx_L1_error)
8326
__Pyx_GOTREF(__pyx_t_4);
8327
__Pyx_GIVEREF(__pyx_t_2);
8328
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
8329
__Pyx_GIVEREF(__pyx_t_3);
8330
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
8331
__pyx_t_2 = 0;
8332
__pyx_t_3 = 0;
8333
__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)
8334
__Pyx_GOTREF(__pyx_t_3);
8335
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8336
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 109, __pyx_L1_error)
8337
__Pyx_GOTREF(__pyx_t_4);
8338
__Pyx_GIVEREF(__pyx_t_3);
8339
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
8340
__pyx_t_3 = 0;
8341
__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)
8342
__Pyx_GOTREF(__pyx_t_3);
8343
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8344
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
8345
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8346
__PYX_ERR(2, 109, __pyx_L1_error)
8347
8348
/* "cysignals/memory.pxd":108
8349
* cdef size_t n = mul_overflowcheck(nmemb, size)
8350
* cdef void* ret = sig_realloc(ptr, n)
8351
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
8352
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8353
* return ret
8354
*/
8355
}
8356
8357
/* "cysignals/memory.pxd":110
8358
* if unlikely(ret == NULL):
8359
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8360
* return ret # <<<<<<<<<<<<<<
8361
*
8362
*
8363
*/
8364
__pyx_r = __pyx_v_ret;
8365
goto __pyx_L0;
8366
8367
/* "cysignals/memory.pxd":95
8368
*
8369
*
8370
* cdef inline void* check_reallocarray(void* ptr, size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
8371
* """
8372
* Re-allocate memory at ``ptr`` to hold ``nmemb`` elements of size
8373
*/
8374
8375
/* function exit code */
8376
__pyx_L1_error:;
8377
__Pyx_XDECREF(__pyx_t_2);
8378
__Pyx_XDECREF(__pyx_t_3);
8379
__Pyx_XDECREF(__pyx_t_4);
8380
__Pyx_AddTraceback("cysignals.memory.check_reallocarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
8381
__pyx_r = NULL;
8382
__pyx_L0:;
8383
__Pyx_RefNannyFinishContext();
8384
return __pyx_r;
8385
}
8386
8387
/* "cysignals/memory.pxd":113
8388
*
8389
*
8390
* cdef inline void* check_malloc(size_t n) except? NULL: # <<<<<<<<<<<<<<
8391
* """
8392
* Allocate ``n`` bytes of memory.
8393
*/
8394
8395
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_malloc(size_t __pyx_v_n) {
8396
void *__pyx_v_ret;
8397
void *__pyx_r;
8398
__Pyx_RefNannyDeclarations
8399
int __pyx_t_1;
8400
PyObject *__pyx_t_2 = NULL;
8401
PyObject *__pyx_t_3 = NULL;
8402
__Pyx_RefNannySetupContext("check_malloc", 0);
8403
8404
/* "cysignals/memory.pxd":117
8405
* Allocate ``n`` bytes of memory.
8406
* """
8407
* if n == 0: # <<<<<<<<<<<<<<
8408
* return NULL
8409
* cdef void* ret = sig_malloc(n)
8410
*/
8411
__pyx_t_1 = ((__pyx_v_n == 0) != 0);
8412
if (__pyx_t_1) {
8413
8414
/* "cysignals/memory.pxd":118
8415
* """
8416
* if n == 0:
8417
* return NULL # <<<<<<<<<<<<<<
8418
* cdef void* ret = sig_malloc(n)
8419
* if unlikely(ret == NULL):
8420
*/
8421
__pyx_r = NULL;
8422
goto __pyx_L0;
8423
8424
/* "cysignals/memory.pxd":117
8425
* Allocate ``n`` bytes of memory.
8426
* """
8427
* if n == 0: # <<<<<<<<<<<<<<
8428
* return NULL
8429
* cdef void* ret = sig_malloc(n)
8430
*/
8431
}
8432
8433
/* "cysignals/memory.pxd":119
8434
* if n == 0:
8435
* return NULL
8436
* cdef void* ret = sig_malloc(n) # <<<<<<<<<<<<<<
8437
* if unlikely(ret == NULL):
8438
* raise MemoryError("failed to allocate %s bytes" % n)
8439
*/
8440
__pyx_v_ret = sig_malloc(__pyx_v_n);
8441
8442
/* "cysignals/memory.pxd":120
8443
* return NULL
8444
* cdef void* ret = sig_malloc(n)
8445
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
8446
* raise MemoryError("failed to allocate %s bytes" % n)
8447
* return ret
8448
*/
8449
__pyx_t_1 = (unlikely((__pyx_v_ret == NULL)) != 0);
8450
if (__pyx_t_1) {
8451
8452
/* "cysignals/memory.pxd":121
8453
* cdef void* ret = sig_malloc(n)
8454
* if unlikely(ret == NULL):
8455
* raise MemoryError("failed to allocate %s bytes" % n) # <<<<<<<<<<<<<<
8456
* return ret
8457
*
8458
*/
8459
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 121, __pyx_L1_error)
8460
__Pyx_GOTREF(__pyx_t_2);
8461
__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)
8462
__Pyx_GOTREF(__pyx_t_3);
8463
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8464
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 121, __pyx_L1_error)
8465
__Pyx_GOTREF(__pyx_t_2);
8466
__Pyx_GIVEREF(__pyx_t_3);
8467
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
8468
__pyx_t_3 = 0;
8469
__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)
8470
__Pyx_GOTREF(__pyx_t_3);
8471
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8472
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
8473
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8474
__PYX_ERR(2, 121, __pyx_L1_error)
8475
8476
/* "cysignals/memory.pxd":120
8477
* return NULL
8478
* cdef void* ret = sig_malloc(n)
8479
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
8480
* raise MemoryError("failed to allocate %s bytes" % n)
8481
* return ret
8482
*/
8483
}
8484
8485
/* "cysignals/memory.pxd":122
8486
* if unlikely(ret == NULL):
8487
* raise MemoryError("failed to allocate %s bytes" % n)
8488
* return ret # <<<<<<<<<<<<<<
8489
*
8490
*
8491
*/
8492
__pyx_r = __pyx_v_ret;
8493
goto __pyx_L0;
8494
8495
/* "cysignals/memory.pxd":113
8496
*
8497
*
8498
* cdef inline void* check_malloc(size_t n) except? NULL: # <<<<<<<<<<<<<<
8499
* """
8500
* Allocate ``n`` bytes of memory.
8501
*/
8502
8503
/* function exit code */
8504
__pyx_L1_error:;
8505
__Pyx_XDECREF(__pyx_t_2);
8506
__Pyx_XDECREF(__pyx_t_3);
8507
__Pyx_AddTraceback("cysignals.memory.check_malloc", __pyx_clineno, __pyx_lineno, __pyx_filename);
8508
__pyx_r = NULL;
8509
__pyx_L0:;
8510
__Pyx_RefNannyFinishContext();
8511
return __pyx_r;
8512
}
8513
8514
/* "cysignals/memory.pxd":125
8515
*
8516
*
8517
* cdef inline void* check_realloc(void* ptr, size_t n) except? NULL: # <<<<<<<<<<<<<<
8518
* """
8519
* Re-allocate memory at ``ptr`` to hold ``n`` bytes.
8520
*/
8521
8522
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_realloc(void *__pyx_v_ptr, size_t __pyx_v_n) {
8523
void *__pyx_v_ret;
8524
void *__pyx_r;
8525
__Pyx_RefNannyDeclarations
8526
int __pyx_t_1;
8527
PyObject *__pyx_t_2 = NULL;
8528
PyObject *__pyx_t_3 = NULL;
8529
__Pyx_RefNannySetupContext("check_realloc", 0);
8530
8531
/* "cysignals/memory.pxd":130
8532
* If ``ptr`` equals ``NULL``, this behaves as ``check_malloc``.
8533
* """
8534
* if n == 0: # <<<<<<<<<<<<<<
8535
* sig_free(ptr)
8536
* return NULL
8537
*/
8538
__pyx_t_1 = ((__pyx_v_n == 0) != 0);
8539
if (__pyx_t_1) {
8540
8541
/* "cysignals/memory.pxd":131
8542
* """
8543
* if n == 0:
8544
* sig_free(ptr) # <<<<<<<<<<<<<<
8545
* return NULL
8546
* cdef void* ret = sig_realloc(ptr, n)
8547
*/
8548
sig_free(__pyx_v_ptr);
8549
8550
/* "cysignals/memory.pxd":132
8551
* if n == 0:
8552
* sig_free(ptr)
8553
* return NULL # <<<<<<<<<<<<<<
8554
* cdef void* ret = sig_realloc(ptr, n)
8555
* if unlikely(ret == NULL):
8556
*/
8557
__pyx_r = NULL;
8558
goto __pyx_L0;
8559
8560
/* "cysignals/memory.pxd":130
8561
* If ``ptr`` equals ``NULL``, this behaves as ``check_malloc``.
8562
* """
8563
* if n == 0: # <<<<<<<<<<<<<<
8564
* sig_free(ptr)
8565
* return NULL
8566
*/
8567
}
8568
8569
/* "cysignals/memory.pxd":133
8570
* sig_free(ptr)
8571
* return NULL
8572
* cdef void* ret = sig_realloc(ptr, n) # <<<<<<<<<<<<<<
8573
* if unlikely(ret == NULL):
8574
* raise MemoryError("failed to allocate %s bytes" % n)
8575
*/
8576
__pyx_v_ret = sig_realloc(__pyx_v_ptr, __pyx_v_n);
8577
8578
/* "cysignals/memory.pxd":134
8579
* return NULL
8580
* cdef void* ret = sig_realloc(ptr, n)
8581
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
8582
* raise MemoryError("failed to allocate %s bytes" % n)
8583
* return ret
8584
*/
8585
__pyx_t_1 = (unlikely((__pyx_v_ret == NULL)) != 0);
8586
if (__pyx_t_1) {
8587
8588
/* "cysignals/memory.pxd":135
8589
* cdef void* ret = sig_realloc(ptr, n)
8590
* if unlikely(ret == NULL):
8591
* raise MemoryError("failed to allocate %s bytes" % n) # <<<<<<<<<<<<<<
8592
* return ret
8593
*
8594
*/
8595
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 135, __pyx_L1_error)
8596
__Pyx_GOTREF(__pyx_t_2);
8597
__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)
8598
__Pyx_GOTREF(__pyx_t_3);
8599
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8600
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 135, __pyx_L1_error)
8601
__Pyx_GOTREF(__pyx_t_2);
8602
__Pyx_GIVEREF(__pyx_t_3);
8603
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
8604
__pyx_t_3 = 0;
8605
__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)
8606
__Pyx_GOTREF(__pyx_t_3);
8607
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8608
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
8609
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8610
__PYX_ERR(2, 135, __pyx_L1_error)
8611
8612
/* "cysignals/memory.pxd":134
8613
* return NULL
8614
* cdef void* ret = sig_realloc(ptr, n)
8615
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
8616
* raise MemoryError("failed to allocate %s bytes" % n)
8617
* return ret
8618
*/
8619
}
8620
8621
/* "cysignals/memory.pxd":136
8622
* if unlikely(ret == NULL):
8623
* raise MemoryError("failed to allocate %s bytes" % n)
8624
* return ret # <<<<<<<<<<<<<<
8625
*
8626
*
8627
*/
8628
__pyx_r = __pyx_v_ret;
8629
goto __pyx_L0;
8630
8631
/* "cysignals/memory.pxd":125
8632
*
8633
*
8634
* cdef inline void* check_realloc(void* ptr, size_t n) except? NULL: # <<<<<<<<<<<<<<
8635
* """
8636
* Re-allocate memory at ``ptr`` to hold ``n`` bytes.
8637
*/
8638
8639
/* function exit code */
8640
__pyx_L1_error:;
8641
__Pyx_XDECREF(__pyx_t_2);
8642
__Pyx_XDECREF(__pyx_t_3);
8643
__Pyx_AddTraceback("cysignals.memory.check_realloc", __pyx_clineno, __pyx_lineno, __pyx_filename);
8644
__pyx_r = NULL;
8645
__pyx_L0:;
8646
__Pyx_RefNannyFinishContext();
8647
return __pyx_r;
8648
}
8649
8650
/* "cysignals/memory.pxd":139
8651
*
8652
*
8653
* cdef inline void* check_calloc(size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
8654
* """
8655
* Allocate memory for ``nmemb`` elements of size ``size``. The
8656
*/
8657
8658
static CYTHON_INLINE void *__pyx_f_9cysignals_6memory_check_calloc(size_t __pyx_v_nmemb, size_t __pyx_v_size) {
8659
void *__pyx_v_ret;
8660
void *__pyx_r;
8661
__Pyx_RefNannyDeclarations
8662
int __pyx_t_1;
8663
PyObject *__pyx_t_2 = NULL;
8664
PyObject *__pyx_t_3 = NULL;
8665
PyObject *__pyx_t_4 = NULL;
8666
__Pyx_RefNannySetupContext("check_calloc", 0);
8667
8668
/* "cysignals/memory.pxd":144
8669
* resulting memory is zeroed.
8670
* """
8671
* if nmemb == 0: # <<<<<<<<<<<<<<
8672
* return NULL
8673
* cdef void* ret = sig_calloc(nmemb, size)
8674
*/
8675
__pyx_t_1 = ((__pyx_v_nmemb == 0) != 0);
8676
if (__pyx_t_1) {
8677
8678
/* "cysignals/memory.pxd":145
8679
* """
8680
* if nmemb == 0:
8681
* return NULL # <<<<<<<<<<<<<<
8682
* cdef void* ret = sig_calloc(nmemb, size)
8683
* if unlikely(ret == NULL):
8684
*/
8685
__pyx_r = NULL;
8686
goto __pyx_L0;
8687
8688
/* "cysignals/memory.pxd":144
8689
* resulting memory is zeroed.
8690
* """
8691
* if nmemb == 0: # <<<<<<<<<<<<<<
8692
* return NULL
8693
* cdef void* ret = sig_calloc(nmemb, size)
8694
*/
8695
}
8696
8697
/* "cysignals/memory.pxd":146
8698
* if nmemb == 0:
8699
* return NULL
8700
* cdef void* ret = sig_calloc(nmemb, size) # <<<<<<<<<<<<<<
8701
* if unlikely(ret == NULL):
8702
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8703
*/
8704
__pyx_v_ret = sig_calloc(__pyx_v_nmemb, __pyx_v_size);
8705
8706
/* "cysignals/memory.pxd":147
8707
* return NULL
8708
* cdef void* ret = sig_calloc(nmemb, size)
8709
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
8710
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8711
* return ret
8712
*/
8713
__pyx_t_1 = (unlikely((__pyx_v_ret == NULL)) != 0);
8714
if (__pyx_t_1) {
8715
8716
/* "cysignals/memory.pxd":148
8717
* cdef void* ret = sig_calloc(nmemb, size)
8718
* if unlikely(ret == NULL):
8719
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size)) # <<<<<<<<<<<<<<
8720
* return ret
8721
*/
8722
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_nmemb); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 148, __pyx_L1_error)
8723
__Pyx_GOTREF(__pyx_t_2);
8724
__pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 148, __pyx_L1_error)
8725
__Pyx_GOTREF(__pyx_t_3);
8726
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 148, __pyx_L1_error)
8727
__Pyx_GOTREF(__pyx_t_4);
8728
__Pyx_GIVEREF(__pyx_t_2);
8729
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
8730
__Pyx_GIVEREF(__pyx_t_3);
8731
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
8732
__pyx_t_2 = 0;
8733
__pyx_t_3 = 0;
8734
__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)
8735
__Pyx_GOTREF(__pyx_t_3);
8736
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8737
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 148, __pyx_L1_error)
8738
__Pyx_GOTREF(__pyx_t_4);
8739
__Pyx_GIVEREF(__pyx_t_3);
8740
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
8741
__pyx_t_3 = 0;
8742
__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)
8743
__Pyx_GOTREF(__pyx_t_3);
8744
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8745
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
8746
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8747
__PYX_ERR(2, 148, __pyx_L1_error)
8748
8749
/* "cysignals/memory.pxd":147
8750
* return NULL
8751
* cdef void* ret = sig_calloc(nmemb, size)
8752
* if unlikely(ret == NULL): # <<<<<<<<<<<<<<
8753
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8754
* return ret
8755
*/
8756
}
8757
8758
/* "cysignals/memory.pxd":149
8759
* if unlikely(ret == NULL):
8760
* raise MemoryError("failed to allocate %s * %s bytes" % (nmemb, size))
8761
* return ret # <<<<<<<<<<<<<<
8762
*/
8763
__pyx_r = __pyx_v_ret;
8764
goto __pyx_L0;
8765
8766
/* "cysignals/memory.pxd":139
8767
*
8768
*
8769
* cdef inline void* check_calloc(size_t nmemb, size_t size) except? NULL: # <<<<<<<<<<<<<<
8770
* """
8771
* Allocate memory for ``nmemb`` elements of size ``size``. The
8772
*/
8773
8774
/* function exit code */
8775
__pyx_L1_error:;
8776
__Pyx_XDECREF(__pyx_t_2);
8777
__Pyx_XDECREF(__pyx_t_3);
8778
__Pyx_XDECREF(__pyx_t_4);
8779
__Pyx_AddTraceback("cysignals.memory.check_calloc", __pyx_clineno, __pyx_lineno, __pyx_filename);
8780
__pyx_r = NULL;
8781
__pyx_L0:;
8782
__Pyx_RefNannyFinishContext();
8783
return __pyx_r;
8784
}
8785
8786
/* "parent.pxd":23
8787
* # Flags, see below
8788
* cdef int flags
8789
* cdef inline bint get_flag(self, int flag): # <<<<<<<<<<<<<<
8790
* return self.flags & flag
8791
*
8792
*/
8793
8794
static CYTHON_INLINE int __pyx_f_4sage_9structure_6parent_6Parent_get_flag(struct __pyx_obj_4sage_9structure_6parent_Parent *__pyx_v_self, int __pyx_v_flag) {
8795
int __pyx_r;
8796
__Pyx_RefNannyDeclarations
8797
__Pyx_RefNannySetupContext("get_flag", 0);
8798
8799
/* "parent.pxd":24
8800
* cdef int flags
8801
* cdef inline bint get_flag(self, int flag):
8802
* return self.flags & flag # <<<<<<<<<<<<<<
8803
*
8804
* cpdef bint is_coercion_cached(self, domain)
8805
*/
8806
__pyx_r = (__pyx_v_self->flags & __pyx_v_flag);
8807
goto __pyx_L0;
8808
8809
/* "parent.pxd":23
8810
* # Flags, see below
8811
* cdef int flags
8812
* cdef inline bint get_flag(self, int flag): # <<<<<<<<<<<<<<
8813
* return self.flags & flag
8814
*
8815
*/
8816
8817
/* function exit code */
8818
__pyx_L0:;
8819
__Pyx_RefNannyFinishContext();
8820
return __pyx_r;
8821
}
8822
8823
/* "sage_object.pxd":13
8824
*
8825
*
8826
* cpdef inline richcmp_not_equal(x, y, int op): # <<<<<<<<<<<<<<
8827
* """
8828
* Like ``richcmp(x, y, op)`` but assuming that `x` is not equal to `y`.
8829
*/
8830
8831
static PyObject *__pyx_pw_4sage_9structure_11sage_object_1richcmp_not_equal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8832
static CYTHON_INLINE PyObject *__pyx_f_4sage_9structure_11sage_object_richcmp_not_equal(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op, CYTHON_UNUSED int __pyx_skip_dispatch) {
8833
PyObject *__pyx_r = NULL;
8834
__Pyx_RefNannyDeclarations
8835
int __pyx_t_1;
8836
PyObject *__pyx_t_2 = NULL;
8837
__Pyx_RefNannySetupContext("richcmp_not_equal", 0);
8838
8839
/* "sage_object.pxd":70
8840
* True
8841
* """
8842
* if op == Py_EQ: # <<<<<<<<<<<<<<
8843
* return False
8844
* elif op == Py_NE:
8845
*/
8846
__pyx_t_1 = ((__pyx_v_op == Py_EQ) != 0);
8847
if (__pyx_t_1) {
8848
8849
/* "sage_object.pxd":71
8850
* """
8851
* if op == Py_EQ:
8852
* return False # <<<<<<<<<<<<<<
8853
* elif op == Py_NE:
8854
* return True
8855
*/
8856
__Pyx_XDECREF(__pyx_r);
8857
__Pyx_INCREF(Py_False);
8858
__pyx_r = Py_False;
8859
goto __pyx_L0;
8860
8861
/* "sage_object.pxd":70
8862
* True
8863
* """
8864
* if op == Py_EQ: # <<<<<<<<<<<<<<
8865
* return False
8866
* elif op == Py_NE:
8867
*/
8868
}
8869
8870
/* "sage_object.pxd":72
8871
* if op == Py_EQ:
8872
* return False
8873
* elif op == Py_NE: # <<<<<<<<<<<<<<
8874
* return True
8875
* return richcmp(x, y, op)
8876
*/
8877
__pyx_t_1 = ((__pyx_v_op == Py_NE) != 0);
8878
if (__pyx_t_1) {
8879
8880
/* "sage_object.pxd":73
8881
* return False
8882
* elif op == Py_NE:
8883
* return True # <<<<<<<<<<<<<<
8884
* return richcmp(x, y, op)
8885
*
8886
*/
8887
__Pyx_XDECREF(__pyx_r);
8888
__Pyx_INCREF(Py_True);
8889
__pyx_r = Py_True;
8890
goto __pyx_L0;
8891
8892
/* "sage_object.pxd":72
8893
* if op == Py_EQ:
8894
* return False
8895
* elif op == Py_NE: # <<<<<<<<<<<<<<
8896
* return True
8897
* return richcmp(x, y, op)
8898
*/
8899
}
8900
8901
/* "sage_object.pxd":74
8902
* elif op == Py_NE:
8903
* return True
8904
* return richcmp(x, y, op) # <<<<<<<<<<<<<<
8905
*
8906
*
8907
*/
8908
__Pyx_XDECREF(__pyx_r);
8909
__pyx_t_2 = PyObject_RichCompare(__pyx_v_x, __pyx_v_y, __pyx_v_op); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 74, __pyx_L1_error)
8910
__Pyx_GOTREF(__pyx_t_2);
8911
__pyx_r = __pyx_t_2;
8912
__pyx_t_2 = 0;
8913
goto __pyx_L0;
8914
8915
/* "sage_object.pxd":13
8916
*
8917
*
8918
* cpdef inline richcmp_not_equal(x, y, int op): # <<<<<<<<<<<<<<
8919
* """
8920
* Like ``richcmp(x, y, op)`` but assuming that `x` is not equal to `y`.
8921
*/
8922
8923
/* function exit code */
8924
__pyx_L1_error:;
8925
__Pyx_XDECREF(__pyx_t_2);
8926
__Pyx_AddTraceback("sage.structure.sage_object.richcmp_not_equal", __pyx_clineno, __pyx_lineno, __pyx_filename);
8927
__pyx_r = 0;
8928
__pyx_L0:;
8929
__Pyx_XGIVEREF(__pyx_r);
8930
__Pyx_RefNannyFinishContext();
8931
return __pyx_r;
8932
}
8933
8934
/* Python wrapper */
8935
static PyObject *__pyx_pw_4sage_9structure_11sage_object_1richcmp_not_equal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8936
static char __pyx_doc_4sage_9structure_11sage_object_richcmp_not_equal[] = "File: (starting at line 13)\n\n Like ``richcmp(x, y, op)`` but assuming that `x` is not equal to `y`.\n\n INPUT:\n\n - ``op`` -- a rich comparison operation (e.g. ``Py_EQ``)\n\n OUTPUT:\n\n If ``op`` is not ``op_EQ`` or ``op_NE``, the result of\n ``richcmp(x, y, op)``. If ``op`` is ``op_EQ``, return\n ``False``. If ``op`` is ``op_NE``, return ``True``.\n\n This is useful to compare lazily two objects A and B according to 2\n (or more) different parameters, say width and height for example.\n One could use::\n\n return richcmp((A.width(), A.height()), (B.width(), B.height()), op)\n\n but this will compute both width and height in all cases, even if\n A.width() and B.width() are enough to decide the comparison.\n\n Instead one can do::\n\n wA = A.width()\n wB = B.width()\n if wA != wB:\n return richcmp_not_equal(wA, wB, op)\n return richcmp(A.height(), B.height(), op)\n\n The difference with ``richcmp`` is that ``richcmp_not_equal``\n assumes that its arguments are not equal, which is excluding the case\n where the comparison cannot be decided so far, without\n knowing the rest of the parameters.\n\n EXAMPLES::\n\n sage: from sage.structure.sage_object import (richcmp_not_equal,\n ....: op_EQ, op_NE, op_LT, op_LE, op_GT, op_GE)\n sage: for op in (op_LT, op_LE, op_EQ, op_NE, op_GT, op_GE):\n ....: print(richcmp_not_equal(3, 4, op))\n True\n True\n False\n True\n False\n False\n sage: for op in (op_LT, op_LE, op_EQ, op_NE, op_GT, op_GE):\n ....: print(richcmp_not_equal(5, 4, op))\n False\n False\n False\n True\n True\n True\n ";
8937
static PyObject *__pyx_pw_4sage_9structure_11sage_object_1richcmp_not_equal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8938
PyObject *__pyx_v_x = 0;
8939
PyObject *__pyx_v_y = 0;
8940
int __pyx_v_op;
8941
PyObject *__pyx_r = 0;
8942
__Pyx_RefNannyDeclarations
8943
__Pyx_RefNannySetupContext("richcmp_not_equal (wrapper)", 0);
8944
{
8945
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_op,0};
8946
PyObject* values[3] = {0,0,0};
8947
if (unlikely(__pyx_kwds)) {
8948
Py_ssize_t kw_args;
8949
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
8950
switch (pos_args) {
8951
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8952
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8953
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8954
case 0: break;
8955
default: goto __pyx_L5_argtuple_error;
8956
}
8957
kw_args = PyDict_Size(__pyx_kwds);
8958
switch (pos_args) {
8959
case 0:
8960
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
8961
else goto __pyx_L5_argtuple_error;
8962
case 1:
8963
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
8964
else {
8965
__Pyx_RaiseArgtupleInvalid("richcmp_not_equal", 1, 3, 3, 1); __PYX_ERR(3, 13, __pyx_L3_error)
8966
}
8967
case 2:
8968
if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
8969
else {
8970
__Pyx_RaiseArgtupleInvalid("richcmp_not_equal", 1, 3, 3, 2); __PYX_ERR(3, 13, __pyx_L3_error)
8971
}
8972
}
8973
if (unlikely(kw_args > 0)) {
8974
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "richcmp_not_equal") < 0)) __PYX_ERR(3, 13, __pyx_L3_error)
8975
}
8976
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
8977
goto __pyx_L5_argtuple_error;
8978
} else {
8979
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8980
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8981
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8982
}
8983
__pyx_v_x = values[0];
8984
__pyx_v_y = values[1];
8985
__pyx_v_op = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_op == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 13, __pyx_L3_error)
8986
}
8987
goto __pyx_L4_argument_unpacking_done;
8988
__pyx_L5_argtuple_error:;
8989
__Pyx_RaiseArgtupleInvalid("richcmp_not_equal", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 13, __pyx_L3_error)
8990
__pyx_L3_error:;
8991
__Pyx_AddTraceback("sage.structure.sage_object.richcmp_not_equal", __pyx_clineno, __pyx_lineno, __pyx_filename);
8992
__Pyx_RefNannyFinishContext();
8993
return NULL;
8994
__pyx_L4_argument_unpacking_done:;
8995
__pyx_r = __pyx_pf_4sage_9structure_11sage_object_richcmp_not_equal(__pyx_self, __pyx_v_x, __pyx_v_y, __pyx_v_op);
8996
8997
/* function exit code */
8998
__Pyx_RefNannyFinishContext();
8999
return __pyx_r;
9000
}
9001
9002
static PyObject *__pyx_pf_4sage_9structure_11sage_object_richcmp_not_equal(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op) {
9003
PyObject *__pyx_r = NULL;
9004
__Pyx_RefNannyDeclarations
9005
PyObject *__pyx_t_1 = NULL;
9006
__Pyx_RefNannySetupContext("richcmp_not_equal", 0);
9007
__Pyx_XDECREF(__pyx_r);
9008
__pyx_t_1 = __pyx_f_4sage_9structure_11sage_object_richcmp_not_equal(__pyx_v_x, __pyx_v_y, __pyx_v_op, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 13, __pyx_L1_error)
9009
__Pyx_GOTREF(__pyx_t_1);
9010
__pyx_r = __pyx_t_1;
9011
__pyx_t_1 = 0;
9012
goto __pyx_L0;
9013
9014
/* function exit code */
9015
__pyx_L1_error:;
9016
__Pyx_XDECREF(__pyx_t_1);
9017
__Pyx_AddTraceback("sage.structure.sage_object.richcmp_not_equal", __pyx_clineno, __pyx_lineno, __pyx_filename);
9018
__pyx_r = NULL;
9019
__pyx_L0:;
9020
__Pyx_XGIVEREF(__pyx_r);
9021
__Pyx_RefNannyFinishContext();
9022
return __pyx_r;
9023
}
9024
9025
/* "sage_object.pxd":77
9026
*
9027
*
9028
* cpdef inline bint rich_to_bool(int op, int c): # <<<<<<<<<<<<<<
9029
* """
9030
* Return the corresponding ``True`` or ``False`` value for a rich
9031
*/
9032
9033
static PyObject *__pyx_pw_4sage_9structure_11sage_object_3rich_to_bool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
9034
static CYTHON_INLINE int __pyx_f_4sage_9structure_11sage_object_rich_to_bool(int __pyx_v_op, int __pyx_v_c, CYTHON_UNUSED int __pyx_skip_dispatch) {
9035
uint32_t __pyx_v_less_bits;
9036
uint32_t __pyx_v_equal_bits;
9037
uint32_t __pyx_v_greater_bits;
9038
uint32_t __pyx_v_bits;
9039
int __pyx_v_shift;
9040
int __pyx_r;
9041
__Pyx_RefNannyDeclarations
9042
__Pyx_RefNannySetupContext("rich_to_bool", 0);
9043
9044
/* "sage_object.pxd":139
9045
* # The 4 lines below involve just constants, so the compiler should
9046
* # optimize them to just one constant value for "bits".
9047
* cdef uint32_t less_bits = (1 << Py_LT) + (1 << Py_LE) + (1 << Py_NE) # <<<<<<<<<<<<<<
9048
* cdef uint32_t equal_bits = (1 << Py_LE) + (1 << Py_GE) + (1 << Py_EQ)
9049
* cdef uint32_t greater_bits = (1 << Py_GT) + (1 << Py_GE) + (1 << Py_NE)
9050
*/
9051
__pyx_v_less_bits = (((1 << Py_LT) + (1 << Py_LE)) + (1 << Py_NE));
9052
9053
/* "sage_object.pxd":140
9054
* # optimize them to just one constant value for "bits".
9055
* cdef uint32_t less_bits = (1 << Py_LT) + (1 << Py_LE) + (1 << Py_NE)
9056
* cdef uint32_t equal_bits = (1 << Py_LE) + (1 << Py_GE) + (1 << Py_EQ) # <<<<<<<<<<<<<<
9057
* cdef uint32_t greater_bits = (1 << Py_GT) + (1 << Py_GE) + (1 << Py_NE)
9058
* cdef uint32_t bits = (less_bits << 24) + (equal_bits) + (greater_bits << 8)
9059
*/
9060
__pyx_v_equal_bits = (((1 << Py_LE) + (1 << Py_GE)) + (1 << Py_EQ));
9061
9062
/* "sage_object.pxd":141
9063
* cdef uint32_t less_bits = (1 << Py_LT) + (1 << Py_LE) + (1 << Py_NE)
9064
* cdef uint32_t equal_bits = (1 << Py_LE) + (1 << Py_GE) + (1 << Py_EQ)
9065
* cdef uint32_t greater_bits = (1 << Py_GT) + (1 << Py_GE) + (1 << Py_NE) # <<<<<<<<<<<<<<
9066
* cdef uint32_t bits = (less_bits << 24) + (equal_bits) + (greater_bits << 8)
9067
*
9068
*/
9069
__pyx_v_greater_bits = (((1 << Py_GT) + (1 << Py_GE)) + (1 << Py_NE));
9070
9071
/* "sage_object.pxd":142
9072
* cdef uint32_t equal_bits = (1 << Py_LE) + (1 << Py_GE) + (1 << Py_EQ)
9073
* cdef uint32_t greater_bits = (1 << Py_GT) + (1 << Py_GE) + (1 << Py_NE)
9074
* cdef uint32_t bits = (less_bits << 24) + (equal_bits) + (greater_bits << 8) # <<<<<<<<<<<<<<
9075
*
9076
* cdef int shift = 8*c + op
9077
*/
9078
__pyx_v_bits = (((__pyx_v_less_bits << 24) + __pyx_v_equal_bits) + (__pyx_v_greater_bits << 8));
9079
9080
/* "sage_object.pxd":144
9081
* cdef uint32_t bits = (less_bits << 24) + (equal_bits) + (greater_bits << 8)
9082
*
9083
* cdef int shift = 8*c + op # <<<<<<<<<<<<<<
9084
*
9085
* # The shift masking (shift & 31) will likely be optimized away by
9086
*/
9087
__pyx_v_shift = ((8 * __pyx_v_c) + __pyx_v_op);
9088
9089
/* "sage_object.pxd":149
9090
* # the compiler since shift and bit test instructions implicitly
9091
* # mask their offset.
9092
* return (bits >> (shift & 31)) & 1 # <<<<<<<<<<<<<<
9093
*
9094
*
9095
*/
9096
__pyx_r = ((__pyx_v_bits >> (__pyx_v_shift & 31)) & 1);
9097
goto __pyx_L0;
9098
9099
/* "sage_object.pxd":77
9100
*
9101
*
9102
* cpdef inline bint rich_to_bool(int op, int c): # <<<<<<<<<<<<<<
9103
* """
9104
* Return the corresponding ``True`` or ``False`` value for a rich
9105
*/
9106
9107
/* function exit code */
9108
__pyx_L0:;
9109
__Pyx_RefNannyFinishContext();
9110
return __pyx_r;
9111
}
9112
9113
/* Python wrapper */
9114
static PyObject *__pyx_pw_4sage_9structure_11sage_object_3rich_to_bool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
9115
static char __pyx_doc_4sage_9structure_11sage_object_2rich_to_bool[] = "File: (starting at line 77)\n\n Return the corresponding ``True`` or ``False`` value for a rich\n comparison, given the result of an ordinary comparison.\n\n INPUT:\n\n - ``op`` -- a rich comparison operation (e.g. ``Py_EQ``)\n\n - ``c`` -- the result of an ordinary comparison: -1, 0 or 1.\n\n OUTPUT: 1 or 0 (corresponding to ``True`` and ``False``)\n\n .. SEEALSO::\n\n ``rich_to_bool_sgn`` if ``c`` could be outside the [-1, 1]\n range.\n\n EXAMPLES::\n\n sage: from sage.structure.sage_object import (rich_to_bool,\n ....: op_EQ, op_NE, op_LT, op_LE, op_GT, op_GE)\n sage: for op in (op_LT, op_LE, op_EQ, op_NE, op_GT, op_GE):\n ....: for c in (-1,0,1):\n ....: print(rich_to_bool(op, c))\n True False False\n True True False\n False True False\n True False True\n False False True\n False True True\n\n Indirect tests using integers::\n\n sage: 0 < 5, 5 < 5, 5 < -8\n (True, False, False)\n sage: 0 <= 5, 5 <= 5, 5 <= -8\n (True, True, False)\n sage: 0 >= 5, 5 >= 5, 5 >= -8\n (False, True, True)\n sage: 0 > 5, 5 > 5, 5 > -8\n (False, False, True)\n sage: 0 == 5, 5 == 5, 5 == -8\n (False, True, False)\n sage: 0 != 5, 5 != 5, 5 != -8\n (True, False, True)\n\n TESTS::\n\n sage: from sage.structure.sage_object import py_rich_to_bool\n sage: py_rich_to_bool(op_EQ, 0)\n doctest:...: DeprecationWarning: py_rich_to_bool is deprecated. Please use sage.structure.sage_object.rich_to_bool instead.\n See http://trac.sagemath.org/21128 for details.\n True\n ";
9116
static PyObject *__pyx_pw_4sage_9structure_11sage_object_3rich_to_bool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
9117
int __pyx_v_op;
9118
int __pyx_v_c;
9119
PyObject *__pyx_r = 0;
9120
__Pyx_RefNannyDeclarations
9121
__Pyx_RefNannySetupContext("rich_to_bool (wrapper)", 0);
9122
{
9123
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_op,&__pyx_n_s_c,0};
9124
PyObject* values[2] = {0,0};
9125
if (unlikely(__pyx_kwds)) {
9126
Py_ssize_t kw_args;
9127
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
9128
switch (pos_args) {
9129
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9130
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9131
case 0: break;
9132
default: goto __pyx_L5_argtuple_error;
9133
}
9134
kw_args = PyDict_Size(__pyx_kwds);
9135
switch (pos_args) {
9136
case 0:
9137
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
9138
else goto __pyx_L5_argtuple_error;
9139
case 1:
9140
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_c)) != 0)) kw_args--;
9141
else {
9142
__Pyx_RaiseArgtupleInvalid("rich_to_bool", 1, 2, 2, 1); __PYX_ERR(3, 77, __pyx_L3_error)
9143
}
9144
}
9145
if (unlikely(kw_args > 0)) {
9146
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rich_to_bool") < 0)) __PYX_ERR(3, 77, __pyx_L3_error)
9147
}
9148
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
9149
goto __pyx_L5_argtuple_error;
9150
} else {
9151
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9152
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9153
}
9154
__pyx_v_op = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_op == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 77, __pyx_L3_error)
9155
__pyx_v_c = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_c == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 77, __pyx_L3_error)
9156
}
9157
goto __pyx_L4_argument_unpacking_done;
9158
__pyx_L5_argtuple_error:;
9159
__Pyx_RaiseArgtupleInvalid("rich_to_bool", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 77, __pyx_L3_error)
9160
__pyx_L3_error:;
9161
__Pyx_AddTraceback("sage.structure.sage_object.rich_to_bool", __pyx_clineno, __pyx_lineno, __pyx_filename);
9162
__Pyx_RefNannyFinishContext();
9163
return NULL;
9164
__pyx_L4_argument_unpacking_done:;
9165
__pyx_r = __pyx_pf_4sage_9structure_11sage_object_2rich_to_bool(__pyx_self, __pyx_v_op, __pyx_v_c);
9166
9167
/* function exit code */
9168
__Pyx_RefNannyFinishContext();
9169
return __pyx_r;
9170
}
9171
9172
static PyObject *__pyx_pf_4sage_9structure_11sage_object_2rich_to_bool(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_op, int __pyx_v_c) {
9173
PyObject *__pyx_r = NULL;
9174
__Pyx_RefNannyDeclarations
9175
PyObject *__pyx_t_1 = NULL;
9176
__Pyx_RefNannySetupContext("rich_to_bool", 0);
9177
__Pyx_XDECREF(__pyx_r);
9178
__pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_4sage_9structure_11sage_object_rich_to_bool(__pyx_v_op, __pyx_v_c, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 77, __pyx_L1_error)
9179
__Pyx_GOTREF(__pyx_t_1);
9180
__pyx_r = __pyx_t_1;
9181
__pyx_t_1 = 0;
9182
goto __pyx_L0;
9183
9184
/* function exit code */
9185
__pyx_L1_error:;
9186
__Pyx_XDECREF(__pyx_t_1);
9187
__Pyx_AddTraceback("sage.structure.sage_object.rich_to_bool", __pyx_clineno, __pyx_lineno, __pyx_filename);
9188
__pyx_r = NULL;
9189
__pyx_L0:;
9190
__Pyx_XGIVEREF(__pyx_r);
9191
__Pyx_RefNannyFinishContext();
9192
return __pyx_r;
9193
}
9194
9195
/* "sage_object.pxd":152
9196
*
9197
*
9198
* cpdef inline bint rich_to_bool_sgn(int op, int c): # <<<<<<<<<<<<<<
9199
* """
9200
* Same as ``rich_to_bool``, but allow any `c < 0` and `c > 0`
9201
*/
9202
9203
static PyObject *__pyx_pw_4sage_9structure_11sage_object_5rich_to_bool_sgn(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
9204
static CYTHON_INLINE int __pyx_f_4sage_9structure_11sage_object_rich_to_bool_sgn(int __pyx_v_op, int __pyx_v_c, CYTHON_UNUSED int __pyx_skip_dispatch) {
9205
int __pyx_r;
9206
__Pyx_RefNannyDeclarations
9207
__Pyx_RefNannySetupContext("rich_to_bool_sgn", 0);
9208
9209
/* "sage_object.pxd":161
9210
* This is in particular needed for ``mpz_cmp()``.
9211
* """
9212
* return rich_to_bool(op, (c > 0) - (c < 0)) # <<<<<<<<<<<<<<
9213
*/
9214
__pyx_r = __pyx_f_4sage_9structure_11sage_object_rich_to_bool(__pyx_v_op, ((__pyx_v_c > 0) - (__pyx_v_c < 0)), 0);
9215
goto __pyx_L0;
9216
9217
/* "sage_object.pxd":152
9218
*
9219
*
9220
* cpdef inline bint rich_to_bool_sgn(int op, int c): # <<<<<<<<<<<<<<
9221
* """
9222
* Same as ``rich_to_bool``, but allow any `c < 0` and `c > 0`
9223
*/
9224
9225
/* function exit code */
9226
__pyx_L0:;
9227
__Pyx_RefNannyFinishContext();
9228
return __pyx_r;
9229
}
9230
9231
/* Python wrapper */
9232
static PyObject *__pyx_pw_4sage_9structure_11sage_object_5rich_to_bool_sgn(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
9233
static char __pyx_doc_4sage_9structure_11sage_object_4rich_to_bool_sgn[] = "File: (starting at line 152)\n\n Same as ``rich_to_bool``, but allow any `c < 0` and `c > 0`\n instead of only `-1` and `1`.\n\n .. NOTE::\n\n This is in particular needed for ``mpz_cmp()``.\n ";
9234
static PyObject *__pyx_pw_4sage_9structure_11sage_object_5rich_to_bool_sgn(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
9235
int __pyx_v_op;
9236
int __pyx_v_c;
9237
PyObject *__pyx_r = 0;
9238
__Pyx_RefNannyDeclarations
9239
__Pyx_RefNannySetupContext("rich_to_bool_sgn (wrapper)", 0);
9240
{
9241
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_op,&__pyx_n_s_c,0};
9242
PyObject* values[2] = {0,0};
9243
if (unlikely(__pyx_kwds)) {
9244
Py_ssize_t kw_args;
9245
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
9246
switch (pos_args) {
9247
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9248
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9249
case 0: break;
9250
default: goto __pyx_L5_argtuple_error;
9251
}
9252
kw_args = PyDict_Size(__pyx_kwds);
9253
switch (pos_args) {
9254
case 0:
9255
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
9256
else goto __pyx_L5_argtuple_error;
9257
case 1:
9258
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_c)) != 0)) kw_args--;
9259
else {
9260
__Pyx_RaiseArgtupleInvalid("rich_to_bool_sgn", 1, 2, 2, 1); __PYX_ERR(3, 152, __pyx_L3_error)
9261
}
9262
}
9263
if (unlikely(kw_args > 0)) {
9264
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rich_to_bool_sgn") < 0)) __PYX_ERR(3, 152, __pyx_L3_error)
9265
}
9266
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
9267
goto __pyx_L5_argtuple_error;
9268
} else {
9269
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9270
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9271
}
9272
__pyx_v_op = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_op == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 152, __pyx_L3_error)
9273
__pyx_v_c = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_c == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 152, __pyx_L3_error)
9274
}
9275
goto __pyx_L4_argument_unpacking_done;
9276
__pyx_L5_argtuple_error:;
9277
__Pyx_RaiseArgtupleInvalid("rich_to_bool_sgn", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 152, __pyx_L3_error)
9278
__pyx_L3_error:;
9279
__Pyx_AddTraceback("sage.structure.sage_object.rich_to_bool_sgn", __pyx_clineno, __pyx_lineno, __pyx_filename);
9280
__Pyx_RefNannyFinishContext();
9281
return NULL;
9282
__pyx_L4_argument_unpacking_done:;
9283
__pyx_r = __pyx_pf_4sage_9structure_11sage_object_4rich_to_bool_sgn(__pyx_self, __pyx_v_op, __pyx_v_c);
9284
9285
/* function exit code */
9286
__Pyx_RefNannyFinishContext();
9287
return __pyx_r;
9288
}
9289
9290
static PyObject *__pyx_pf_4sage_9structure_11sage_object_4rich_to_bool_sgn(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_op, int __pyx_v_c) {
9291
PyObject *__pyx_r = NULL;
9292
__Pyx_RefNannyDeclarations
9293
PyObject *__pyx_t_1 = NULL;
9294
__Pyx_RefNannySetupContext("rich_to_bool_sgn", 0);
9295
__Pyx_XDECREF(__pyx_r);
9296
__pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_4sage_9structure_11sage_object_rich_to_bool_sgn(__pyx_v_op, __pyx_v_c, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 152, __pyx_L1_error)
9297
__Pyx_GOTREF(__pyx_t_1);
9298
__pyx_r = __pyx_t_1;
9299
__pyx_t_1 = 0;
9300
goto __pyx_L0;
9301
9302
/* function exit code */
9303
__pyx_L1_error:;
9304
__Pyx_XDECREF(__pyx_t_1);
9305
__Pyx_AddTraceback("sage.structure.sage_object.rich_to_bool_sgn", __pyx_clineno, __pyx_lineno, __pyx_filename);
9306
__pyx_r = NULL;
9307
__pyx_L0:;
9308
__Pyx_XGIVEREF(__pyx_r);
9309
__Pyx_RefNannyFinishContext();
9310
return __pyx_r;
9311
}
9312
9313
/* "sage/ext/stdsage.pxd":16
9314
*
9315
*
9316
* cdef inline PY_NEW(type t): # <<<<<<<<<<<<<<
9317
* """
9318
* Return ``t.__new__(t)``. This works even for types like
9319
*/
9320
9321
static CYTHON_INLINE PyObject *__pyx_f_4sage_3ext_7stdsage_PY_NEW(PyTypeObject *__pyx_v_t) {
9322
PyObject *__pyx_r = NULL;
9323
__Pyx_RefNannyDeclarations
9324
PyObject *__pyx_t_1 = NULL;
9325
__Pyx_RefNannySetupContext("PY_NEW", 0);
9326
9327
/* "sage/ext/stdsage.pxd":22
9328
* optimizations assume that ``tp_new`` doesn't change).
9329
* """
9330
* return (<PyTypeObject*>t).tp_new(t, <object>NULL, <object>NULL) # <<<<<<<<<<<<<<
9331
*
9332
*
9333
*/
9334
__Pyx_XDECREF(__pyx_r);
9335
__pyx_t_1 = ((PyTypeObject *)__pyx_v_t)->tp_new(((PyTypeObject *)__pyx_v_t), ((PyObject *)NULL), ((PyObject *)NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 22, __pyx_L1_error)
9336
__Pyx_GOTREF(__pyx_t_1);
9337
__pyx_r = __pyx_t_1;
9338
__pyx_t_1 = 0;
9339
goto __pyx_L0;
9340
9341
/* "sage/ext/stdsage.pxd":16
9342
*
9343
*
9344
* cdef inline PY_NEW(type t): # <<<<<<<<<<<<<<
9345
* """
9346
* Return ``t.__new__(t)``. This works even for types like
9347
*/
9348
9349
/* function exit code */
9350
__pyx_L1_error:;
9351
__Pyx_XDECREF(__pyx_t_1);
9352
__Pyx_AddTraceback("sage.ext.stdsage.PY_NEW", __pyx_clineno, __pyx_lineno, __pyx_filename);
9353
__pyx_r = 0;
9354
__pyx_L0:;
9355
__Pyx_XGIVEREF(__pyx_r);
9356
__Pyx_RefNannyFinishContext();
9357
return __pyx_r;
9358
}
9359
9360
/* "sage/ext/stdsage.pxd":25
9361
*
9362
*
9363
* cdef inline void PY_SET_TP_NEW(type dst, type src): # <<<<<<<<<<<<<<
9364
* """
9365
* Manually set ``dst.__new__`` to ``src.__new__``. This is used to
9366
*/
9367
9368
static CYTHON_INLINE void __pyx_f_4sage_3ext_7stdsage_PY_SET_TP_NEW(PyTypeObject *__pyx_v_dst, PyTypeObject *__pyx_v_src) {
9369
__Pyx_RefNannyDeclarations
9370
newfunc __pyx_t_1;
9371
__Pyx_RefNannySetupContext("PY_SET_TP_NEW", 0);
9372
9373
/* "sage/ext/stdsage.pxd":31
9374
* irrelevant base class ``tp_new`` methods.
9375
* """
9376
* (<PyTypeObject*>dst).tp_new = (<PyTypeObject*>src).tp_new # <<<<<<<<<<<<<<
9377
*
9378
*
9379
*/
9380
__pyx_t_1 = ((PyTypeObject *)__pyx_v_src)->tp_new;
9381
((PyTypeObject *)__pyx_v_dst)->tp_new = __pyx_t_1;
9382
9383
/* "sage/ext/stdsage.pxd":25
9384
*
9385
*
9386
* cdef inline void PY_SET_TP_NEW(type dst, type src): # <<<<<<<<<<<<<<
9387
* """
9388
* Manually set ``dst.__new__`` to ``src.__new__``. This is used to
9389
*/
9390
9391
/* function exit code */
9392
__Pyx_RefNannyFinishContext();
9393
}
9394
9395
/* "sage/ext/stdsage.pxd":34
9396
*
9397
*
9398
* cdef inline bint HAS_DICTIONARY(obj): # <<<<<<<<<<<<<<
9399
* """
9400
* Test whether the given object has a Python dictionary.
9401
*/
9402
9403
static CYTHON_INLINE int __pyx_f_4sage_3ext_7stdsage_HAS_DICTIONARY(PyObject *__pyx_v_obj) {
9404
int __pyx_r;
9405
__Pyx_RefNannyDeclarations
9406
__Pyx_RefNannySetupContext("HAS_DICTIONARY", 0);
9407
9408
/* "sage/ext/stdsage.pxd":38
9409
* Test whether the given object has a Python dictionary.
9410
* """
9411
* return Py_TYPE(obj).tp_dictoffset != 0 # <<<<<<<<<<<<<<
9412
*/
9413
__pyx_r = (Py_TYPE(__pyx_v_obj)->tp_dictoffset != 0);
9414
goto __pyx_L0;
9415
9416
/* "sage/ext/stdsage.pxd":34
9417
*
9418
*
9419
* cdef inline bint HAS_DICTIONARY(obj): # <<<<<<<<<<<<<<
9420
* """
9421
* Test whether the given object has a Python dictionary.
9422
*/
9423
9424
/* function exit code */
9425
__pyx_L0:;
9426
__Pyx_RefNannyFinishContext();
9427
return __pyx_r;
9428
}
9429
9430
/* "cysignals/signals.pxd":35
9431
* # (PyErr_Occurred() is non-NULL). To Cython, it will look like
9432
* # cython_check_exception() actually raised the exception.
9433
* cdef inline void cython_check_exception() nogil except *: # <<<<<<<<<<<<<<
9434
* pass
9435
*
9436
*/
9437
9438
static CYTHON_INLINE void __pyx_f_9cysignals_7signals_cython_check_exception(void) {
9439
9440
/* function exit code */
9441
}
9442
9443
/* "cfunc.to_py":65
9444
* @cname("__Pyx_CFunc_object____object____object____int___to_py")
9445
* cdef object __Pyx_CFunc_object____object____object____int___to_py(object (*f)(object, object, int) ):
9446
* def wrap(object arg0, object arg1, int arg2): # <<<<<<<<<<<<<<
9447
* """wrap(arg0, arg1, arg2: 'int')"""
9448
* return f(arg0, arg1, arg2)
9449
*/
9450
9451
/* Python wrapper */
9452
static PyObject *__pyx_pw_11cfunc_dot_to_py_53__Pyx_CFunc_object____object____object____int___to_py_1wrap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
9453
static char __pyx_doc_11cfunc_dot_to_py_53__Pyx_CFunc_object____object____object____int___to_py_wrap[] = "File: (starting at line 65)\nwrap(arg0, arg1, arg2: 'int')";
9454
static PyMethodDef __pyx_mdef_11cfunc_dot_to_py_53__Pyx_CFunc_object____object____object____int___to_py_1wrap = {"wrap", (PyCFunction)__pyx_pw_11cfunc_dot_to_py_53__Pyx_CFunc_object____object____object____int___to_py_1wrap, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11cfunc_dot_to_py_53__Pyx_CFunc_object____object____object____int___to_py_wrap};
9455
static PyObject *__pyx_pw_11cfunc_dot_to_py_53__Pyx_CFunc_object____object____object____int___to_py_1wrap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
9456
PyObject *__pyx_v_arg0 = 0;
9457
PyObject *__pyx_v_arg1 = 0;
9458
int __pyx_v_arg2;
9459
PyObject *__pyx_r = 0;
9460
__Pyx_RefNannyDeclarations
9461
__Pyx_RefNannySetupContext("wrap (wrapper)", 0);
9462
{
9463
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arg0,&__pyx_n_s_arg1,&__pyx_n_s_arg2,0};
9464
PyObject* values[3] = {0,0,0};
9465
if (unlikely(__pyx_kwds)) {
9466
Py_ssize_t kw_args;
9467
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
9468
switch (pos_args) {
9469
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
9470
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9471
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9472
case 0: break;
9473
default: goto __pyx_L5_argtuple_error;
9474
}
9475
kw_args = PyDict_Size(__pyx_kwds);
9476
switch (pos_args) {
9477
case 0:
9478
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_arg0)) != 0)) kw_args--;
9479
else goto __pyx_L5_argtuple_error;
9480
case 1:
9481
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_arg1)) != 0)) kw_args--;
9482
else {
9483
__Pyx_RaiseArgtupleInvalid("wrap", 1, 3, 3, 1); __PYX_ERR(5, 65, __pyx_L3_error)
9484
}
9485
case 2:
9486
if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_arg2)) != 0)) kw_args--;
9487
else {
9488
__Pyx_RaiseArgtupleInvalid("wrap", 1, 3, 3, 2); __PYX_ERR(5, 65, __pyx_L3_error)
9489
}
9490
}
9491
if (unlikely(kw_args > 0)) {
9492
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wrap") < 0)) __PYX_ERR(5, 65, __pyx_L3_error)
9493
}
9494
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
9495
goto __pyx_L5_argtuple_error;
9496
} else {
9497
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9498
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9499
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
9500
}
9501
__pyx_v_arg0 = values[0];
9502
__pyx_v_arg1 = values[1];
9503
__pyx_v_arg2 = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_arg2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 65, __pyx_L3_error)
9504
}
9505
goto __pyx_L4_argument_unpacking_done;
9506
__pyx_L5_argtuple_error:;
9507
__Pyx_RaiseArgtupleInvalid("wrap", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 65, __pyx_L3_error)
9508
__pyx_L3_error:;
9509
__Pyx_AddTraceback("cfunc.to_py.__Pyx_CFunc_object____object____object____int___to_py.wrap", __pyx_clineno, __pyx_lineno, __pyx_filename);
9510
__Pyx_RefNannyFinishContext();
9511
return NULL;
9512
__pyx_L4_argument_unpacking_done:;
9513
__pyx_r = __pyx_pf_11cfunc_dot_to_py_53__Pyx_CFunc_object____object____object____int___to_py_wrap(__pyx_self, __pyx_v_arg0, __pyx_v_arg1, __pyx_v_arg2);
9514
9515
/* function exit code */
9516
__Pyx_RefNannyFinishContext();
9517
return __pyx_r;
9518
}
9519
9520
static PyObject *__pyx_pf_11cfunc_dot_to_py_53__Pyx_CFunc_object____object____object____int___to_py_wrap(PyObject *__pyx_self, PyObject *__pyx_v_arg0, PyObject *__pyx_v_arg1, int __pyx_v_arg2) {
9521
struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py *__pyx_cur_scope;
9522
struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py *__pyx_outer_scope;
9523
PyObject *__pyx_r = NULL;
9524
__Pyx_RefNannyDeclarations
9525
PyObject *__pyx_t_1 = NULL;
9526
__Pyx_RefNannySetupContext("wrap", 0);
9527
__pyx_outer_scope = (struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py *) __Pyx_CyFunction_GetClosure(__pyx_self);
9528
__pyx_cur_scope = __pyx_outer_scope;
9529
9530
/* "cfunc.to_py":67
9531
* def wrap(object arg0, object arg1, int arg2):
9532
* """wrap(arg0, arg1, arg2: 'int')"""
9533
* return f(arg0, arg1, arg2) # <<<<<<<<<<<<<<
9534
* return wrap
9535
*
9536
*/
9537
__Pyx_XDECREF(__pyx_r);
9538
__pyx_t_1 = __pyx_cur_scope->__pyx_v_f(__pyx_v_arg0, __pyx_v_arg1, __pyx_v_arg2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 67, __pyx_L1_error)
9539
__Pyx_GOTREF(__pyx_t_1);
9540
__pyx_r = __pyx_t_1;
9541
__pyx_t_1 = 0;
9542
goto __pyx_L0;
9543
9544
/* "cfunc.to_py":65
9545
* @cname("__Pyx_CFunc_object____object____object____int___to_py")
9546
* cdef object __Pyx_CFunc_object____object____object____int___to_py(object (*f)(object, object, int) ):
9547
* def wrap(object arg0, object arg1, int arg2): # <<<<<<<<<<<<<<
9548
* """wrap(arg0, arg1, arg2: 'int')"""
9549
* return f(arg0, arg1, arg2)
9550
*/
9551
9552
/* function exit code */
9553
__pyx_L1_error:;
9554
__Pyx_XDECREF(__pyx_t_1);
9555
__Pyx_AddTraceback("cfunc.to_py.__Pyx_CFunc_object____object____object____int___to_py.wrap", __pyx_clineno, __pyx_lineno, __pyx_filename);
9556
__pyx_r = NULL;
9557
__pyx_L0:;
9558
__Pyx_XGIVEREF(__pyx_r);
9559
__Pyx_RefNannyFinishContext();
9560
return __pyx_r;
9561
}
9562
9563
/* "cfunc.to_py":64
9564
*
9565
* @cname("__Pyx_CFunc_object____object____object____int___to_py")
9566
* cdef object __Pyx_CFunc_object____object____object____int___to_py(object (*f)(object, object, int) ): # <<<<<<<<<<<<<<
9567
* def wrap(object arg0, object arg1, int arg2):
9568
* """wrap(arg0, arg1, arg2: 'int')"""
9569
*/
9570
9571
static PyObject *__Pyx_CFunc_object____object____object____int___to_py(PyObject *(*__pyx_v_f)(PyObject *, PyObject *, int)) {
9572
struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py *__pyx_cur_scope;
9573
PyObject *__pyx_v_wrap = 0;
9574
PyObject *__pyx_r = NULL;
9575
__Pyx_RefNannyDeclarations
9576
PyObject *__pyx_t_1 = NULL;
9577
__Pyx_RefNannySetupContext("__Pyx_CFunc_object____object____object____int___to_py", 0);
9578
__pyx_cur_scope = (struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py *)__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py(__pyx_ptype___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py, __pyx_empty_tuple, NULL);
9579
if (unlikely(!__pyx_cur_scope)) {
9580
__pyx_cur_scope = ((struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py *)Py_None);
9581
__Pyx_INCREF(Py_None);
9582
__PYX_ERR(5, 64, __pyx_L1_error)
9583
} else {
9584
__Pyx_GOTREF(__pyx_cur_scope);
9585
}
9586
__pyx_cur_scope->__pyx_v_f = __pyx_v_f;
9587
9588
/* "cfunc.to_py":65
9589
* @cname("__Pyx_CFunc_object____object____object____int___to_py")
9590
* cdef object __Pyx_CFunc_object____object____object____int___to_py(object (*f)(object, object, int) ):
9591
* def wrap(object arg0, object arg1, int arg2): # <<<<<<<<<<<<<<
9592
* """wrap(arg0, arg1, arg2: 'int')"""
9593
* return f(arg0, arg1, arg2)
9594
*/
9595
__pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_11cfunc_dot_to_py_53__Pyx_CFunc_object____object____object____int___to_py_1wrap, 0, __pyx_n_s_Pyx_CFunc_object____object, ((PyObject*)__pyx_cur_scope), __pyx_n_s_cfunc_to_py, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 65, __pyx_L1_error)
9596
__Pyx_GOTREF(__pyx_t_1);
9597
__pyx_v_wrap = __pyx_t_1;
9598
__pyx_t_1 = 0;
9599
9600
/* "cfunc.to_py":68
9601
* """wrap(arg0, arg1, arg2: 'int')"""
9602
* return f(arg0, arg1, arg2)
9603
* return wrap # <<<<<<<<<<<<<<
9604
*
9605
*
9606
*/
9607
__Pyx_XDECREF(__pyx_r);
9608
__Pyx_INCREF(__pyx_v_wrap);
9609
__pyx_r = __pyx_v_wrap;
9610
goto __pyx_L0;
9611
9612
/* "cfunc.to_py":64
9613
*
9614
* @cname("__Pyx_CFunc_object____object____object____int___to_py")
9615
* cdef object __Pyx_CFunc_object____object____object____int___to_py(object (*f)(object, object, int) ): # <<<<<<<<<<<<<<
9616
* def wrap(object arg0, object arg1, int arg2):
9617
* """wrap(arg0, arg1, arg2: 'int')"""
9618
*/
9619
9620
/* function exit code */
9621
__pyx_L1_error:;
9622
__Pyx_XDECREF(__pyx_t_1);
9623
__Pyx_AddTraceback("cfunc.to_py.__Pyx_CFunc_object____object____object____int___to_py", __pyx_clineno, __pyx_lineno, __pyx_filename);
9624
__pyx_r = 0;
9625
__pyx_L0:;
9626
__Pyx_XDECREF(__pyx_v_wrap);
9627
__Pyx_DECREF(((PyObject *)__pyx_cur_scope));
9628
__Pyx_XGIVEREF(__pyx_r);
9629
__Pyx_RefNannyFinishContext();
9630
return __pyx_r;
9631
}
9632
9633
static struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py *__pyx_freelist___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py[8];
9634
static int __pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py = 0;
9635
9636
static PyObject *__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
9637
PyObject *o;
9638
if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py)))) {
9639
o = (PyObject*)__pyx_freelist___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py[--__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py];
9640
memset(o, 0, sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py));
9641
(void) PyObject_INIT(o, t);
9642
} else {
9643
o = (*t->tp_alloc)(t, 0);
9644
if (unlikely(!o)) return 0;
9645
}
9646
return o;
9647
}
9648
9649
static void __pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py(PyObject *o) {
9650
if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py)))) {
9651
__pyx_freelist___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py[__pyx_freecount___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py++] = ((struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py *)o);
9652
} else {
9653
(*Py_TYPE(o)->tp_free)(o);
9654
}
9655
}
9656
9657
static PyTypeObject __pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py = {
9658
PyVarObject_HEAD_INIT(0, 0)
9659
"code.alex.psage.psage.ellcurve.minmodel.sqrt5.__pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py", /*tp_name*/
9660
sizeof(struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py), /*tp_basicsize*/
9661
0, /*tp_itemsize*/
9662
__pyx_tp_dealloc___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py, /*tp_dealloc*/
9663
0, /*tp_print*/
9664
0, /*tp_getattr*/
9665
0, /*tp_setattr*/
9666
#if PY_MAJOR_VERSION < 3
9667
0, /*tp_compare*/
9668
#endif
9669
#if PY_MAJOR_VERSION >= 3
9670
0, /*tp_as_async*/
9671
#endif
9672
0, /*tp_repr*/
9673
0, /*tp_as_number*/
9674
0, /*tp_as_sequence*/
9675
0, /*tp_as_mapping*/
9676
0, /*tp_hash*/
9677
0, /*tp_call*/
9678
0, /*tp_str*/
9679
0, /*tp_getattro*/
9680
0, /*tp_setattro*/
9681
0, /*tp_as_buffer*/
9682
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
9683
0, /*tp_doc*/
9684
0, /*tp_traverse*/
9685
0, /*tp_clear*/
9686
0, /*tp_richcompare*/
9687
0, /*tp_weaklistoffset*/
9688
0, /*tp_iter*/
9689
0, /*tp_iternext*/
9690
0, /*tp_methods*/
9691
0, /*tp_members*/
9692
0, /*tp_getset*/
9693
0, /*tp_base*/
9694
0, /*tp_dict*/
9695
0, /*tp_descr_get*/
9696
0, /*tp_descr_set*/
9697
0, /*tp_dictoffset*/
9698
0, /*tp_init*/
9699
0, /*tp_alloc*/
9700
__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py, /*tp_new*/
9701
0, /*tp_free*/
9702
0, /*tp_is_gc*/
9703
0, /*tp_bases*/
9704
0, /*tp_mro*/
9705
0, /*tp_cache*/
9706
0, /*tp_subclasses*/
9707
0, /*tp_weaklist*/
9708
0, /*tp_del*/
9709
0, /*tp_version_tag*/
9710
#if PY_VERSION_HEX >= 0x030400a1
9711
0, /*tp_finalize*/
9712
#endif
9713
};
9714
9715
static PyMethodDef __pyx_methods[] = {
9716
{"f_map", (PyCFunction)__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_1f_map, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_f_map},
9717
{"canonical_model_c_invariants", (PyCFunction)__pyx_pw_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_5canonical_model_c_invariants, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_4canonical_model_c_invariants},
9718
{0, 0, 0, 0}
9719
};
9720
9721
#if PY_MAJOR_VERSION >= 3
9722
static struct PyModuleDef __pyx_moduledef = {
9723
#if PY_VERSION_HEX < 0x03020000
9724
{ PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
9725
#else
9726
PyModuleDef_HEAD_INIT,
9727
#endif
9728
"sqrt5",
9729
__pyx_k_File_sqrt5_pyx_starting_at_line, /* m_doc */
9730
-1, /* m_size */
9731
__pyx_methods /* m_methods */,
9732
NULL, /* m_reload */
9733
NULL, /* m_traverse */
9734
NULL, /* m_clear */
9735
NULL /* m_free */
9736
};
9737
#endif
9738
9739
static __Pyx_StringTabEntry __pyx_string_tab[] = {
9740
{&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
9741
{&__pyx_n_s_D1, __pyx_k_D1, sizeof(__pyx_k_D1), 0, 0, 1, 1},
9742
{&__pyx_n_s_D2, __pyx_k_D2, sizeof(__pyx_k_D2), 0, 0, 1, 1},
9743
{&__pyx_n_s_E, __pyx_k_E, sizeof(__pyx_k_E), 0, 0, 1, 1},
9744
{&__pyx_kp_s_E_must_be_an_elliptic_curve, __pyx_k_E_must_be_an_elliptic_curve, sizeof(__pyx_k_E_must_be_an_elliptic_curve), 0, 0, 1, 0},
9745
{&__pyx_kp_s_E_must_be_over_Q_sqrt_5, __pyx_k_E_must_be_over_Q_sqrt_5, sizeof(__pyx_k_E_must_be_over_Q_sqrt_5), 0, 0, 1, 0},
9746
{&__pyx_n_s_EllipticCurve, __pyx_k_EllipticCurve, sizeof(__pyx_k_EllipticCurve), 0, 0, 1, 1},
9747
{&__pyx_n_s_K, __pyx_k_K, sizeof(__pyx_k_K), 0, 0, 1, 1},
9748
{&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
9749
{&__pyx_n_s_P2, __pyx_k_P2, sizeof(__pyx_k_P2), 0, 0, 1, 1},
9750
{&__pyx_n_s_P3, __pyx_k_P3, sizeof(__pyx_k_P3), 0, 0, 1, 1},
9751
{&__pyx_n_s_Pyx_CFunc_object____object, __pyx_k_Pyx_CFunc_object____object, sizeof(__pyx_k_Pyx_CFunc_object____object), 0, 0, 1, 1},
9752
{&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
9753
{&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
9754
{&__pyx_n_s_a1, __pyx_k_a1, sizeof(__pyx_k_a1), 0, 0, 1, 1},
9755
{&__pyx_n_s_a1p, __pyx_k_a1p, sizeof(__pyx_k_a1p), 0, 0, 1, 1},
9756
{&__pyx_n_s_a2, __pyx_k_a2, sizeof(__pyx_k_a2), 0, 0, 1, 1},
9757
{&__pyx_n_s_a2p, __pyx_k_a2p, sizeof(__pyx_k_a2p), 0, 0, 1, 1},
9758
{&__pyx_n_s_a3, __pyx_k_a3, sizeof(__pyx_k_a3), 0, 0, 1, 1},
9759
{&__pyx_n_s_a3p, __pyx_k_a3p, sizeof(__pyx_k_a3p), 0, 0, 1, 1},
9760
{&__pyx_n_s_a4, __pyx_k_a4, sizeof(__pyx_k_a4), 0, 0, 1, 1},
9761
{&__pyx_n_s_a4p, __pyx_k_a4p, sizeof(__pyx_k_a4p), 0, 0, 1, 1},
9762
{&__pyx_n_s_a6, __pyx_k_a6, sizeof(__pyx_k_a6), 0, 0, 1, 1},
9763
{&__pyx_n_s_a6p, __pyx_k_a6p, sizeof(__pyx_k_a6p), 0, 0, 1, 1},
9764
{&__pyx_n_s_a_invariants, __pyx_k_a_invariants, sizeof(__pyx_k_a_invariants), 0, 0, 1, 1},
9765
{&__pyx_n_s_arg0, __pyx_k_arg0, sizeof(__pyx_k_arg0), 0, 0, 1, 1},
9766
{&__pyx_n_s_arg1, __pyx_k_arg1, sizeof(__pyx_k_arg1), 0, 0, 1, 1},
9767
{&__pyx_n_s_arg2, __pyx_k_arg2, sizeof(__pyx_k_arg2), 0, 0, 1, 1},
9768
{&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
9769
{&__pyx_n_s_base_field, __pyx_k_base_field, sizeof(__pyx_k_base_field), 0, 0, 1, 1},
9770
{&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
9771
{&__pyx_n_s_canonical_model, __pyx_k_canonical_model, sizeof(__pyx_k_canonical_model), 0, 0, 1, 1},
9772
{&__pyx_n_s_cfunc_to_py, __pyx_k_cfunc_to_py, sizeof(__pyx_k_cfunc_to_py), 0, 0, 1, 1},
9773
{&__pyx_n_s_code_alex_psage_psage_ellcurve_m, __pyx_k_code_alex_psage_psage_ellcurve_m, sizeof(__pyx_k_code_alex_psage_psage_ellcurve_m), 0, 0, 1, 1},
9774
{&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1},
9775
{&__pyx_n_s_disc, __pyx_k_disc, sizeof(__pyx_k_disc), 0, 0, 1, 1},
9776
{&__pyx_n_s_discriminant, __pyx_k_discriminant, sizeof(__pyx_k_discriminant), 0, 0, 1, 1},
9777
{&__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},
9778
{&__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},
9779
{&__pyx_n_s_gen, __pyx_k_gen, sizeof(__pyx_k_gen), 0, 0, 1, 1},
9780
{&__pyx_n_s_ideal, __pyx_k_ideal, sizeof(__pyx_k_ideal), 0, 0, 1, 1},
9781
{&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
9782
{&__pyx_n_s_init_memory_functions, __pyx_k_init_memory_functions, sizeof(__pyx_k_init_memory_functions), 0, 0, 1, 1},
9783
{&__pyx_n_s_left, __pyx_k_left, sizeof(__pyx_k_left), 0, 0, 1, 1},
9784
{&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
9785
{&__pyx_n_s_mod, __pyx_k_mod, sizeof(__pyx_k_mod), 0, 0, 1, 1},
9786
{&__pyx_n_s_op, __pyx_k_op, sizeof(__pyx_k_op), 0, 0, 1, 1},
9787
{&__pyx_n_s_parent, __pyx_k_parent, sizeof(__pyx_k_parent), 0, 0, 1, 1},
9788
{&__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},
9789
{&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
9790
{&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1},
9791
{&__pyx_n_s_ra1p, __pyx_k_ra1p, sizeof(__pyx_k_ra1p), 0, 0, 1, 1},
9792
{&__pyx_n_s_right, __pyx_k_right, sizeof(__pyx_k_right), 0, 0, 1, 1},
9793
{&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
9794
{&__pyx_n_s_sa1, __pyx_k_sa1, sizeof(__pyx_k_sa1), 0, 0, 1, 1},
9795
{&__pyx_n_s_sage_ext_memory, __pyx_k_sage_ext_memory, sizeof(__pyx_k_sage_ext_memory), 0, 0, 1, 1},
9796
{&__pyx_n_s_sage_schemes_elliptic_curves_con, __pyx_k_sage_schemes_elliptic_curves_con, sizeof(__pyx_k_sage_schemes_elliptic_curves_con), 0, 0, 1, 1},
9797
{&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
9798
{&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
9799
{&__pyx_n_s_t1, __pyx_k_t1, sizeof(__pyx_k_t1), 0, 0, 1, 1},
9800
{&__pyx_n_s_t2, __pyx_k_t2, sizeof(__pyx_k_t2), 0, 0, 1, 1},
9801
{&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
9802
{&__pyx_n_s_u, __pyx_k_u, sizeof(__pyx_k_u), 0, 0, 1, 1},
9803
{&__pyx_n_s_u1, __pyx_k_u1, sizeof(__pyx_k_u1), 0, 0, 1, 1},
9804
{&__pyx_n_s_u2, __pyx_k_u2, sizeof(__pyx_k_u2), 0, 0, 1, 1},
9805
{&__pyx_n_s_wrap, __pyx_k_wrap, sizeof(__pyx_k_wrap), 0, 0, 1, 1},
9806
{&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
9807
{&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1},
9808
{0, 0, 0, 0, 0, 0, 0}
9809
};
9810
static int __Pyx_InitCachedBuiltins(void) {
9811
__pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 366, __pyx_L1_error)
9812
__pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 369, __pyx_L1_error)
9813
__pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(2, 91, __pyx_L1_error)
9814
return 0;
9815
__pyx_L1_error:;
9816
return -1;
9817
}
9818
9819
static int __Pyx_InitCachedConstants(void) {
9820
__Pyx_RefNannyDeclarations
9821
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
9822
9823
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":385
9824
* mpz_neg(u1.value, u1.value)
9825
* mpz_clear(t1); mpz_clear(t2)
9826
* u = K(u1)+K.gen(0)*K(u2) # <<<<<<<<<<<<<<
9827
* a1,a2,a3,a4,a6 = u*a1,u*u*a2,u*u*u*a3,a4*u**4,a6*u**6
9828
* P2 = K.ideal(2)
9829
*/
9830
__pyx_tuple_ = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 385, __pyx_L1_error)
9831
__Pyx_GOTREF(__pyx_tuple_);
9832
__Pyx_GIVEREF(__pyx_tuple_);
9833
9834
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":387
9835
* u = K(u1)+K.gen(0)*K(u2)
9836
* a1,a2,a3,a4,a6 = u*a1,u*u*a2,u*u*u*a3,a4*u**4,a6*u**6
9837
* P2 = K.ideal(2) # <<<<<<<<<<<<<<
9838
* P3 = K.ideal(3)
9839
* a1p = a1.mod(P2)
9840
*/
9841
__pyx_tuple__2 = PyTuple_Pack(1, __pyx_int_2); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 387, __pyx_L1_error)
9842
__Pyx_GOTREF(__pyx_tuple__2);
9843
__Pyx_GIVEREF(__pyx_tuple__2);
9844
9845
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":388
9846
* a1,a2,a3,a4,a6 = u*a1,u*u*a2,u*u*u*a3,a4*u**4,a6*u**6
9847
* P2 = K.ideal(2)
9848
* P3 = K.ideal(3) # <<<<<<<<<<<<<<
9849
* a1p = a1.mod(P2)
9850
* s = (a1p - a1)/K(2)
9851
*/
9852
__pyx_tuple__3 = PyTuple_Pack(1, __pyx_int_3); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 388, __pyx_L1_error)
9853
__Pyx_GOTREF(__pyx_tuple__3);
9854
__Pyx_GIVEREF(__pyx_tuple__3);
9855
9856
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":390
9857
* P3 = K.ideal(3)
9858
* a1p = a1.mod(P2)
9859
* s = (a1p - a1)/K(2) # <<<<<<<<<<<<<<
9860
* sa1 = s*a1
9861
* a2p = (a2 - sa1 - s**2).mod(P3)
9862
*/
9863
__pyx_tuple__4 = PyTuple_Pack(1, __pyx_int_2); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 390, __pyx_L1_error)
9864
__Pyx_GOTREF(__pyx_tuple__4);
9865
__Pyx_GIVEREF(__pyx_tuple__4);
9866
9867
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":393
9868
* sa1 = s*a1
9869
* a2p = (a2 - sa1 - s**2).mod(P3)
9870
* r = (a2p - a2 + sa1 + s**2)/K(3) # <<<<<<<<<<<<<<
9871
* ra1p = r*a1p
9872
* a3p = (a3+ra1p).mod(P2)
9873
*/
9874
__pyx_tuple__5 = PyTuple_Pack(1, __pyx_int_3); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 393, __pyx_L1_error)
9875
__Pyx_GOTREF(__pyx_tuple__5);
9876
__Pyx_GIVEREF(__pyx_tuple__5);
9877
9878
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":396
9879
* ra1p = r*a1p
9880
* a3p = (a3+ra1p).mod(P2)
9881
* t = r*s + (a3p - a3 - ra1p)/K(2) # <<<<<<<<<<<<<<
9882
* a4p = a4 - s*a3 + 2*r*a2 - (t+r*s)*a1 + 3*r**2 - 2*s*t
9883
* a6p = a6 + r*a4 + r**2*a2 + r**3 - t*a3 - t**2 - r*t*a1
9884
*/
9885
__pyx_tuple__6 = PyTuple_Pack(1, __pyx_int_2); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 396, __pyx_L1_error)
9886
__Pyx_GOTREF(__pyx_tuple__6);
9887
__Pyx_GIVEREF(__pyx_tuple__6);
9888
9889
/* "cfunc.to_py":65
9890
* @cname("__Pyx_CFunc_object____object____object____int___to_py")
9891
* cdef object __Pyx_CFunc_object____object____object____int___to_py(object (*f)(object, object, int) ):
9892
* def wrap(object arg0, object arg1, int arg2): # <<<<<<<<<<<<<<
9893
* """wrap(arg0, arg1, arg2: 'int')"""
9894
* return f(arg0, arg1, arg2)
9895
*/
9896
__pyx_tuple__7 = PyTuple_Pack(3, __pyx_n_s_arg0, __pyx_n_s_arg1, __pyx_n_s_arg2); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(5, 65, __pyx_L1_error)
9897
__Pyx_GOTREF(__pyx_tuple__7);
9898
__Pyx_GIVEREF(__pyx_tuple__7);
9899
__pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_wrap, 65, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(5, 65, __pyx_L1_error)
9900
9901
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":345
9902
* return c,d,e,f
9903
*
9904
* def canonical_model(E): # <<<<<<<<<<<<<<
9905
* """
9906
* Given a global minimal model E over Q(sqrt5) returns a canonical global
9907
*/
9908
__pyx_tuple__9 = PyTuple_Pack(26, __pyx_n_s_E, __pyx_n_s_K, __pyx_n_s_D1, __pyx_n_s_D2, __pyx_n_s_a1, __pyx_n_s_a2, __pyx_n_s_a3, __pyx_n_s_a4, __pyx_n_s_a6, __pyx_n_s_u1, __pyx_n_s_u2, __pyx_n_s_t1, __pyx_n_s_t2, __pyx_n_s_u, __pyx_n_s_P2, __pyx_n_s_P3, __pyx_n_s_a1p, __pyx_n_s_s, __pyx_n_s_sa1, __pyx_n_s_a2p, __pyx_n_s_r, __pyx_n_s_ra1p, __pyx_n_s_a3p, __pyx_n_s_t, __pyx_n_s_a4p, __pyx_n_s_a6p); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 345, __pyx_L1_error)
9909
__Pyx_GOTREF(__pyx_tuple__9);
9910
__Pyx_GIVEREF(__pyx_tuple__9);
9911
__pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 26, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_projects_68c8b2b8_03ba_44d4_a0d, __pyx_n_s_canonical_model, 345, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 345, __pyx_L1_error)
9912
__Pyx_RefNannyFinishContext();
9913
return 0;
9914
__pyx_L1_error:;
9915
__Pyx_RefNannyFinishContext();
9916
return -1;
9917
}
9918
9919
static int __Pyx_InitGlobals(void) {
9920
if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
9921
__pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
9922
__pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
9923
__pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
9924
__pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
9925
__pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) __PYX_ERR(0, 1, __pyx_L1_error)
9926
__pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) __PYX_ERR(0, 1, __pyx_L1_error)
9927
__pyx_int_4294967295 = PyInt_FromString((char *)"4294967295", 0, 0); if (unlikely(!__pyx_int_4294967295)) __PYX_ERR(0, 1, __pyx_L1_error)
9928
__pyx_int_9223372036854775808L = PyLong_FromString((char *)"9223372036854775808", 0, 0); if (unlikely(!__pyx_int_9223372036854775808L)) __PYX_ERR(0, 1, __pyx_L1_error)
9929
return 0;
9930
__pyx_L1_error:;
9931
return -1;
9932
}
9933
9934
#if PY_MAJOR_VERSION < 3
9935
PyMODINIT_FUNC initsqrt5(void); /*proto*/
9936
PyMODINIT_FUNC initsqrt5(void)
9937
#else
9938
PyMODINIT_FUNC PyInit_sqrt5(void); /*proto*/
9939
PyMODINIT_FUNC PyInit_sqrt5(void)
9940
#endif
9941
{
9942
PyObject *__pyx_t_1 = NULL;
9943
PyObject *__pyx_t_2 = NULL;
9944
int __pyx_t_3;
9945
PyObject *__pyx_t_4 = NULL;
9946
PyObject *__pyx_t_5 = NULL;
9947
__Pyx_RefNannyDeclarations
9948
#if CYTHON_REFNANNY
9949
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
9950
if (!__Pyx_RefNanny) {
9951
PyErr_Clear();
9952
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
9953
if (!__Pyx_RefNanny)
9954
Py_FatalError("failed to import 'refnanny' module");
9955
}
9956
#endif
9957
__Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_sqrt5(void)", 0);
9958
if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
9959
__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
9960
__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
9961
__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
9962
#ifdef __Pyx_CyFunction_USED
9963
if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
9964
#endif
9965
#ifdef __Pyx_FusedFunction_USED
9966
if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
9967
#endif
9968
#ifdef __Pyx_Coroutine_USED
9969
if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
9970
#endif
9971
#ifdef __Pyx_Generator_USED
9972
if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
9973
#endif
9974
#ifdef __Pyx_StopAsyncIteration_USED
9975
if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
9976
#endif
9977
/*--- Library function declarations ---*/
9978
/*--- Threads initialization code ---*/
9979
#if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
9980
#ifdef WITH_THREAD /* Python build with threading support? */
9981
PyEval_InitThreads();
9982
#endif
9983
#endif
9984
/*--- Module creation code ---*/
9985
#if PY_MAJOR_VERSION < 3
9986
__pyx_m = Py_InitModule4("sqrt5", __pyx_methods, __pyx_k_File_sqrt5_pyx_starting_at_line, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
9987
#else
9988
__pyx_m = PyModule_Create(&__pyx_moduledef);
9989
#endif
9990
if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
9991
__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
9992
Py_INCREF(__pyx_d);
9993
__pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
9994
#if CYTHON_COMPILING_IN_PYPY
9995
Py_INCREF(__pyx_b);
9996
#endif
9997
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
9998
/*--- Initialize various global constants etc. ---*/
9999
if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10000
#if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
10001
if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10002
#endif
10003
if (__pyx_module_is_main_code__alex__psage__psage__ellcurve__minmodel__sqrt5) {
10004
if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10005
}
10006
#if PY_MAJOR_VERSION >= 3
10007
{
10008
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
10009
if (!PyDict_GetItemString(modules, "code.alex.psage.psage.ellcurve.minmodel.sqrt5")) {
10010
if (unlikely(PyDict_SetItemString(modules, "code.alex.psage.psage.ellcurve.minmodel.sqrt5", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
10011
}
10012
}
10013
#endif
10014
/*--- Builtin init code ---*/
10015
if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10016
/*--- Constants init code ---*/
10017
if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10018
/*--- Global init code ---*/
10019
/*--- Variable export code ---*/
10020
/*--- Function export code ---*/
10021
/*--- Type init code ---*/
10022
if (PyType_Ready(&__pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py) < 0) __PYX_ERR(5, 64, __pyx_L1_error)
10023
__pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py.tp_print = 0;
10024
__pyx_ptype___pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py = &__pyx_scope_struct____Pyx_CFunc_object____object____object____int___to_py;
10025
/*--- Type import code ---*/
10026
__pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
10027
#if CYTHON_COMPILING_IN_PYPY
10028
sizeof(PyTypeObject),
10029
#else
10030
sizeof(PyHeapTypeObject),
10031
#endif
10032
0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(6, 9, __pyx_L1_error)
10033
__pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) __PYX_ERR(7, 8, __pyx_L1_error)
10034
__pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) __PYX_ERR(8, 15, __pyx_L1_error)
10035
__pyx_ptype_4sage_9structure_11sage_object_SageObject = __Pyx_ImportType("sage.structure.sage_object", "SageObject", sizeof(struct __pyx_obj_4sage_9structure_11sage_object_SageObject), 1); if (unlikely(!__pyx_ptype_4sage_9structure_11sage_object_SageObject)) __PYX_ERR(3, 9, __pyx_L1_error)
10036
__pyx_ptype_4sage_9structure_15category_object_CategoryObject = __Pyx_ImportType("sage.structure.category_object", "CategoryObject", sizeof(struct __pyx_obj_4sage_9structure_15category_object_CategoryObject), 1); if (unlikely(!__pyx_ptype_4sage_9structure_15category_object_CategoryObject)) __PYX_ERR(9, 15, __pyx_L1_error)
10037
__pyx_vtabptr_4sage_9structure_15category_object_CategoryObject = (struct __pyx_vtabstruct_4sage_9structure_15category_object_CategoryObject*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_15category_object_CategoryObject->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_15category_object_CategoryObject)) __PYX_ERR(9, 15, __pyx_L1_error)
10038
__pyx_ptype_4sage_9structure_11coerce_dict_MonoDict = __Pyx_ImportType("sage.structure.coerce_dict", "MonoDict", sizeof(struct __pyx_obj_4sage_9structure_11coerce_dict_MonoDict), 1); if (unlikely(!__pyx_ptype_4sage_9structure_11coerce_dict_MonoDict)) __PYX_ERR(10, 7, __pyx_L1_error)
10039
__pyx_vtabptr_4sage_9structure_11coerce_dict_MonoDict = (struct __pyx_vtabstruct_4sage_9structure_11coerce_dict_MonoDict*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_11coerce_dict_MonoDict->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_11coerce_dict_MonoDict)) __PYX_ERR(10, 7, __pyx_L1_error)
10040
__pyx_ptype_4sage_9structure_11coerce_dict_TripleDict = __Pyx_ImportType("sage.structure.coerce_dict", "TripleDict", sizeof(struct __pyx_obj_4sage_9structure_11coerce_dict_TripleDict), 1); if (unlikely(!__pyx_ptype_4sage_9structure_11coerce_dict_TripleDict)) __PYX_ERR(10, 23, __pyx_L1_error)
10041
__pyx_vtabptr_4sage_9structure_11coerce_dict_TripleDict = (struct __pyx_vtabstruct_4sage_9structure_11coerce_dict_TripleDict*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_11coerce_dict_TripleDict->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_11coerce_dict_TripleDict)) __PYX_ERR(10, 23, __pyx_L1_error)
10042
__pyx_ptype_4sage_9structure_6parent_Parent = __Pyx_ImportType("sage.structure.parent", "Parent", sizeof(struct __pyx_obj_4sage_9structure_6parent_Parent), 1); if (unlikely(!__pyx_ptype_4sage_9structure_6parent_Parent)) __PYX_ERR(11, 12, __pyx_L1_error)
10043
__pyx_vtabptr_4sage_9structure_6parent_Parent = (struct __pyx_vtabstruct_4sage_9structure_6parent_Parent*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_6parent_Parent->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_6parent_Parent)) __PYX_ERR(11, 12, __pyx_L1_error)
10044
__pyx_ptype_4sage_4misc_18inherit_comparison_InheritComparisonMetaclass = __Pyx_ImportType("sage.misc.inherit_comparison", "InheritComparisonMetaclass", sizeof(struct __pyx_obj_4sage_4misc_18inherit_comparison_InheritComparisonMetaclass), 1); if (unlikely(!__pyx_ptype_4sage_4misc_18inherit_comparison_InheritComparisonMetaclass)) __PYX_ERR(12, 3, __pyx_L1_error)
10045
__pyx_ptype_4sage_9structure_7element_Element = __Pyx_ImportType("sage.structure.element", "Element", sizeof(struct __pyx_obj_4sage_9structure_7element_Element), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_Element)) __PYX_ERR(1, 169, __pyx_L1_error)
10046
__pyx_vtabptr_4sage_9structure_7element_Element = (struct __pyx_vtabstruct_4sage_9structure_7element_Element*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_Element->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_Element)) __PYX_ERR(1, 169, __pyx_L1_error)
10047
__pyx_ptype_4sage_9structure_7element_ElementWithCachedMethod = __Pyx_ImportType("sage.structure.element", "ElementWithCachedMethod", sizeof(struct __pyx_obj_4sage_9structure_7element_ElementWithCachedMethod), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_ElementWithCachedMethod)) __PYX_ERR(1, 192, __pyx_L1_error)
10048
__pyx_vtabptr_4sage_9structure_7element_ElementWithCachedMethod = (struct __pyx_vtabstruct_4sage_9structure_7element_ElementWithCachedMethod*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_ElementWithCachedMethod->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_ElementWithCachedMethod)) __PYX_ERR(1, 192, __pyx_L1_error)
10049
__pyx_ptype_4sage_9structure_7element_ModuleElement = __Pyx_ImportType("sage.structure.element", "ModuleElement", sizeof(struct __pyx_obj_4sage_9structure_7element_ModuleElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_ModuleElement)) __PYX_ERR(1, 195, __pyx_L1_error)
10050
__pyx_vtabptr_4sage_9structure_7element_ModuleElement = (struct __pyx_vtabstruct_4sage_9structure_7element_ModuleElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_ModuleElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_ModuleElement)) __PYX_ERR(1, 195, __pyx_L1_error)
10051
__pyx_ptype_4sage_9structure_7element_RingElement = __Pyx_ImportType("sage.structure.element", "RingElement", sizeof(struct __pyx_obj_4sage_9structure_7element_RingElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_RingElement)) __PYX_ERR(1, 197, __pyx_L1_error)
10052
__pyx_vtabptr_4sage_9structure_7element_RingElement = (struct __pyx_vtabstruct_4sage_9structure_7element_RingElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_RingElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_RingElement)) __PYX_ERR(1, 197, __pyx_L1_error)
10053
__pyx_ptype_4sage_9structure_7element_MonoidElement = __Pyx_ImportType("sage.structure.element", "MonoidElement", sizeof(struct __pyx_obj_4sage_9structure_7element_MonoidElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_MonoidElement)) __PYX_ERR(1, 208, __pyx_L1_error)
10054
__pyx_vtabptr_4sage_9structure_7element_MonoidElement = (struct __pyx_vtabstruct_4sage_9structure_7element_MonoidElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_MonoidElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_MonoidElement)) __PYX_ERR(1, 208, __pyx_L1_error)
10055
__pyx_ptype_4sage_9structure_7element_MultiplicativeGroupElement = __Pyx_ImportType("sage.structure.element", "MultiplicativeGroupElement", sizeof(struct __pyx_obj_4sage_9structure_7element_MultiplicativeGroupElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_MultiplicativeGroupElement)) __PYX_ERR(1, 211, __pyx_L1_error)
10056
__pyx_vtabptr_4sage_9structure_7element_MultiplicativeGroupElement = (struct __pyx_vtabstruct_4sage_9structure_7element_MultiplicativeGroupElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_MultiplicativeGroupElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_MultiplicativeGroupElement)) __PYX_ERR(1, 211, __pyx_L1_error)
10057
__pyx_ptype_4sage_9structure_7element_AdditiveGroupElement = __Pyx_ImportType("sage.structure.element", "AdditiveGroupElement", sizeof(struct __pyx_obj_4sage_9structure_7element_AdditiveGroupElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_AdditiveGroupElement)) __PYX_ERR(1, 214, __pyx_L1_error)
10058
__pyx_vtabptr_4sage_9structure_7element_AdditiveGroupElement = (struct __pyx_vtabstruct_4sage_9structure_7element_AdditiveGroupElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_AdditiveGroupElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_AdditiveGroupElement)) __PYX_ERR(1, 214, __pyx_L1_error)
10059
__pyx_ptype_4sage_9structure_7element_CommutativeRingElement = __Pyx_ImportType("sage.structure.element", "CommutativeRingElement", sizeof(struct __pyx_obj_4sage_9structure_7element_CommutativeRingElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_CommutativeRingElement)) __PYX_ERR(1, 220, __pyx_L1_error)
10060
__pyx_vtabptr_4sage_9structure_7element_CommutativeRingElement = (struct __pyx_vtabstruct_4sage_9structure_7element_CommutativeRingElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_CommutativeRingElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_CommutativeRingElement)) __PYX_ERR(1, 220, __pyx_L1_error)
10061
__pyx_ptype_4sage_9structure_7element_IntegralDomainElement = __Pyx_ImportType("sage.structure.element", "IntegralDomainElement", sizeof(struct __pyx_obj_4sage_9structure_7element_IntegralDomainElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_IntegralDomainElement)) __PYX_ERR(1, 223, __pyx_L1_error)
10062
__pyx_vtabptr_4sage_9structure_7element_IntegralDomainElement = (struct __pyx_vtabstruct_4sage_9structure_7element_IntegralDomainElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_IntegralDomainElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_IntegralDomainElement)) __PYX_ERR(1, 223, __pyx_L1_error)
10063
__pyx_ptype_4sage_9structure_7element_DedekindDomainElement = __Pyx_ImportType("sage.structure.element", "DedekindDomainElement", sizeof(struct __pyx_obj_4sage_9structure_7element_DedekindDomainElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_DedekindDomainElement)) __PYX_ERR(1, 226, __pyx_L1_error)
10064
__pyx_vtabptr_4sage_9structure_7element_DedekindDomainElement = (struct __pyx_vtabstruct_4sage_9structure_7element_DedekindDomainElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_DedekindDomainElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_DedekindDomainElement)) __PYX_ERR(1, 226, __pyx_L1_error)
10065
__pyx_ptype_4sage_9structure_7element_PrincipalIdealDomainElement = __Pyx_ImportType("sage.structure.element", "PrincipalIdealDomainElement", sizeof(struct __pyx_obj_4sage_9structure_7element_PrincipalIdealDomainElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_PrincipalIdealDomainElement)) __PYX_ERR(1, 229, __pyx_L1_error)
10066
__pyx_vtabptr_4sage_9structure_7element_PrincipalIdealDomainElement = (struct __pyx_vtabstruct_4sage_9structure_7element_PrincipalIdealDomainElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_PrincipalIdealDomainElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_PrincipalIdealDomainElement)) __PYX_ERR(1, 229, __pyx_L1_error)
10067
__pyx_ptype_4sage_9structure_7element_EuclideanDomainElement = __Pyx_ImportType("sage.structure.element", "EuclideanDomainElement", sizeof(struct __pyx_obj_4sage_9structure_7element_EuclideanDomainElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_EuclideanDomainElement)) __PYX_ERR(1, 232, __pyx_L1_error)
10068
__pyx_vtabptr_4sage_9structure_7element_EuclideanDomainElement = (struct __pyx_vtabstruct_4sage_9structure_7element_EuclideanDomainElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_EuclideanDomainElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_EuclideanDomainElement)) __PYX_ERR(1, 232, __pyx_L1_error)
10069
__pyx_ptype_4sage_9structure_7element_FieldElement = __Pyx_ImportType("sage.structure.element", "FieldElement", sizeof(struct __pyx_obj_4sage_9structure_7element_FieldElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_FieldElement)) __PYX_ERR(1, 236, __pyx_L1_error)
10070
__pyx_vtabptr_4sage_9structure_7element_FieldElement = (struct __pyx_vtabstruct_4sage_9structure_7element_FieldElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_FieldElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_FieldElement)) __PYX_ERR(1, 236, __pyx_L1_error)
10071
__pyx_ptype_4sage_9structure_7element_AlgebraElement = __Pyx_ImportType("sage.structure.element", "AlgebraElement", sizeof(struct __pyx_obj_4sage_9structure_7element_AlgebraElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_AlgebraElement)) __PYX_ERR(1, 239, __pyx_L1_error)
10072
__pyx_vtabptr_4sage_9structure_7element_AlgebraElement = (struct __pyx_vtabstruct_4sage_9structure_7element_AlgebraElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_AlgebraElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_AlgebraElement)) __PYX_ERR(1, 239, __pyx_L1_error)
10073
__pyx_ptype_4sage_9structure_7element_CommutativeAlgebraElement = __Pyx_ImportType("sage.structure.element", "CommutativeAlgebraElement", sizeof(struct __pyx_obj_4sage_9structure_7element_CommutativeAlgebraElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_CommutativeAlgebraElement)) __PYX_ERR(1, 242, __pyx_L1_error)
10074
__pyx_vtabptr_4sage_9structure_7element_CommutativeAlgebraElement = (struct __pyx_vtabstruct_4sage_9structure_7element_CommutativeAlgebraElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_CommutativeAlgebraElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_CommutativeAlgebraElement)) __PYX_ERR(1, 242, __pyx_L1_error)
10075
__pyx_ptype_4sage_9structure_7element_InfinityElement = __Pyx_ImportType("sage.structure.element", "InfinityElement", sizeof(struct __pyx_obj_4sage_9structure_7element_InfinityElement), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_InfinityElement)) __PYX_ERR(1, 245, __pyx_L1_error)
10076
__pyx_vtabptr_4sage_9structure_7element_InfinityElement = (struct __pyx_vtabstruct_4sage_9structure_7element_InfinityElement*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_InfinityElement->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_InfinityElement)) __PYX_ERR(1, 245, __pyx_L1_error)
10077
__pyx_ptype_4sage_9structure_7element_Vector = __Pyx_ImportType("sage.structure.element", "Vector", sizeof(struct __pyx_obj_4sage_9structure_7element_Vector), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_Vector)) __PYX_ERR(1, 249, __pyx_L1_error)
10078
__pyx_vtabptr_4sage_9structure_7element_Vector = (struct __pyx_vtabstruct_4sage_9structure_7element_Vector*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_Vector->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_Vector)) __PYX_ERR(1, 249, __pyx_L1_error)
10079
__pyx_ptype_4sage_9structure_7element_Matrix = __Pyx_ImportType("sage.structure.element", "Matrix", sizeof(struct __pyx_obj_4sage_9structure_7element_Matrix), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_Matrix)) __PYX_ERR(1, 264, __pyx_L1_error)
10080
__pyx_vtabptr_4sage_9structure_7element_Matrix = (struct __pyx_vtabstruct_4sage_9structure_7element_Matrix*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_Matrix->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_Matrix)) __PYX_ERR(1, 264, __pyx_L1_error)
10081
__pyx_ptype_4sage_9structure_7element_CoercionModel = __Pyx_ImportType("sage.structure.element", "CoercionModel", sizeof(struct __pyx_obj_4sage_9structure_7element_CoercionModel), 1); if (unlikely(!__pyx_ptype_4sage_9structure_7element_CoercionModel)) __PYX_ERR(1, 277, __pyx_L1_error)
10082
__pyx_vtabptr_4sage_9structure_7element_CoercionModel = (struct __pyx_vtabstruct_4sage_9structure_7element_CoercionModel*)__Pyx_GetVtable(__pyx_ptype_4sage_9structure_7element_CoercionModel->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_9structure_7element_CoercionModel)) __PYX_ERR(1, 277, __pyx_L1_error)
10083
__pyx_ptype_4sage_10categories_3map_Map = __Pyx_ImportType("sage.categories.map", "Map", sizeof(struct __pyx_obj_4sage_10categories_3map_Map), 1); if (unlikely(!__pyx_ptype_4sage_10categories_3map_Map)) __PYX_ERR(13, 4, __pyx_L1_error)
10084
__pyx_vtabptr_4sage_10categories_3map_Map = (struct __pyx_vtabstruct_4sage_10categories_3map_Map*)__Pyx_GetVtable(__pyx_ptype_4sage_10categories_3map_Map->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_10categories_3map_Map)) __PYX_ERR(13, 4, __pyx_L1_error)
10085
__pyx_ptype_4sage_10categories_3map_Section = __Pyx_ImportType("sage.categories.map", "Section", sizeof(struct __pyx_obj_4sage_10categories_3map_Section), 1); if (unlikely(!__pyx_ptype_4sage_10categories_3map_Section)) __PYX_ERR(13, 25, __pyx_L1_error)
10086
__pyx_vtabptr_4sage_10categories_3map_Section = (struct __pyx_vtabstruct_4sage_10categories_3map_Section*)__Pyx_GetVtable(__pyx_ptype_4sage_10categories_3map_Section->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_10categories_3map_Section)) __PYX_ERR(13, 25, __pyx_L1_error)
10087
__pyx_ptype_4sage_10categories_3map_FormalCompositeMap = __Pyx_ImportType("sage.categories.map", "FormalCompositeMap", sizeof(struct __pyx_obj_4sage_10categories_3map_FormalCompositeMap), 1); if (unlikely(!__pyx_ptype_4sage_10categories_3map_FormalCompositeMap)) __PYX_ERR(13, 28, __pyx_L1_error)
10088
__pyx_vtabptr_4sage_10categories_3map_FormalCompositeMap = (struct __pyx_vtabstruct_4sage_10categories_3map_FormalCompositeMap*)__Pyx_GetVtable(__pyx_ptype_4sage_10categories_3map_FormalCompositeMap->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_10categories_3map_FormalCompositeMap)) __PYX_ERR(13, 28, __pyx_L1_error)
10089
__pyx_ptype_4sage_10categories_8morphism_Morphism = __Pyx_ImportType("sage.categories.morphism", "Morphism", sizeof(struct __pyx_obj_4sage_10categories_8morphism_Morphism), 1); if (unlikely(!__pyx_ptype_4sage_10categories_8morphism_Morphism)) __PYX_ERR(14, 5, __pyx_L1_error)
10090
__pyx_vtabptr_4sage_10categories_8morphism_Morphism = (struct __pyx_vtabstruct_4sage_10categories_8morphism_Morphism*)__Pyx_GetVtable(__pyx_ptype_4sage_10categories_8morphism_Morphism->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_10categories_8morphism_Morphism)) __PYX_ERR(14, 5, __pyx_L1_error)
10091
__pyx_ptype_4sage_10categories_8morphism_SetMorphism = __Pyx_ImportType("sage.categories.morphism", "SetMorphism", sizeof(struct __pyx_obj_4sage_10categories_8morphism_SetMorphism), 1); if (unlikely(!__pyx_ptype_4sage_10categories_8morphism_SetMorphism)) __PYX_ERR(14, 8, __pyx_L1_error)
10092
__pyx_vtabptr_4sage_10categories_8morphism_SetMorphism = (struct __pyx_vtabstruct_4sage_10categories_8morphism_SetMorphism*)__Pyx_GetVtable(__pyx_ptype_4sage_10categories_8morphism_SetMorphism->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_10categories_8morphism_SetMorphism)) __PYX_ERR(14, 8, __pyx_L1_error)
10093
__pyx_ptype_4sage_5rings_7integer_Integer = __Pyx_ImportType("sage.rings.integer", "Integer", sizeof(struct __pyx_obj_4sage_5rings_7integer_Integer), 1); if (unlikely(!__pyx_ptype_4sage_5rings_7integer_Integer)) __PYX_ERR(15, 7, __pyx_L1_error)
10094
__pyx_vtabptr_4sage_5rings_7integer_Integer = (struct __pyx_vtabstruct_4sage_5rings_7integer_Integer*)__Pyx_GetVtable(__pyx_ptype_4sage_5rings_7integer_Integer->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_5rings_7integer_Integer)) __PYX_ERR(15, 7, __pyx_L1_error)
10095
__pyx_ptype_4sage_5rings_7integer_int_to_Z = __Pyx_ImportType("sage.rings.integer", "int_to_Z", sizeof(struct __pyx_obj_4sage_5rings_7integer_int_to_Z), 1); if (unlikely(!__pyx_ptype_4sage_5rings_7integer_int_to_Z)) __PYX_ERR(15, 37, __pyx_L1_error)
10096
__pyx_vtabptr_4sage_5rings_7integer_int_to_Z = (struct __pyx_vtabstruct_4sage_5rings_7integer_int_to_Z*)__Pyx_GetVtable(__pyx_ptype_4sage_5rings_7integer_int_to_Z->tp_dict); if (unlikely(!__pyx_vtabptr_4sage_5rings_7integer_int_to_Z)) __PYX_ERR(15, 37, __pyx_L1_error)
10097
/*--- Variable import code ---*/
10098
__pyx_t_1 = __Pyx_ImportModule("cysignals.signals"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
10099
if (__Pyx_ImportVoidPtr(__pyx_t_1, "cysigs", (void **)&__pyx_vp_9cysignals_7signals_cysigs, "cysigs_t") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10100
Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10101
__pyx_t_2 = __Pyx_ImportModule("sage.structure.element"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
10102
if (__Pyx_ImportVoidPtr(__pyx_t_2, "coercion_model", (void **)&__pyx_vp_4sage_9structure_7element_coercion_model, "struct __pyx_obj_4sage_9structure_7element_CoercionModel *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10103
Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10104
/*--- Function import code ---*/
10105
/*--- Execution code ---*/
10106
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
10107
if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10108
#endif
10109
10110
/* "../../../../../../../sage/sage-7.5/local/lib/python2.7/site-packages/cysignals/signals.pxi":24
10111
* # This *must* be done for every module using interrupt functions
10112
* # otherwise you will get segmentation faults.
10113
* import_cysignals__signals() # <<<<<<<<<<<<<<
10114
*/
10115
__pyx_t_3 = import_cysignals__signals(); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(16, 24, __pyx_L1_error)
10116
10117
/* "../../../../../../../sage/sage-7.5/src/sage/ext/stdsage.pxi":24
10118
*
10119
* from sage.ext.stdsage cimport PY_NEW, HAS_DICTIONARY
10120
* from sage.ext.memory import init_memory_functions # <<<<<<<<<<<<<<
10121
*/
10122
__pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 24, __pyx_L1_error)
10123
__Pyx_GOTREF(__pyx_t_4);
10124
__Pyx_INCREF(__pyx_n_s_init_memory_functions);
10125
__Pyx_GIVEREF(__pyx_n_s_init_memory_functions);
10126
PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_init_memory_functions);
10127
__pyx_t_5 = __Pyx_Import(__pyx_n_s_sage_ext_memory, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(17, 24, __pyx_L1_error)
10128
__Pyx_GOTREF(__pyx_t_5);
10129
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10130
__pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_init_memory_functions); if (unlikely(!__pyx_t_4)) __PYX_ERR(17, 24, __pyx_L1_error)
10131
__Pyx_GOTREF(__pyx_t_4);
10132
if (PyDict_SetItem(__pyx_d, __pyx_n_s_init_memory_functions, __pyx_t_4) < 0) __PYX_ERR(17, 24, __pyx_L1_error)
10133
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10134
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10135
10136
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":29
10137
* include 'cdefs.pxi'
10138
*
10139
* from sage.schemes.elliptic_curves.constructor import EllipticCurve # <<<<<<<<<<<<<<
10140
* from sage.rings.integer cimport Integer
10141
* from libc.stdint cimport int64_t, uint64_t
10142
*/
10143
__pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 29, __pyx_L1_error)
10144
__Pyx_GOTREF(__pyx_t_5);
10145
__Pyx_INCREF(__pyx_n_s_EllipticCurve);
10146
__Pyx_GIVEREF(__pyx_n_s_EllipticCurve);
10147
PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_EllipticCurve);
10148
__pyx_t_4 = __Pyx_Import(__pyx_n_s_sage_schemes_elliptic_curves_con, __pyx_t_5, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 29, __pyx_L1_error)
10149
__Pyx_GOTREF(__pyx_t_4);
10150
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10151
__pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_EllipticCurve); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 29, __pyx_L1_error)
10152
__Pyx_GOTREF(__pyx_t_5);
10153
if (PyDict_SetItem(__pyx_d, __pyx_n_s_EllipticCurve, __pyx_t_5) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
10154
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10155
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10156
10157
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":345
10158
* return c,d,e,f
10159
*
10160
* def canonical_model(E): # <<<<<<<<<<<<<<
10161
* """
10162
* Given a global minimal model E over Q(sqrt5) returns a canonical global
10163
*/
10164
__pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4code_4alex_5psage_5psage_8ellcurve_8minmodel_5sqrt5_3canonical_model, NULL, __pyx_n_s_code_alex_psage_psage_ellcurve_m); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 345, __pyx_L1_error)
10165
__Pyx_GOTREF(__pyx_t_4);
10166
if (PyDict_SetItem(__pyx_d, __pyx_n_s_canonical_model, __pyx_t_4) < 0) __PYX_ERR(0, 345, __pyx_L1_error)
10167
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10168
10169
/* "code/alex/psage/psage/ellcurve/minmodel/sqrt5.pyx":1
10170
* ################################################################################# # <<<<<<<<<<<<<<
10171
* #
10172
* # (c) Copyright 2011 R. Andrew Ohana
10173
*/
10174
__pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
10175
__Pyx_GOTREF(__pyx_t_4);
10176
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_4) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10177
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10178
10179
/* "cfunc.to_py":64
10180
*
10181
* @cname("__Pyx_CFunc_object____object____object____int___to_py")
10182
* cdef object __Pyx_CFunc_object____object____object____int___to_py(object (*f)(object, object, int) ): # <<<<<<<<<<<<<<
10183
* def wrap(object arg0, object arg1, int arg2):
10184
* """wrap(arg0, arg1, arg2: 'int')"""
10185
*/
10186
10187
/*--- Wrapped vars code ---*/
10188
10189
goto __pyx_L0;
10190
__pyx_L1_error:;
10191
__Pyx_XDECREF(__pyx_t_1);
10192
__Pyx_XDECREF(__pyx_t_2);
10193
__Pyx_XDECREF(__pyx_t_4);
10194
__Pyx_XDECREF(__pyx_t_5);
10195
if (__pyx_m) {
10196
if (__pyx_d) {
10197
__Pyx_AddTraceback("init code.alex.psage.psage.ellcurve.minmodel.sqrt5", __pyx_clineno, __pyx_lineno, __pyx_filename);
10198
}
10199
Py_DECREF(__pyx_m); __pyx_m = 0;
10200
} else if (!PyErr_Occurred()) {
10201
PyErr_SetString(PyExc_ImportError, "init code.alex.psage.psage.ellcurve.minmodel.sqrt5");
10202
}
10203
__pyx_L0:;
10204
__Pyx_RefNannyFinishContext();
10205
#if PY_MAJOR_VERSION < 3
10206
return;
10207
#else
10208
return __pyx_m;
10209
#endif
10210
}
10211
10212
/* --- Runtime support code --- */
10213
/* Refnanny */
10214
#if CYTHON_REFNANNY
10215
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
10216
PyObject *m = NULL, *p = NULL;
10217
void *r = NULL;
10218
m = PyImport_ImportModule((char *)modname);
10219
if (!m) goto end;
10220
p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
10221
if (!p) goto end;
10222
r = PyLong_AsVoidPtr(p);
10223
end:
10224
Py_XDECREF(p);
10225
Py_XDECREF(m);
10226
return (__Pyx_RefNannyAPIStruct *)r;
10227
}
10228
#endif
10229
10230
/* GetBuiltinName */
10231
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
10232
PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
10233
if (unlikely(!result)) {
10234
PyErr_Format(PyExc_NameError,
10235
#if PY_MAJOR_VERSION >= 3
10236
"name '%U' is not defined", name);
10237
#else
10238
"name '%.200s' is not defined", PyString_AS_STRING(name));
10239
#endif
10240
}
10241
return result;
10242
}
10243
10244
/* None */
10245
static CYTHON_INLINE int64_t __Pyx_mod_int64_t(int64_t a, int64_t b) {
10246
int64_t r = a % b;
10247
r += ((r != 0) & ((r ^ b) < 0)) * b;
10248
return r;
10249
}
10250
10251
/* None */
10252
static CYTHON_INLINE int64_t __Pyx_div_int64_t(int64_t a, int64_t b) {
10253
int64_t q = a / b;
10254
int64_t r = a - q*b;
10255
q -= ((r != 0) & ((r ^ b) < 0));
10256
return q;
10257
}
10258
10259
/* PyErrFetchRestore */
10260
#if CYTHON_FAST_THREAD_STATE
10261
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
10262
PyObject *tmp_type, *tmp_value, *tmp_tb;
10263
tmp_type = tstate->curexc_type;
10264
tmp_value = tstate->curexc_value;
10265
tmp_tb = tstate->curexc_traceback;
10266
tstate->curexc_type = type;
10267
tstate->curexc_value = value;
10268
tstate->curexc_traceback = tb;
10269
Py_XDECREF(tmp_type);
10270
Py_XDECREF(tmp_value);
10271
Py_XDECREF(tmp_tb);
10272
}
10273
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
10274
*type = tstate->curexc_type;
10275
*value = tstate->curexc_value;
10276
*tb = tstate->curexc_traceback;
10277
tstate->curexc_type = 0;
10278
tstate->curexc_value = 0;
10279
tstate->curexc_traceback = 0;
10280
}
10281
#endif
10282
10283
/* WriteUnraisableException */
10284
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
10285
CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
10286
int full_traceback, CYTHON_UNUSED int nogil) {
10287
PyObject *old_exc, *old_val, *old_tb;
10288
PyObject *ctx;
10289
__Pyx_PyThreadState_declare
10290
#ifdef WITH_THREAD
10291
PyGILState_STATE state;
10292
if (nogil)
10293
state = PyGILState_Ensure();
10294
#ifdef _MSC_VER
10295
else state = (PyGILState_STATE)-1;
10296
#endif
10297
#endif
10298
__Pyx_PyThreadState_assign
10299
__Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
10300
if (full_traceback) {
10301
Py_XINCREF(old_exc);
10302
Py_XINCREF(old_val);
10303
Py_XINCREF(old_tb);
10304
__Pyx_ErrRestore(old_exc, old_val, old_tb);
10305
PyErr_PrintEx(1);
10306
}
10307
#if PY_MAJOR_VERSION < 3
10308
ctx = PyString_FromString(name);
10309
#else
10310
ctx = PyUnicode_FromString(name);
10311
#endif
10312
__Pyx_ErrRestore(old_exc, old_val, old_tb);
10313
if (!ctx) {
10314
PyErr_WriteUnraisable(Py_None);
10315
} else {
10316
PyErr_WriteUnraisable(ctx);
10317
Py_DECREF(ctx);
10318
}
10319
#ifdef WITH_THREAD
10320
if (nogil)
10321
PyGILState_Release(state);
10322
#endif
10323
}
10324
10325
/* RaiseArgTupleInvalid */
10326
static void __Pyx_RaiseArgtupleInvalid(
10327
const char* func_name,
10328
int exact,
10329
Py_ssize_t num_min,
10330
Py_ssize_t num_max,
10331
Py_ssize_t num_found)
10332
{
10333
Py_ssize_t num_expected;
10334
const char *more_or_less;
10335
if (num_found < num_min) {
10336
num_expected = num_min;
10337
more_or_less = "at least";
10338
} else {
10339
num_expected = num_max;
10340
more_or_less = "at most";
10341
}
10342
if (exact) {
10343
more_or_less = "exactly";
10344
}
10345
PyErr_Format(PyExc_TypeError,
10346
"%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
10347
func_name, more_or_less, num_expected,
10348
(num_expected == 1) ? "" : "s", num_found);
10349
}
10350
10351
/* RaiseDoubleKeywords */
10352
static void __Pyx_RaiseDoubleKeywordsError(
10353
const char* func_name,
10354
PyObject* kw_name)
10355
{
10356
PyErr_Format(PyExc_TypeError,
10357
#if PY_MAJOR_VERSION >= 3
10358
"%s() got multiple values for keyword argument '%U'", func_name, kw_name);
10359
#else
10360
"%s() got multiple values for keyword argument '%s'", func_name,
10361
PyString_AsString(kw_name));
10362
#endif
10363
}
10364
10365
/* ParseKeywords */
10366
static int __Pyx_ParseOptionalKeywords(
10367
PyObject *kwds,
10368
PyObject **argnames[],
10369
PyObject *kwds2,
10370
PyObject *values[],
10371
Py_ssize_t num_pos_args,
10372
const char* function_name)
10373
{
10374
PyObject *key = 0, *value = 0;
10375
Py_ssize_t pos = 0;
10376
PyObject*** name;
10377
PyObject*** first_kw_arg = argnames + num_pos_args;
10378
while (PyDict_Next(kwds, &pos, &key, &value)) {
10379
name = first_kw_arg;
10380
while (*name && (**name != key)) name++;
10381
if (*name) {
10382
values[name-argnames] = value;
10383
continue;
10384
}
10385
name = first_kw_arg;
10386
#if PY_MAJOR_VERSION < 3
10387
if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
10388
while (*name) {
10389
if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
10390
&& _PyString_Eq(**name, key)) {
10391
values[name-argnames] = value;
10392
break;
10393
}
10394
name++;
10395
}
10396
if (*name) continue;
10397
else {
10398
PyObject*** argname = argnames;
10399
while (argname != first_kw_arg) {
10400
if ((**argname == key) || (
10401
(CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
10402
&& _PyString_Eq(**argname, key))) {
10403
goto arg_passed_twice;
10404
}
10405
argname++;
10406
}
10407
}
10408
} else
10409
#endif
10410
if (likely(PyUnicode_Check(key))) {
10411
while (*name) {
10412
int cmp = (**name == key) ? 0 :
10413
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
10414
(PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
10415
#endif
10416
PyUnicode_Compare(**name, key);
10417
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
10418
if (cmp == 0) {
10419
values[name-argnames] = value;
10420
break;
10421
}
10422
name++;
10423
}
10424
if (*name) continue;
10425
else {
10426
PyObject*** argname = argnames;
10427
while (argname != first_kw_arg) {
10428
int cmp = (**argname == key) ? 0 :
10429
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
10430
(PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
10431
#endif
10432
PyUnicode_Compare(**argname, key);
10433
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
10434
if (cmp == 0) goto arg_passed_twice;
10435
argname++;
10436
}
10437
}
10438
} else
10439
goto invalid_keyword_type;
10440
if (kwds2) {
10441
if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
10442
} else {
10443
goto invalid_keyword;
10444
}
10445
}
10446
return 0;
10447
arg_passed_twice:
10448
__Pyx_RaiseDoubleKeywordsError(function_name, key);
10449
goto bad;
10450
invalid_keyword_type:
10451
PyErr_Format(PyExc_TypeError,
10452
"%.200s() keywords must be strings", function_name);
10453
goto bad;
10454
invalid_keyword:
10455
PyErr_Format(PyExc_TypeError,
10456
#if PY_MAJOR_VERSION < 3
10457
"%.200s() got an unexpected keyword argument '%.200s'",
10458
function_name, PyString_AsString(key));
10459
#else
10460
"%s() got an unexpected keyword argument '%U'",
10461
function_name, key);
10462
#endif
10463
bad:
10464
return -1;
10465
}
10466
10467
/* ArgTypeTest */
10468
static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
10469
PyErr_Format(PyExc_TypeError,
10470
"Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
10471
name, type->tp_name, Py_TYPE(obj)->tp_name);
10472
}
10473
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
10474
const char *name, int exact)
10475
{
10476
if (unlikely(!type)) {
10477
PyErr_SetString(PyExc_SystemError, "Missing type object");
10478
return 0;
10479
}
10480
if (none_allowed && obj == Py_None) return 1;
10481
else if (exact) {
10482
if (likely(Py_TYPE(obj) == type)) return 1;
10483
#if PY_MAJOR_VERSION == 2
10484
else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
10485
#endif
10486
}
10487
else {
10488
if (likely(PyObject_TypeCheck(obj, type))) return 1;
10489
}
10490
__Pyx_RaiseArgumentTypeInvalid(name, obj, type);
10491
return 0;
10492
}
10493
10494
/* PyCFunctionFastCall */
10495
#if CYTHON_FAST_PYCCALL
10496
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
10497
PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
10498
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
10499
PyObject *self = PyCFunction_GET_SELF(func);
10500
assert(PyCFunction_Check(func));
10501
assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)));
10502
assert(nargs >= 0);
10503
assert(nargs == 0 || args != NULL);
10504
/* _PyCFunction_FastCallDict() must not be called with an exception set,
10505
because it may clear it (directly or indirectly) and so the
10506
caller loses its exception */
10507
assert(!PyErr_Occurred());
10508
return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
10509
}
10510
#endif // CYTHON_FAST_PYCCALL
10511
10512
/* PyFunctionFastCall */
10513
#if CYTHON_FAST_PYCALL
10514
#include "frameobject.h"
10515
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
10516
PyObject *globals) {
10517
PyFrameObject *f;
10518
PyThreadState *tstate = PyThreadState_GET();
10519
PyObject **fastlocals;
10520
Py_ssize_t i;
10521
PyObject *result;
10522
assert(globals != NULL);
10523
/* XXX Perhaps we should create a specialized
10524
PyFrame_New() that doesn't take locals, but does
10525
take builtins without sanity checking them.
10526
*/
10527
assert(tstate != NULL);
10528
f = PyFrame_New(tstate, co, globals, NULL);
10529
if (f == NULL) {
10530
return NULL;
10531
}
10532
fastlocals = f->f_localsplus;
10533
for (i = 0; i < na; i++) {
10534
Py_INCREF(*args);
10535
fastlocals[i] = *args++;
10536
}
10537
result = PyEval_EvalFrameEx(f,0);
10538
++tstate->recursion_depth;
10539
Py_DECREF(f);
10540
--tstate->recursion_depth;
10541
return result;
10542
}
10543
#if 1 || PY_VERSION_HEX < 0x030600B1
10544
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
10545
PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
10546
PyObject *globals = PyFunction_GET_GLOBALS(func);
10547
PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
10548
PyObject *closure;
10549
#if PY_MAJOR_VERSION >= 3
10550
PyObject *kwdefs;
10551
#endif
10552
PyObject *kwtuple, **k;
10553
PyObject **d;
10554
Py_ssize_t nd;
10555
Py_ssize_t nk;
10556
PyObject *result;
10557
assert(kwargs == NULL || PyDict_Check(kwargs));
10558
nk = kwargs ? PyDict_Size(kwargs) : 0;
10559
if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
10560
return NULL;
10561
}
10562
if (
10563
#if PY_MAJOR_VERSION >= 3
10564
co->co_kwonlyargcount == 0 &&
10565
#endif
10566
likely(kwargs == NULL || nk == 0) &&
10567
co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
10568
if (argdefs == NULL && co->co_argcount == nargs) {
10569
result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
10570
goto done;
10571
}
10572
else if (nargs == 0 && argdefs != NULL
10573
&& co->co_argcount == Py_SIZE(argdefs)) {
10574
/* function called with no arguments, but all parameters have
10575
a default value: use default values as arguments .*/
10576
args = &PyTuple_GET_ITEM(argdefs, 0);
10577
result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
10578
goto done;
10579
}
10580
}
10581
if (kwargs != NULL) {
10582
Py_ssize_t pos, i;
10583
kwtuple = PyTuple_New(2 * nk);
10584
if (kwtuple == NULL) {
10585
result = NULL;
10586
goto done;
10587
}
10588
k = &PyTuple_GET_ITEM(kwtuple, 0);
10589
pos = i = 0;
10590
while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
10591
Py_INCREF(k[i]);
10592
Py_INCREF(k[i+1]);
10593
i += 2;
10594
}
10595
nk = i / 2;
10596
}
10597
else {
10598
kwtuple = NULL;
10599
k = NULL;
10600
}
10601
closure = PyFunction_GET_CLOSURE(func);
10602
#if PY_MAJOR_VERSION >= 3
10603
kwdefs = PyFunction_GET_KW_DEFAULTS(func);
10604
#endif
10605
if (argdefs != NULL) {
10606
d = &PyTuple_GET_ITEM(argdefs, 0);
10607
nd = Py_SIZE(argdefs);
10608
}
10609
else {
10610
d = NULL;
10611
nd = 0;
10612
}
10613
#if PY_MAJOR_VERSION >= 3
10614
result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
10615
args, nargs,
10616
k, (int)nk,
10617
d, (int)nd, kwdefs, closure);
10618
#else
10619
result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
10620
args, nargs,
10621
k, (int)nk,
10622
d, (int)nd, closure);
10623
#endif
10624
Py_XDECREF(kwtuple);
10625
done:
10626
Py_LeaveRecursiveCall();
10627
return result;
10628
}
10629
#endif // CPython < 3.6
10630
#endif // CYTHON_FAST_PYCALL
10631
10632
/* PyObjectCall */
10633
#if CYTHON_COMPILING_IN_CPYTHON
10634
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
10635
PyObject *result;
10636
ternaryfunc call = func->ob_type->tp_call;
10637
if (unlikely(!call))
10638
return PyObject_Call(func, arg, kw);
10639
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
10640
return NULL;
10641
result = (*call)(func, arg, kw);
10642
Py_LeaveRecursiveCall();
10643
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
10644
PyErr_SetString(
10645
PyExc_SystemError,
10646
"NULL result without error in PyObject_Call");
10647
}
10648
return result;
10649
}
10650
#endif
10651
10652
/* PyObjectCallMethO */
10653
#if CYTHON_COMPILING_IN_CPYTHON
10654
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
10655
PyObject *self, *result;
10656
PyCFunction cfunc;
10657
cfunc = PyCFunction_GET_FUNCTION(func);
10658
self = PyCFunction_GET_SELF(func);
10659
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
10660
return NULL;
10661
result = cfunc(self, arg);
10662
Py_LeaveRecursiveCall();
10663
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
10664
PyErr_SetString(
10665
PyExc_SystemError,
10666
"NULL result without error in PyObject_Call");
10667
}
10668
return result;
10669
}
10670
#endif
10671
10672
/* PyObjectCallOneArg */
10673
#if CYTHON_COMPILING_IN_CPYTHON
10674
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
10675
PyObject *result;
10676
PyObject *args = PyTuple_New(1);
10677
if (unlikely(!args)) return NULL;
10678
Py_INCREF(arg);
10679
PyTuple_SET_ITEM(args, 0, arg);
10680
result = __Pyx_PyObject_Call(func, args, NULL);
10681
Py_DECREF(args);
10682
return result;
10683
}
10684
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
10685
#if CYTHON_FAST_PYCALL
10686
if (PyFunction_Check(func)) {
10687
return __Pyx_PyFunction_FastCall(func, &arg, 1);
10688
}
10689
#endif
10690
#ifdef __Pyx_CyFunction_USED
10691
if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
10692
#else
10693
if (likely(PyCFunction_Check(func))) {
10694
#endif
10695
if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
10696
return __Pyx_PyObject_CallMethO(func, arg);
10697
#if CYTHON_FAST_PYCCALL
10698
} else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
10699
return __Pyx_PyCFunction_FastCall(func, &arg, 1);
10700
#endif
10701
}
10702
}
10703
return __Pyx__PyObject_CallOneArg(func, arg);
10704
}
10705
#else
10706
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
10707
PyObject *result;
10708
PyObject *args = PyTuple_Pack(1, arg);
10709
if (unlikely(!args)) return NULL;
10710
result = __Pyx_PyObject_Call(func, args, NULL);
10711
Py_DECREF(args);
10712
return result;
10713
}
10714
#endif
10715
10716
/* PyObjectCallNoArg */
10717
#if CYTHON_COMPILING_IN_CPYTHON
10718
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
10719
#if CYTHON_FAST_PYCALL
10720
if (PyFunction_Check(func)) {
10721
return __Pyx_PyFunction_FastCall(func, NULL, 0);
10722
}
10723
#endif
10724
#ifdef __Pyx_CyFunction_USED
10725
if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
10726
#else
10727
if (likely(PyCFunction_Check(func))) {
10728
#endif
10729
if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
10730
return __Pyx_PyObject_CallMethO(func, NULL);
10731
}
10732
}
10733
return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
10734
}
10735
#endif
10736
10737
/* RaiseException */
10738
#if PY_MAJOR_VERSION < 3
10739
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
10740
CYTHON_UNUSED PyObject *cause) {
10741
__Pyx_PyThreadState_declare
10742
Py_XINCREF(type);
10743
if (!value || value == Py_None)
10744
value = NULL;
10745
else
10746
Py_INCREF(value);
10747
if (!tb || tb == Py_None)
10748
tb = NULL;
10749
else {
10750
Py_INCREF(tb);
10751
if (!PyTraceBack_Check(tb)) {
10752
PyErr_SetString(PyExc_TypeError,
10753
"raise: arg 3 must be a traceback or None");
10754
goto raise_error;
10755
}
10756
}
10757
if (PyType_Check(type)) {
10758
#if CYTHON_COMPILING_IN_PYPY
10759
if (!value) {
10760
Py_INCREF(Py_None);
10761
value = Py_None;
10762
}
10763
#endif
10764
PyErr_NormalizeException(&type, &value, &tb);
10765
} else {
10766
if (value) {
10767
PyErr_SetString(PyExc_TypeError,
10768
"instance exception may not have a separate value");
10769
goto raise_error;
10770
}
10771
value = type;
10772
type = (PyObject*) Py_TYPE(type);
10773
Py_INCREF(type);
10774
if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
10775
PyErr_SetString(PyExc_TypeError,
10776
"raise: exception class must be a subclass of BaseException");
10777
goto raise_error;
10778
}
10779
}
10780
__Pyx_PyThreadState_assign
10781
__Pyx_ErrRestore(type, value, tb);
10782
return;
10783
raise_error:
10784
Py_XDECREF(value);
10785
Py_XDECREF(type);
10786
Py_XDECREF(tb);
10787
return;
10788
}
10789
#else
10790
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
10791
PyObject* owned_instance = NULL;
10792
if (tb == Py_None) {
10793
tb = 0;
10794
} else if (tb && !PyTraceBack_Check(tb)) {
10795
PyErr_SetString(PyExc_TypeError,
10796
"raise: arg 3 must be a traceback or None");
10797
goto bad;
10798
}
10799
if (value == Py_None)
10800
value = 0;
10801
if (PyExceptionInstance_Check(type)) {
10802
if (value) {
10803
PyErr_SetString(PyExc_TypeError,
10804
"instance exception may not have a separate value");
10805
goto bad;
10806
}
10807
value = type;
10808
type = (PyObject*) Py_TYPE(value);
10809
} else if (PyExceptionClass_Check(type)) {
10810
PyObject *instance_class = NULL;
10811
if (value && PyExceptionInstance_Check(value)) {
10812
instance_class = (PyObject*) Py_TYPE(value);
10813
if (instance_class != type) {
10814
int is_subclass = PyObject_IsSubclass(instance_class, type);
10815
if (!is_subclass) {
10816
instance_class = NULL;
10817
} else if (unlikely(is_subclass == -1)) {
10818
goto bad;
10819
} else {
10820
type = instance_class;
10821
}
10822
}
10823
}
10824
if (!instance_class) {
10825
PyObject *args;
10826
if (!value)
10827
args = PyTuple_New(0);
10828
else if (PyTuple_Check(value)) {
10829
Py_INCREF(value);
10830
args = value;
10831
} else
10832
args = PyTuple_Pack(1, value);
10833
if (!args)
10834
goto bad;
10835
owned_instance = PyObject_Call(type, args, NULL);
10836
Py_DECREF(args);
10837
if (!owned_instance)
10838
goto bad;
10839
value = owned_instance;
10840
if (!PyExceptionInstance_Check(value)) {
10841
PyErr_Format(PyExc_TypeError,
10842
"calling %R should have returned an instance of "
10843
"BaseException, not %R",
10844
type, Py_TYPE(value));
10845
goto bad;
10846
}
10847
}
10848
} else {
10849
PyErr_SetString(PyExc_TypeError,
10850
"raise: exception class must be a subclass of BaseException");
10851
goto bad;
10852
}
10853
#if PY_VERSION_HEX >= 0x03030000
10854
if (cause) {
10855
#else
10856
if (cause && cause != Py_None) {
10857
#endif
10858
PyObject *fixed_cause;
10859
if (cause == Py_None) {
10860
fixed_cause = NULL;
10861
} else if (PyExceptionClass_Check(cause)) {
10862
fixed_cause = PyObject_CallObject(cause, NULL);
10863
if (fixed_cause == NULL)
10864
goto bad;
10865
} else if (PyExceptionInstance_Check(cause)) {
10866
fixed_cause = cause;
10867
Py_INCREF(fixed_cause);
10868
} else {
10869
PyErr_SetString(PyExc_TypeError,
10870
"exception causes must derive from "
10871
"BaseException");
10872
goto bad;
10873
}
10874
PyException_SetCause(value, fixed_cause);
10875
}
10876
PyErr_SetObject(type, value);
10877
if (tb) {
10878
#if CYTHON_COMPILING_IN_PYPY
10879
PyObject *tmp_type, *tmp_value, *tmp_tb;
10880
PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
10881
Py_INCREF(tb);
10882
PyErr_Restore(tmp_type, tmp_value, tb);
10883
Py_XDECREF(tmp_tb);
10884
#else
10885
PyThreadState *tstate = PyThreadState_GET();
10886
PyObject* tmp_tb = tstate->curexc_traceback;
10887
if (tb != tmp_tb) {
10888
Py_INCREF(tb);
10889
tstate->curexc_traceback = tb;
10890
Py_XDECREF(tmp_tb);
10891
}
10892
#endif
10893
}
10894
bad:
10895
Py_XDECREF(owned_instance);
10896
return;
10897
}
10898
#endif
10899
10900
/* RaiseTooManyValuesToUnpack */
10901
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
10902
PyErr_Format(PyExc_ValueError,
10903
"too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
10904
}
10905
10906
/* RaiseNeedMoreValuesToUnpack */
10907
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
10908
PyErr_Format(PyExc_ValueError,
10909
"need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
10910
index, (index == 1) ? "" : "s");
10911
}
10912
10913
/* IterFinish */
10914
static CYTHON_INLINE int __Pyx_IterFinish(void) {
10915
#if CYTHON_FAST_THREAD_STATE
10916
PyThreadState *tstate = PyThreadState_GET();
10917
PyObject* exc_type = tstate->curexc_type;
10918
if (unlikely(exc_type)) {
10919
if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
10920
PyObject *exc_value, *exc_tb;
10921
exc_value = tstate->curexc_value;
10922
exc_tb = tstate->curexc_traceback;
10923
tstate->curexc_type = 0;
10924
tstate->curexc_value = 0;
10925
tstate->curexc_traceback = 0;
10926
Py_DECREF(exc_type);
10927
Py_XDECREF(exc_value);
10928
Py_XDECREF(exc_tb);
10929
return 0;
10930
} else {
10931
return -1;
10932
}
10933
}
10934
return 0;
10935
#else
10936
if (unlikely(PyErr_Occurred())) {
10937
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
10938
PyErr_Clear();
10939
return 0;
10940
} else {
10941
return -1;
10942
}
10943
}
10944
return 0;
10945
#endif
10946
}
10947
10948
/* UnpackItemEndCheck */
10949
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
10950
if (unlikely(retval)) {
10951
Py_DECREF(retval);
10952
__Pyx_RaiseTooManyValuesError(expected);
10953
return -1;
10954
} else {
10955
return __Pyx_IterFinish();
10956
}
10957
return 0;
10958
}
10959
10960
/* SaveResetException */
10961
#if CYTHON_FAST_THREAD_STATE
10962
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
10963
*type = tstate->exc_type;
10964
*value = tstate->exc_value;
10965
*tb = tstate->exc_traceback;
10966
Py_XINCREF(*type);
10967
Py_XINCREF(*value);
10968
Py_XINCREF(*tb);
10969
}
10970
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
10971
PyObject *tmp_type, *tmp_value, *tmp_tb;
10972
tmp_type = tstate->exc_type;
10973
tmp_value = tstate->exc_value;
10974
tmp_tb = tstate->exc_traceback;
10975
tstate->exc_type = type;
10976
tstate->exc_value = value;
10977
tstate->exc_traceback = tb;
10978
Py_XDECREF(tmp_type);
10979
Py_XDECREF(tmp_value);
10980
Py_XDECREF(tmp_tb);
10981
}
10982
#endif
10983
10984
/* PyErrExceptionMatches */
10985
#if CYTHON_FAST_THREAD_STATE
10986
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
10987
PyObject *exc_type = tstate->curexc_type;
10988
if (exc_type == err) return 1;
10989
if (unlikely(!exc_type)) return 0;
10990
return PyErr_GivenExceptionMatches(exc_type, err);
10991
}
10992
#endif
10993
10994
/* GetException */
10995
#if CYTHON_FAST_THREAD_STATE
10996
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
10997
#else
10998
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
10999
#endif
11000
PyObject *local_type, *local_value, *local_tb;
11001
#if CYTHON_FAST_THREAD_STATE
11002
PyObject *tmp_type, *tmp_value, *tmp_tb;
11003
local_type = tstate->curexc_type;
11004
local_value = tstate->curexc_value;
11005
local_tb = tstate->curexc_traceback;
11006
tstate->curexc_type = 0;
11007
tstate->curexc_value = 0;
11008
tstate->curexc_traceback = 0;
11009
#else
11010
PyErr_Fetch(&local_type, &local_value, &local_tb);
11011
#endif
11012
PyErr_NormalizeException(&local_type, &local_value, &local_tb);
11013
#if CYTHON_FAST_THREAD_STATE
11014
if (unlikely(tstate->curexc_type))
11015
#else
11016
if (unlikely(PyErr_Occurred()))
11017
#endif
11018
goto bad;
11019
#if PY_MAJOR_VERSION >= 3
11020
if (local_tb) {
11021
if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
11022
goto bad;
11023
}
11024
#endif
11025
Py_XINCREF(local_tb);
11026
Py_XINCREF(local_type);
11027
Py_XINCREF(local_value);
11028
*type = local_type;
11029
*value = local_value;
11030
*tb = local_tb;
11031
#if CYTHON_FAST_THREAD_STATE
11032
tmp_type = tstate->exc_type;
11033
tmp_value = tstate->exc_value;
11034
tmp_tb = tstate->exc_traceback;
11035
tstate->exc_type = local_type;
11036
tstate->exc_value = local_value;
11037
tstate->exc_traceback = local_tb;
11038
Py_XDECREF(tmp_type);
11039
Py_XDECREF(tmp_value);
11040
Py_XDECREF(tmp_tb);
11041
#else
11042
PyErr_SetExcInfo(local_type, local_value, local_tb);
11043
#endif
11044
return 0;
11045
bad:
11046
*type = 0;
11047
*value = 0;
11048
*tb = 0;
11049
Py_XDECREF(local_type);
11050
Py_XDECREF(local_value);
11051
Py_XDECREF(local_tb);
11052
return -1;
11053
}
11054
11055
/* GetModuleGlobalName */
11056
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
11057
PyObject *result;
11058
#if !CYTHON_AVOID_BORROWED_REFS
11059
result = PyDict_GetItem(__pyx_d, name);
11060
if (likely(result)) {
11061
Py_INCREF(result);
11062
} else {
11063
#else
11064
result = PyObject_GetItem(__pyx_d, name);
11065
if (!result) {
11066
PyErr_Clear();
11067
#endif
11068
result = __Pyx_GetBuiltinName(name);
11069
}
11070
return result;
11071
}
11072
11073
/* FetchCommonType */
11074
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
11075
PyObject* fake_module;
11076
PyTypeObject* cached_type = NULL;
11077
fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
11078
if (!fake_module) return NULL;
11079
Py_INCREF(fake_module);
11080
cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
11081
if (cached_type) {
11082
if (!PyType_Check((PyObject*)cached_type)) {
11083
PyErr_Format(PyExc_TypeError,
11084
"Shared Cython type %.200s is not a type object",
11085
type->tp_name);
11086
goto bad;
11087
}
11088
if (cached_type->tp_basicsize != type->tp_basicsize) {
11089
PyErr_Format(PyExc_TypeError,
11090
"Shared Cython type %.200s has the wrong size, try recompiling",
11091
type->tp_name);
11092
goto bad;
11093
}
11094
} else {
11095
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
11096
PyErr_Clear();
11097
if (PyType_Ready(type) < 0) goto bad;
11098
if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
11099
goto bad;
11100
Py_INCREF(type);
11101
cached_type = type;
11102
}
11103
done:
11104
Py_DECREF(fake_module);
11105
return cached_type;
11106
bad:
11107
Py_XDECREF(cached_type);
11108
cached_type = NULL;
11109
goto done;
11110
}
11111
11112
/* CythonFunction */
11113
static PyObject *
11114
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
11115
{
11116
if (unlikely(op->func_doc == NULL)) {
11117
if (op->func.m_ml->ml_doc) {
11118
#if PY_MAJOR_VERSION >= 3
11119
op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
11120
#else
11121
op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
11122
#endif
11123
if (unlikely(op->func_doc == NULL))
11124
return NULL;
11125
} else {
11126
Py_INCREF(Py_None);
11127
return Py_None;
11128
}
11129
}
11130
Py_INCREF(op->func_doc);
11131
return op->func_doc;
11132
}
11133
static int
11134
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
11135
{
11136
PyObject *tmp = op->func_doc;
11137
if (value == NULL) {
11138
value = Py_None;
11139
}
11140
Py_INCREF(value);
11141
op->func_doc = value;
11142
Py_XDECREF(tmp);
11143
return 0;
11144
}
11145
static PyObject *
11146
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
11147
{
11148
if (unlikely(op->func_name == NULL)) {
11149
#if PY_MAJOR_VERSION >= 3
11150
op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
11151
#else
11152
op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
11153
#endif
11154
if (unlikely(op->func_name == NULL))
11155
return NULL;
11156
}
11157
Py_INCREF(op->func_name);
11158
return op->func_name;
11159
}
11160
static int
11161
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
11162
{
11163
PyObject *tmp;
11164
#if PY_MAJOR_VERSION >= 3
11165
if (unlikely(value == NULL || !PyUnicode_Check(value))) {
11166
#else
11167
if (unlikely(value == NULL || !PyString_Check(value))) {
11168
#endif
11169
PyErr_SetString(PyExc_TypeError,
11170
"__name__ must be set to a string object");
11171
return -1;
11172
}
11173
tmp = op->func_name;
11174
Py_INCREF(value);
11175
op->func_name = value;
11176
Py_XDECREF(tmp);
11177
return 0;
11178
}
11179
static PyObject *
11180
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
11181
{
11182
Py_INCREF(op->func_qualname);
11183
return op->func_qualname;
11184
}
11185
static int
11186
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
11187
{
11188
PyObject *tmp;
11189
#if PY_MAJOR_VERSION >= 3
11190
if (unlikely(value == NULL || !PyUnicode_Check(value))) {
11191
#else
11192
if (unlikely(value == NULL || !PyString_Check(value))) {
11193
#endif
11194
PyErr_SetString(PyExc_TypeError,
11195
"__qualname__ must be set to a string object");
11196
return -1;
11197
}
11198
tmp = op->func_qualname;
11199
Py_INCREF(value);
11200
op->func_qualname = value;
11201
Py_XDECREF(tmp);
11202
return 0;
11203
}
11204
static PyObject *
11205
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
11206
{
11207
PyObject *self;
11208
self = m->func_closure;
11209
if (self == NULL)
11210
self = Py_None;
11211
Py_INCREF(self);
11212
return self;
11213
}
11214
static PyObject *
11215
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
11216
{
11217
if (unlikely(op->func_dict == NULL)) {
11218
op->func_dict = PyDict_New();
11219
if (unlikely(op->func_dict == NULL))
11220
return NULL;
11221
}
11222
Py_INCREF(op->func_dict);
11223
return op->func_dict;
11224
}
11225
static int
11226
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
11227
{
11228
PyObject *tmp;
11229
if (unlikely(value == NULL)) {
11230
PyErr_SetString(PyExc_TypeError,
11231
"function's dictionary may not be deleted");
11232
return -1;
11233
}
11234
if (unlikely(!PyDict_Check(value))) {
11235
PyErr_SetString(PyExc_TypeError,
11236
"setting function's dictionary to a non-dict");
11237
return -1;
11238
}
11239
tmp = op->func_dict;
11240
Py_INCREF(value);
11241
op->func_dict = value;
11242
Py_XDECREF(tmp);
11243
return 0;
11244
}
11245
static PyObject *
11246
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
11247
{
11248
Py_INCREF(op->func_globals);
11249
return op->func_globals;
11250
}
11251
static PyObject *
11252
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
11253
{
11254
Py_INCREF(Py_None);
11255
return Py_None;
11256
}
11257
static PyObject *
11258
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
11259
{
11260
PyObject* result = (op->func_code) ? op->func_code : Py_None;
11261
Py_INCREF(result);
11262
return result;
11263
}
11264
static int
11265
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
11266
int result = 0;
11267
PyObject *res = op->defaults_getter((PyObject *) op);
11268
if (unlikely(!res))
11269
return -1;
11270
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11271
op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
11272
Py_INCREF(op->defaults_tuple);
11273
op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
11274
Py_INCREF(op->defaults_kwdict);
11275
#else
11276
op->defaults_tuple = PySequence_ITEM(res, 0);
11277
if (unlikely(!op->defaults_tuple)) result = -1;
11278
else {
11279
op->defaults_kwdict = PySequence_ITEM(res, 1);
11280
if (unlikely(!op->defaults_kwdict)) result = -1;
11281
}
11282
#endif
11283
Py_DECREF(res);
11284
return result;
11285
}
11286
static int
11287
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
11288
PyObject* tmp;
11289
if (!value) {
11290
value = Py_None;
11291
} else if (value != Py_None && !PyTuple_Check(value)) {
11292
PyErr_SetString(PyExc_TypeError,
11293
"__defaults__ must be set to a tuple object");
11294
return -1;
11295
}
11296
Py_INCREF(value);
11297
tmp = op->defaults_tuple;
11298
op->defaults_tuple = value;
11299
Py_XDECREF(tmp);
11300
return 0;
11301
}
11302
static PyObject *
11303
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
11304
PyObject* result = op->defaults_tuple;
11305
if (unlikely(!result)) {
11306
if (op->defaults_getter) {
11307
if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
11308
result = op->defaults_tuple;
11309
} else {
11310
result = Py_None;
11311
}
11312
}
11313
Py_INCREF(result);
11314
return result;
11315
}
11316
static int
11317
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
11318
PyObject* tmp;
11319
if (!value) {
11320
value = Py_None;
11321
} else if (value != Py_None && !PyDict_Check(value)) {
11322
PyErr_SetString(PyExc_TypeError,
11323
"__kwdefaults__ must be set to a dict object");
11324
return -1;
11325
}
11326
Py_INCREF(value);
11327
tmp = op->defaults_kwdict;
11328
op->defaults_kwdict = value;
11329
Py_XDECREF(tmp);
11330
return 0;
11331
}
11332
static PyObject *
11333
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
11334
PyObject* result = op->defaults_kwdict;
11335
if (unlikely(!result)) {
11336
if (op->defaults_getter) {
11337
if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
11338
result = op->defaults_kwdict;
11339
} else {
11340
result = Py_None;
11341
}
11342
}
11343
Py_INCREF(result);
11344
return result;
11345
}
11346
static int
11347
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
11348
PyObject* tmp;
11349
if (!value || value == Py_None) {
11350
value = NULL;
11351
} else if (!PyDict_Check(value)) {
11352
PyErr_SetString(PyExc_TypeError,
11353
"__annotations__ must be set to a dict object");
11354
return -1;
11355
}
11356
Py_XINCREF(value);
11357
tmp = op->func_annotations;
11358
op->func_annotations = value;
11359
Py_XDECREF(tmp);
11360
return 0;
11361
}
11362
static PyObject *
11363
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
11364
PyObject* result = op->func_annotations;
11365
if (unlikely(!result)) {
11366
result = PyDict_New();
11367
if (unlikely(!result)) return NULL;
11368
op->func_annotations = result;
11369
}
11370
Py_INCREF(result);
11371
return result;
11372
}
11373
static PyGetSetDef __pyx_CyFunction_getsets[] = {
11374
{(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
11375
{(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
11376
{(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
11377
{(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
11378
{(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
11379
{(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
11380
{(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
11381
{(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
11382
{(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
11383
{(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
11384
{(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
11385
{(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
11386
{(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
11387
{(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
11388
{(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
11389
{(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
11390
{(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
11391
{(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
11392
{0, 0, 0, 0, 0}
11393
};
11394
static PyMemberDef __pyx_CyFunction_members[] = {
11395
{(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
11396
{0, 0, 0, 0, 0}
11397
};
11398
static PyObject *
11399
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
11400
{
11401
#if PY_MAJOR_VERSION >= 3
11402
return PyUnicode_FromString(m->func.m_ml->ml_name);
11403
#else
11404
return PyString_FromString(m->func.m_ml->ml_name);
11405
#endif
11406
}
11407
static PyMethodDef __pyx_CyFunction_methods[] = {
11408
{"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
11409
{0, 0, 0, 0}
11410
};
11411
#if PY_VERSION_HEX < 0x030500A0
11412
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
11413
#else
11414
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
11415
#endif
11416
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
11417
PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
11418
__pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
11419
if (op == NULL)
11420
return NULL;
11421
op->flags = flags;
11422
__Pyx_CyFunction_weakreflist(op) = NULL;
11423
op->func.m_ml = ml;
11424
op->func.m_self = (PyObject *) op;
11425
Py_XINCREF(closure);
11426
op->func_closure = closure;
11427
Py_XINCREF(module);
11428
op->func.m_module = module;
11429
op->func_dict = NULL;
11430
op->func_name = NULL;
11431
Py_INCREF(qualname);
11432
op->func_qualname = qualname;
11433
op->func_doc = NULL;
11434
op->func_classobj = NULL;
11435
op->func_globals = globals;
11436
Py_INCREF(op->func_globals);
11437
Py_XINCREF(code);
11438
op->func_code = code;
11439
op->defaults_pyobjects = 0;
11440
op->defaults = NULL;
11441
op->defaults_tuple = NULL;
11442
op->defaults_kwdict = NULL;
11443
op->defaults_getter = NULL;
11444
op->func_annotations = NULL;
11445
PyObject_GC_Track(op);
11446
return (PyObject *) op;
11447
}
11448
static int
11449
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
11450
{
11451
Py_CLEAR(m->func_closure);
11452
Py_CLEAR(m->func.m_module);
11453
Py_CLEAR(m->func_dict);
11454
Py_CLEAR(m->func_name);
11455
Py_CLEAR(m->func_qualname);
11456
Py_CLEAR(m->func_doc);
11457
Py_CLEAR(m->func_globals);
11458
Py_CLEAR(m->func_code);
11459
Py_CLEAR(m->func_classobj);
11460
Py_CLEAR(m->defaults_tuple);
11461
Py_CLEAR(m->defaults_kwdict);
11462
Py_CLEAR(m->func_annotations);
11463
if (m->defaults) {
11464
PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
11465
int i;
11466
for (i = 0; i < m->defaults_pyobjects; i++)
11467
Py_XDECREF(pydefaults[i]);
11468
PyObject_Free(m->defaults);
11469
m->defaults = NULL;
11470
}
11471
return 0;
11472
}
11473
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
11474
{
11475
PyObject_GC_UnTrack(m);
11476
if (__Pyx_CyFunction_weakreflist(m) != NULL)
11477
PyObject_ClearWeakRefs((PyObject *) m);
11478
__Pyx_CyFunction_clear(m);
11479
PyObject_GC_Del(m);
11480
}
11481
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
11482
{
11483
Py_VISIT(m->func_closure);
11484
Py_VISIT(m->func.m_module);
11485
Py_VISIT(m->func_dict);
11486
Py_VISIT(m->func_name);
11487
Py_VISIT(m->func_qualname);
11488
Py_VISIT(m->func_doc);
11489
Py_VISIT(m->func_globals);
11490
Py_VISIT(m->func_code);
11491
Py_VISIT(m->func_classobj);
11492
Py_VISIT(m->defaults_tuple);
11493
Py_VISIT(m->defaults_kwdict);
11494
if (m->defaults) {
11495
PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
11496
int i;
11497
for (i = 0; i < m->defaults_pyobjects; i++)
11498
Py_VISIT(pydefaults[i]);
11499
}
11500
return 0;
11501
}
11502
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
11503
{
11504
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
11505
if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
11506
Py_INCREF(func);
11507
return func;
11508
}
11509
if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
11510
if (type == NULL)
11511
type = (PyObject *)(Py_TYPE(obj));
11512
return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
11513
}
11514
if (obj == Py_None)
11515
obj = NULL;
11516
return __Pyx_PyMethod_New(func, obj, type);
11517
}
11518
static PyObject*
11519
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
11520
{
11521
#if PY_MAJOR_VERSION >= 3
11522
return PyUnicode_FromFormat("<cyfunction %U at %p>",
11523
op->func_qualname, (void *)op);
11524
#else
11525
return PyString_FromFormat("<cyfunction %s at %p>",
11526
PyString_AsString(op->func_qualname), (void *)op);
11527
#endif
11528
}
11529
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
11530
PyCFunctionObject* f = (PyCFunctionObject*)func;
11531
PyCFunction meth = f->m_ml->ml_meth;
11532
Py_ssize_t size;
11533
switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
11534
case METH_VARARGS:
11535
if (likely(kw == NULL || PyDict_Size(kw) == 0))
11536
return (*meth)(self, arg);
11537
break;
11538
case METH_VARARGS | METH_KEYWORDS:
11539
return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
11540
case METH_NOARGS:
11541
if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
11542
size = PyTuple_GET_SIZE(arg);
11543
if (likely(size == 0))
11544
return (*meth)(self, NULL);
11545
PyErr_Format(PyExc_TypeError,
11546
"%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
11547
f->m_ml->ml_name, size);
11548
return NULL;
11549
}
11550
break;
11551
case METH_O:
11552
if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
11553
size = PyTuple_GET_SIZE(arg);
11554
if (likely(size == 1)) {
11555
PyObject *result, *arg0 = PySequence_ITEM(arg, 0);
11556
if (unlikely(!arg0)) return NULL;
11557
result = (*meth)(self, arg0);
11558
Py_DECREF(arg0);
11559
return result;
11560
}
11561
PyErr_Format(PyExc_TypeError,
11562
"%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
11563
f->m_ml->ml_name, size);
11564
return NULL;
11565
}
11566
break;
11567
default:
11568
PyErr_SetString(PyExc_SystemError, "Bad call flags in "
11569
"__Pyx_CyFunction_Call. METH_OLDARGS is no "
11570
"longer supported!");
11571
return NULL;
11572
}
11573
PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
11574
f->m_ml->ml_name);
11575
return NULL;
11576
}
11577
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
11578
return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
11579
}
11580
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
11581
PyObject *result;
11582
__pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
11583
if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
11584
Py_ssize_t argc;
11585
PyObject *new_args;
11586
PyObject *self;
11587
argc = PyTuple_GET_SIZE(args);
11588
new_args = PyTuple_GetSlice(args, 1, argc);
11589
if (unlikely(!new_args))
11590
return NULL;
11591
self = PyTuple_GetItem(args, 0);
11592
if (unlikely(!self)) {
11593
Py_DECREF(new_args);
11594
return NULL;
11595
}
11596
result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
11597
Py_DECREF(new_args);
11598
} else {
11599
result = __Pyx_CyFunction_Call(func, args, kw);
11600
}
11601
return result;
11602
}
11603
static PyTypeObject __pyx_CyFunctionType_type = {
11604
PyVarObject_HEAD_INIT(0, 0)
11605
"cython_function_or_method",
11606
sizeof(__pyx_CyFunctionObject),
11607
0,
11608
(destructor) __Pyx_CyFunction_dealloc,
11609
0,
11610
0,
11611
0,
11612
#if PY_MAJOR_VERSION < 3
11613
0,
11614
#else
11615
0,
11616
#endif
11617
(reprfunc) __Pyx_CyFunction_repr,
11618
0,
11619
0,
11620
0,
11621
0,
11622
__Pyx_CyFunction_CallAsMethod,
11623
0,
11624
0,
11625
0,
11626
0,
11627
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
11628
0,
11629
(traverseproc) __Pyx_CyFunction_traverse,
11630
(inquiry) __Pyx_CyFunction_clear,
11631
0,
11632
#if PY_VERSION_HEX < 0x030500A0
11633
offsetof(__pyx_CyFunctionObject, func_weakreflist),
11634
#else
11635
offsetof(PyCFunctionObject, m_weakreflist),
11636
#endif
11637
0,
11638
0,
11639
__pyx_CyFunction_methods,
11640
__pyx_CyFunction_members,
11641
__pyx_CyFunction_getsets,
11642
0,
11643
0,
11644
__Pyx_CyFunction_descr_get,
11645
0,
11646
offsetof(__pyx_CyFunctionObject, func_dict),
11647
0,
11648
0,
11649
0,
11650
0,
11651
0,
11652
0,
11653
0,
11654
0,
11655
0,
11656
0,
11657
0,
11658
0,
11659
#if PY_VERSION_HEX >= 0x030400a1
11660
0,
11661
#endif
11662
};
11663
static int __pyx_CyFunction_init(void) {
11664
__pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
11665
if (__pyx_CyFunctionType == NULL) {
11666
return -1;
11667
}
11668
return 0;
11669
}
11670
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
11671
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
11672
m->defaults = PyObject_Malloc(size);
11673
if (!m->defaults)
11674
return PyErr_NoMemory();
11675
memset(m->defaults, 0, size);
11676
m->defaults_pyobjects = pyobjects;
11677
return m->defaults;
11678
}
11679
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
11680
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
11681
m->defaults_tuple = tuple;
11682
Py_INCREF(tuple);
11683
}
11684
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
11685
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
11686
m->defaults_kwdict = dict;
11687
Py_INCREF(dict);
11688
}
11689
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
11690
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
11691
m->func_annotations = dict;
11692
Py_INCREF(dict);
11693
}
11694
11695
/* GetVTable */
11696
static void* __Pyx_GetVtable(PyObject *dict) {
11697
void* ptr;
11698
PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
11699
if (!ob)
11700
goto bad;
11701
#if PY_VERSION_HEX >= 0x02070000
11702
ptr = PyCapsule_GetPointer(ob, 0);
11703
#else
11704
ptr = PyCObject_AsVoidPtr(ob);
11705
#endif
11706
if (!ptr && !PyErr_Occurred())
11707
PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
11708
Py_DECREF(ob);
11709
return ptr;
11710
bad:
11711
Py_XDECREF(ob);
11712
return NULL;
11713
}
11714
11715
/* Import */
11716
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
11717
PyObject *empty_list = 0;
11718
PyObject *module = 0;
11719
PyObject *global_dict = 0;
11720
PyObject *empty_dict = 0;
11721
PyObject *list;
11722
#if PY_VERSION_HEX < 0x03030000
11723
PyObject *py_import;
11724
py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
11725
if (!py_import)
11726
goto bad;
11727
#endif
11728
if (from_list)
11729
list = from_list;
11730
else {
11731
empty_list = PyList_New(0);
11732
if (!empty_list)
11733
goto bad;
11734
list = empty_list;
11735
}
11736
global_dict = PyModule_GetDict(__pyx_m);
11737
if (!global_dict)
11738
goto bad;
11739
empty_dict = PyDict_New();
11740
if (!empty_dict)
11741
goto bad;
11742
{
11743
#if PY_MAJOR_VERSION >= 3
11744
if (level == -1) {
11745
if (strchr(__Pyx_MODULE_NAME, '.')) {
11746
#if PY_VERSION_HEX < 0x03030000
11747
PyObject *py_level = PyInt_FromLong(1);
11748
if (!py_level)
11749
goto bad;
11750
module = PyObject_CallFunctionObjArgs(py_import,
11751
name, global_dict, empty_dict, list, py_level, NULL);
11752
Py_DECREF(py_level);
11753
#else
11754
module = PyImport_ImportModuleLevelObject(
11755
name, global_dict, empty_dict, list, 1);
11756
#endif
11757
if (!module) {
11758
if (!PyErr_ExceptionMatches(PyExc_ImportError))
11759
goto bad;
11760
PyErr_Clear();
11761
}
11762
}
11763
level = 0;
11764
}
11765
#endif
11766
if (!module) {
11767
#if PY_VERSION_HEX < 0x03030000
11768
PyObject *py_level = PyInt_FromLong(level);
11769
if (!py_level)
11770
goto bad;
11771
module = PyObject_CallFunctionObjArgs(py_import,
11772
name, global_dict, empty_dict, list, py_level, NULL);
11773
Py_DECREF(py_level);
11774
#else
11775
module = PyImport_ImportModuleLevelObject(
11776
name, global_dict, empty_dict, list, level);
11777
#endif
11778
}
11779
}
11780
bad:
11781
#if PY_VERSION_HEX < 0x03030000
11782
Py_XDECREF(py_import);
11783
#endif
11784
Py_XDECREF(empty_list);
11785
Py_XDECREF(empty_dict);
11786
return module;
11787
}
11788
11789
/* ImportFrom */
11790
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
11791
PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
11792
if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
11793
PyErr_Format(PyExc_ImportError,
11794
#if PY_MAJOR_VERSION < 3
11795
"cannot import name %.230s", PyString_AS_STRING(name));
11796
#else
11797
"cannot import name %S", name);
11798
#endif
11799
}
11800
return value;
11801
}
11802
11803
/* CodeObjectCache */
11804
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
11805
int start = 0, mid = 0, end = count - 1;
11806
if (end >= 0 && code_line > entries[end].code_line) {
11807
return count;
11808
}
11809
while (start < end) {
11810
mid = start + (end - start) / 2;
11811
if (code_line < entries[mid].code_line) {
11812
end = mid;
11813
} else if (code_line > entries[mid].code_line) {
11814
start = mid + 1;
11815
} else {
11816
return mid;
11817
}
11818
}
11819
if (code_line <= entries[mid].code_line) {
11820
return mid;
11821
} else {
11822
return mid + 1;
11823
}
11824
}
11825
static PyCodeObject *__pyx_find_code_object(int code_line) {
11826
PyCodeObject* code_object;
11827
int pos;
11828
if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
11829
return NULL;
11830
}
11831
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
11832
if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
11833
return NULL;
11834
}
11835
code_object = __pyx_code_cache.entries[pos].code_object;
11836
Py_INCREF(code_object);
11837
return code_object;
11838
}
11839
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
11840
int pos, i;
11841
__Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
11842
if (unlikely(!code_line)) {
11843
return;
11844
}
11845
if (unlikely(!entries)) {
11846
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
11847
if (likely(entries)) {
11848
__pyx_code_cache.entries = entries;
11849
__pyx_code_cache.max_count = 64;
11850
__pyx_code_cache.count = 1;
11851
entries[0].code_line = code_line;
11852
entries[0].code_object = code_object;
11853
Py_INCREF(code_object);
11854
}
11855
return;
11856
}
11857
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
11858
if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
11859
PyCodeObject* tmp = entries[pos].code_object;
11860
entries[pos].code_object = code_object;
11861
Py_DECREF(tmp);
11862
return;
11863
}
11864
if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
11865
int new_max = __pyx_code_cache.max_count + 64;
11866
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
11867
__pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
11868
if (unlikely(!entries)) {
11869
return;
11870
}
11871
__pyx_code_cache.entries = entries;
11872
__pyx_code_cache.max_count = new_max;
11873
}
11874
for (i=__pyx_code_cache.count; i>pos; i--) {
11875
entries[i] = entries[i-1];
11876
}
11877
entries[pos].code_line = code_line;
11878
entries[pos].code_object = code_object;
11879
__pyx_code_cache.count++;
11880
Py_INCREF(code_object);
11881
}
11882
11883
/* AddTraceback */
11884
#include "compile.h"
11885
#include "frameobject.h"
11886
#include "traceback.h"
11887
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
11888
const char *funcname, int c_line,
11889
int py_line, const char *filename) {
11890
PyCodeObject *py_code = 0;
11891
PyObject *py_srcfile = 0;
11892
PyObject *py_funcname = 0;
11893
#if PY_MAJOR_VERSION < 3
11894
py_srcfile = PyString_FromString(filename);
11895
#else
11896
py_srcfile = PyUnicode_FromString(filename);
11897
#endif
11898
if (!py_srcfile) goto bad;
11899
if (c_line) {
11900
#if PY_MAJOR_VERSION < 3
11901
py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
11902
#else
11903
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
11904
#endif
11905
}
11906
else {
11907
#if PY_MAJOR_VERSION < 3
11908
py_funcname = PyString_FromString(funcname);
11909
#else
11910
py_funcname = PyUnicode_FromString(funcname);
11911
#endif
11912
}
11913
if (!py_funcname) goto bad;
11914
py_code = __Pyx_PyCode_New(
11915
0,
11916
0,
11917
0,
11918
0,
11919
0,
11920
__pyx_empty_bytes, /*PyObject *code,*/
11921
__pyx_empty_tuple, /*PyObject *consts,*/
11922
__pyx_empty_tuple, /*PyObject *names,*/
11923
__pyx_empty_tuple, /*PyObject *varnames,*/
11924
__pyx_empty_tuple, /*PyObject *freevars,*/
11925
__pyx_empty_tuple, /*PyObject *cellvars,*/
11926
py_srcfile, /*PyObject *filename,*/
11927
py_funcname, /*PyObject *name,*/
11928
py_line,
11929
__pyx_empty_bytes /*PyObject *lnotab*/
11930
);
11931
Py_DECREF(py_srcfile);
11932
Py_DECREF(py_funcname);
11933
return py_code;
11934
bad:
11935
Py_XDECREF(py_srcfile);
11936
Py_XDECREF(py_funcname);
11937
return NULL;
11938
}
11939
static void __Pyx_AddTraceback(const char *funcname, int c_line,
11940
int py_line, const char *filename) {
11941
PyCodeObject *py_code = 0;
11942
PyFrameObject *py_frame = 0;
11943
py_code = __pyx_find_code_object(c_line ? c_line : py_line);
11944
if (!py_code) {
11945
py_code = __Pyx_CreateCodeObjectForTraceback(
11946
funcname, c_line, py_line, filename);
11947
if (!py_code) goto bad;
11948
__pyx_insert_code_object(c_line ? c_line : py_line, py_code);
11949
}
11950
py_frame = PyFrame_New(
11951
PyThreadState_GET(), /*PyThreadState *tstate,*/
11952
py_code, /*PyCodeObject *code,*/
11953
__pyx_d, /*PyObject *globals,*/
11954
0 /*PyObject *locals*/
11955
);
11956
if (!py_frame) goto bad;
11957
__Pyx_PyFrame_SetLineNumber(py_frame, py_line);
11958
PyTraceBack_Here(py_frame);
11959
bad:
11960
Py_XDECREF(py_code);
11961
Py_XDECREF(py_frame);
11962
}
11963
11964
/* CIntToPy */
11965
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value) {
11966
const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0;
11967
const int is_unsigned = neg_one > const_zero;
11968
if (is_unsigned) {
11969
if (sizeof(int64_t) < sizeof(long)) {
11970
return PyInt_FromLong((long) value);
11971
} else if (sizeof(int64_t) <= sizeof(unsigned long)) {
11972
return PyLong_FromUnsignedLong((unsigned long) value);
11973
#ifdef HAVE_LONG_LONG
11974
} else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
11975
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
11976
#endif
11977
}
11978
} else {
11979
if (sizeof(int64_t) <= sizeof(long)) {
11980
return PyInt_FromLong((long) value);
11981
#ifdef HAVE_LONG_LONG
11982
} else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
11983
return PyLong_FromLongLong((PY_LONG_LONG) value);
11984
#endif
11985
}
11986
}
11987
{
11988
int one = 1; int little = (int)*(unsigned char *)&one;
11989
unsigned char *bytes = (unsigned char *)&value;
11990
return _PyLong_FromByteArray(bytes, sizeof(int64_t),
11991
little, !is_unsigned);
11992
}
11993
}
11994
11995
/* CIntFromPyVerify */
11996
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
11997
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
11998
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
11999
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
12000
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
12001
{\
12002
func_type value = func_value;\
12003
if (sizeof(target_type) < sizeof(func_type)) {\
12004
if (unlikely(value != (func_type) (target_type) value)) {\
12005
func_type zero = 0;\
12006
if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
12007
return (target_type) -1;\
12008
if (is_unsigned && unlikely(value < zero))\
12009
goto raise_neg_overflow;\
12010
else\
12011
goto raise_overflow;\
12012
}\
12013
}\
12014
return (target_type) value;\
12015
}
12016
12017
/* CIntToPy */
12018
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value) {
12019
const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0;
12020
const int is_unsigned = neg_one > const_zero;
12021
if (is_unsigned) {
12022
if (sizeof(uint64_t) < sizeof(long)) {
12023
return PyInt_FromLong((long) value);
12024
} else if (sizeof(uint64_t) <= sizeof(unsigned long)) {
12025
return PyLong_FromUnsignedLong((unsigned long) value);
12026
#ifdef HAVE_LONG_LONG
12027
} else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
12028
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
12029
#endif
12030
}
12031
} else {
12032
if (sizeof(uint64_t) <= sizeof(long)) {
12033
return PyInt_FromLong((long) value);
12034
#ifdef HAVE_LONG_LONG
12035
} else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
12036
return PyLong_FromLongLong((PY_LONG_LONG) value);
12037
#endif
12038
}
12039
}
12040
{
12041
int one = 1; int little = (int)*(unsigned char *)&one;
12042
unsigned char *bytes = (unsigned char *)&value;
12043
return _PyLong_FromByteArray(bytes, sizeof(uint64_t),
12044
little, !is_unsigned);
12045
}
12046
}
12047
12048
/* CIntFromPy */
12049
static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *x) {
12050
const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0;
12051
const int is_unsigned = neg_one > const_zero;
12052
#if PY_MAJOR_VERSION < 3
12053
if (likely(PyInt_Check(x))) {
12054
if (sizeof(uint64_t) < sizeof(long)) {
12055
__PYX_VERIFY_RETURN_INT(uint64_t, long, PyInt_AS_LONG(x))
12056
} else {
12057
long val = PyInt_AS_LONG(x);
12058
if (is_unsigned && unlikely(val < 0)) {
12059
goto raise_neg_overflow;
12060
}
12061
return (uint64_t) val;
12062
}
12063
} else
12064
#endif
12065
if (likely(PyLong_Check(x))) {
12066
if (is_unsigned) {
12067
#if CYTHON_USE_PYLONG_INTERNALS
12068
const digit* digits = ((PyLongObject*)x)->ob_digit;
12069
switch (Py_SIZE(x)) {
12070
case 0: return (uint64_t) 0;
12071
case 1: __PYX_VERIFY_RETURN_INT(uint64_t, digit, digits[0])
12072
case 2:
12073
if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
12074
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
12075
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12076
} else if (8 * sizeof(uint64_t) >= 2 * PyLong_SHIFT) {
12077
return (uint64_t) (((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
12078
}
12079
}
12080
break;
12081
case 3:
12082
if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
12083
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
12084
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12085
} else if (8 * sizeof(uint64_t) >= 3 * PyLong_SHIFT) {
12086
return (uint64_t) (((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
12087
}
12088
}
12089
break;
12090
case 4:
12091
if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
12092
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
12093
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12094
} else if (8 * sizeof(uint64_t) >= 4 * PyLong_SHIFT) {
12095
return (uint64_t) (((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
12096
}
12097
}
12098
break;
12099
}
12100
#endif
12101
#if CYTHON_COMPILING_IN_CPYTHON
12102
if (unlikely(Py_SIZE(x) < 0)) {
12103
goto raise_neg_overflow;
12104
}
12105
#else
12106
{
12107
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
12108
if (unlikely(result < 0))
12109
return (uint64_t) -1;
12110
if (unlikely(result == 1))
12111
goto raise_neg_overflow;
12112
}
12113
#endif
12114
if (sizeof(uint64_t) <= sizeof(unsigned long)) {
12115
__PYX_VERIFY_RETURN_INT_EXC(uint64_t, unsigned long, PyLong_AsUnsignedLong(x))
12116
#ifdef HAVE_LONG_LONG
12117
} else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
12118
__PYX_VERIFY_RETURN_INT_EXC(uint64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
12119
#endif
12120
}
12121
} else {
12122
#if CYTHON_USE_PYLONG_INTERNALS
12123
const digit* digits = ((PyLongObject*)x)->ob_digit;
12124
switch (Py_SIZE(x)) {
12125
case 0: return (uint64_t) 0;
12126
case -1: __PYX_VERIFY_RETURN_INT(uint64_t, sdigit, (sdigit) (-(sdigit)digits[0]))
12127
case 1: __PYX_VERIFY_RETURN_INT(uint64_t, digit, +digits[0])
12128
case -2:
12129
if (8 * sizeof(uint64_t) - 1 > 1 * PyLong_SHIFT) {
12130
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
12131
__PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12132
} else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
12133
return (uint64_t) (((uint64_t)-1)*(((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
12134
}
12135
}
12136
break;
12137
case 2:
12138
if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
12139
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
12140
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12141
} else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
12142
return (uint64_t) ((((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
12143
}
12144
}
12145
break;
12146
case -3:
12147
if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
12148
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
12149
__PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12150
} else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
12151
return (uint64_t) (((uint64_t)-1)*(((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
12152
}
12153
}
12154
break;
12155
case 3:
12156
if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
12157
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
12158
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12159
} else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
12160
return (uint64_t) ((((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
12161
}
12162
}
12163
break;
12164
case -4:
12165
if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
12166
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
12167
__PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12168
} else if (8 * sizeof(uint64_t) - 1 > 4 * PyLong_SHIFT) {
12169
return (uint64_t) (((uint64_t)-1)*(((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
12170
}
12171
}
12172
break;
12173
case 4:
12174
if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
12175
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
12176
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12177
} else if (8 * sizeof(uint64_t) - 1 > 4 * PyLong_SHIFT) {
12178
return (uint64_t) ((((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
12179
}
12180
}
12181
break;
12182
}
12183
#endif
12184
if (sizeof(uint64_t) <= sizeof(long)) {
12185
__PYX_VERIFY_RETURN_INT_EXC(uint64_t, long, PyLong_AsLong(x))
12186
#ifdef HAVE_LONG_LONG
12187
} else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
12188
__PYX_VERIFY_RETURN_INT_EXC(uint64_t, PY_LONG_LONG, PyLong_AsLongLong(x))
12189
#endif
12190
}
12191
}
12192
{
12193
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
12194
PyErr_SetString(PyExc_RuntimeError,
12195
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
12196
#else
12197
uint64_t val;
12198
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
12199
#if PY_MAJOR_VERSION < 3
12200
if (likely(v) && !PyLong_Check(v)) {
12201
PyObject *tmp = v;
12202
v = PyNumber_Long(tmp);
12203
Py_DECREF(tmp);
12204
}
12205
#endif
12206
if (likely(v)) {
12207
int one = 1; int is_little = (int)*(unsigned char *)&one;
12208
unsigned char *bytes = (unsigned char *)&val;
12209
int ret = _PyLong_AsByteArray((PyLongObject *)v,
12210
bytes, sizeof(val),
12211
is_little, !is_unsigned);
12212
Py_DECREF(v);
12213
if (likely(!ret))
12214
return val;
12215
}
12216
#endif
12217
return (uint64_t) -1;
12218
}
12219
} else {
12220
uint64_t val;
12221
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
12222
if (!tmp) return (uint64_t) -1;
12223
val = __Pyx_PyInt_As_uint64_t(tmp);
12224
Py_DECREF(tmp);
12225
return val;
12226
}
12227
raise_overflow:
12228
PyErr_SetString(PyExc_OverflowError,
12229
"value too large to convert to uint64_t");
12230
return (uint64_t) -1;
12231
raise_neg_overflow:
12232
PyErr_SetString(PyExc_OverflowError,
12233
"can't convert negative value to uint64_t");
12234
return (uint64_t) -1;
12235
}
12236
12237
/* CIntFromPy */
12238
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
12239
const int neg_one = (int) -1, const_zero = (int) 0;
12240
const int is_unsigned = neg_one > const_zero;
12241
#if PY_MAJOR_VERSION < 3
12242
if (likely(PyInt_Check(x))) {
12243
if (sizeof(int) < sizeof(long)) {
12244
__PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
12245
} else {
12246
long val = PyInt_AS_LONG(x);
12247
if (is_unsigned && unlikely(val < 0)) {
12248
goto raise_neg_overflow;
12249
}
12250
return (int) val;
12251
}
12252
} else
12253
#endif
12254
if (likely(PyLong_Check(x))) {
12255
if (is_unsigned) {
12256
#if CYTHON_USE_PYLONG_INTERNALS
12257
const digit* digits = ((PyLongObject*)x)->ob_digit;
12258
switch (Py_SIZE(x)) {
12259
case 0: return (int) 0;
12260
case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
12261
case 2:
12262
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
12263
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
12264
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12265
} else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
12266
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
12267
}
12268
}
12269
break;
12270
case 3:
12271
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
12272
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
12273
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12274
} else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
12275
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
12276
}
12277
}
12278
break;
12279
case 4:
12280
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
12281
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
12282
__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])))
12283
} else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
12284
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
12285
}
12286
}
12287
break;
12288
}
12289
#endif
12290
#if CYTHON_COMPILING_IN_CPYTHON
12291
if (unlikely(Py_SIZE(x) < 0)) {
12292
goto raise_neg_overflow;
12293
}
12294
#else
12295
{
12296
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
12297
if (unlikely(result < 0))
12298
return (int) -1;
12299
if (unlikely(result == 1))
12300
goto raise_neg_overflow;
12301
}
12302
#endif
12303
if (sizeof(int) <= sizeof(unsigned long)) {
12304
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
12305
#ifdef HAVE_LONG_LONG
12306
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
12307
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
12308
#endif
12309
}
12310
} else {
12311
#if CYTHON_USE_PYLONG_INTERNALS
12312
const digit* digits = ((PyLongObject*)x)->ob_digit;
12313
switch (Py_SIZE(x)) {
12314
case 0: return (int) 0;
12315
case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
12316
case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
12317
case -2:
12318
if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
12319
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
12320
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12321
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
12322
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
12323
}
12324
}
12325
break;
12326
case 2:
12327
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
12328
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
12329
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12330
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
12331
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
12332
}
12333
}
12334
break;
12335
case -3:
12336
if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
12337
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
12338
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12339
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
12340
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
12341
}
12342
}
12343
break;
12344
case 3:
12345
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
12346
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
12347
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12348
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
12349
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
12350
}
12351
}
12352
break;
12353
case -4:
12354
if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
12355
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
12356
__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])))
12357
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
12358
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
12359
}
12360
}
12361
break;
12362
case 4:
12363
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
12364
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
12365
__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])))
12366
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
12367
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
12368
}
12369
}
12370
break;
12371
}
12372
#endif
12373
if (sizeof(int) <= sizeof(long)) {
12374
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
12375
#ifdef HAVE_LONG_LONG
12376
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
12377
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
12378
#endif
12379
}
12380
}
12381
{
12382
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
12383
PyErr_SetString(PyExc_RuntimeError,
12384
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
12385
#else
12386
int val;
12387
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
12388
#if PY_MAJOR_VERSION < 3
12389
if (likely(v) && !PyLong_Check(v)) {
12390
PyObject *tmp = v;
12391
v = PyNumber_Long(tmp);
12392
Py_DECREF(tmp);
12393
}
12394
#endif
12395
if (likely(v)) {
12396
int one = 1; int is_little = (int)*(unsigned char *)&one;
12397
unsigned char *bytes = (unsigned char *)&val;
12398
int ret = _PyLong_AsByteArray((PyLongObject *)v,
12399
bytes, sizeof(val),
12400
is_little, !is_unsigned);
12401
Py_DECREF(v);
12402
if (likely(!ret))
12403
return val;
12404
}
12405
#endif
12406
return (int) -1;
12407
}
12408
} else {
12409
int val;
12410
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
12411
if (!tmp) return (int) -1;
12412
val = __Pyx_PyInt_As_int(tmp);
12413
Py_DECREF(tmp);
12414
return val;
12415
}
12416
raise_overflow:
12417
PyErr_SetString(PyExc_OverflowError,
12418
"value too large to convert to int");
12419
return (int) -1;
12420
raise_neg_overflow:
12421
PyErr_SetString(PyExc_OverflowError,
12422
"can't convert negative value to int");
12423
return (int) -1;
12424
}
12425
12426
/* CIntToPy */
12427
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
12428
const long neg_one = (long) -1, const_zero = (long) 0;
12429
const int is_unsigned = neg_one > const_zero;
12430
if (is_unsigned) {
12431
if (sizeof(long) < sizeof(long)) {
12432
return PyInt_FromLong((long) value);
12433
} else if (sizeof(long) <= sizeof(unsigned long)) {
12434
return PyLong_FromUnsignedLong((unsigned long) value);
12435
#ifdef HAVE_LONG_LONG
12436
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
12437
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
12438
#endif
12439
}
12440
} else {
12441
if (sizeof(long) <= sizeof(long)) {
12442
return PyInt_FromLong((long) value);
12443
#ifdef HAVE_LONG_LONG
12444
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
12445
return PyLong_FromLongLong((PY_LONG_LONG) value);
12446
#endif
12447
}
12448
}
12449
{
12450
int one = 1; int little = (int)*(unsigned char *)&one;
12451
unsigned char *bytes = (unsigned char *)&value;
12452
return _PyLong_FromByteArray(bytes, sizeof(long),
12453
little, !is_unsigned);
12454
}
12455
}
12456
12457
/* CIntFromPy */
12458
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
12459
const long neg_one = (long) -1, const_zero = (long) 0;
12460
const int is_unsigned = neg_one > const_zero;
12461
#if PY_MAJOR_VERSION < 3
12462
if (likely(PyInt_Check(x))) {
12463
if (sizeof(long) < sizeof(long)) {
12464
__PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
12465
} else {
12466
long val = PyInt_AS_LONG(x);
12467
if (is_unsigned && unlikely(val < 0)) {
12468
goto raise_neg_overflow;
12469
}
12470
return (long) val;
12471
}
12472
} else
12473
#endif
12474
if (likely(PyLong_Check(x))) {
12475
if (is_unsigned) {
12476
#if CYTHON_USE_PYLONG_INTERNALS
12477
const digit* digits = ((PyLongObject*)x)->ob_digit;
12478
switch (Py_SIZE(x)) {
12479
case 0: return (long) 0;
12480
case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
12481
case 2:
12482
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
12483
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
12484
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12485
} else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
12486
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
12487
}
12488
}
12489
break;
12490
case 3:
12491
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
12492
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
12493
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12494
} else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
12495
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
12496
}
12497
}
12498
break;
12499
case 4:
12500
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
12501
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
12502
__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])))
12503
} else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
12504
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
12505
}
12506
}
12507
break;
12508
}
12509
#endif
12510
#if CYTHON_COMPILING_IN_CPYTHON
12511
if (unlikely(Py_SIZE(x) < 0)) {
12512
goto raise_neg_overflow;
12513
}
12514
#else
12515
{
12516
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
12517
if (unlikely(result < 0))
12518
return (long) -1;
12519
if (unlikely(result == 1))
12520
goto raise_neg_overflow;
12521
}
12522
#endif
12523
if (sizeof(long) <= sizeof(unsigned long)) {
12524
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
12525
#ifdef HAVE_LONG_LONG
12526
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
12527
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
12528
#endif
12529
}
12530
} else {
12531
#if CYTHON_USE_PYLONG_INTERNALS
12532
const digit* digits = ((PyLongObject*)x)->ob_digit;
12533
switch (Py_SIZE(x)) {
12534
case 0: return (long) 0;
12535
case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
12536
case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
12537
case -2:
12538
if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
12539
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
12540
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12541
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
12542
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12543
}
12544
}
12545
break;
12546
case 2:
12547
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
12548
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
12549
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12550
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
12551
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12552
}
12553
}
12554
break;
12555
case -3:
12556
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
12557
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
12558
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12559
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
12560
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12561
}
12562
}
12563
break;
12564
case 3:
12565
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
12566
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
12567
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12568
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
12569
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12570
}
12571
}
12572
break;
12573
case -4:
12574
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
12575
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
12576
__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])))
12577
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
12578
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12579
}
12580
}
12581
break;
12582
case 4:
12583
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
12584
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
12585
__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])))
12586
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
12587
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12588
}
12589
}
12590
break;
12591
}
12592
#endif
12593
if (sizeof(long) <= sizeof(long)) {
12594
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
12595
#ifdef HAVE_LONG_LONG
12596
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
12597
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
12598
#endif
12599
}
12600
}
12601
{
12602
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
12603
PyErr_SetString(PyExc_RuntimeError,
12604
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
12605
#else
12606
long val;
12607
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
12608
#if PY_MAJOR_VERSION < 3
12609
if (likely(v) && !PyLong_Check(v)) {
12610
PyObject *tmp = v;
12611
v = PyNumber_Long(tmp);
12612
Py_DECREF(tmp);
12613
}
12614
#endif
12615
if (likely(v)) {
12616
int one = 1; int is_little = (int)*(unsigned char *)&one;
12617
unsigned char *bytes = (unsigned char *)&val;
12618
int ret = _PyLong_AsByteArray((PyLongObject *)v,
12619
bytes, sizeof(val),
12620
is_little, !is_unsigned);
12621
Py_DECREF(v);
12622
if (likely(!ret))
12623
return val;
12624
}
12625
#endif
12626
return (long) -1;
12627
}
12628
} else {
12629
long val;
12630
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
12631
if (!tmp) return (long) -1;
12632
val = __Pyx_PyInt_As_long(tmp);
12633
Py_DECREF(tmp);
12634
return val;
12635
}
12636
raise_overflow:
12637
PyErr_SetString(PyExc_OverflowError,
12638
"value too large to convert to long");
12639
return (long) -1;
12640
raise_neg_overflow:
12641
PyErr_SetString(PyExc_OverflowError,
12642
"can't convert negative value to long");
12643
return (long) -1;
12644
}
12645
12646
/* CheckBinaryVersion */
12647
static int __Pyx_check_binary_version(void) {
12648
char ctversion[4], rtversion[4];
12649
PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
12650
PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
12651
if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
12652
char message[200];
12653
PyOS_snprintf(message, sizeof(message),
12654
"compiletime version %s of module '%.100s' "
12655
"does not match runtime version %s",
12656
ctversion, __Pyx_MODULE_NAME, rtversion);
12657
return PyErr_WarnEx(NULL, message, 1);
12658
}
12659
return 0;
12660
}
12661
12662
/* ModuleImport */
12663
#ifndef __PYX_HAVE_RT_ImportModule
12664
#define __PYX_HAVE_RT_ImportModule
12665
static PyObject *__Pyx_ImportModule(const char *name) {
12666
PyObject *py_name = 0;
12667
PyObject *py_module = 0;
12668
py_name = __Pyx_PyIdentifier_FromString(name);
12669
if (!py_name)
12670
goto bad;
12671
py_module = PyImport_Import(py_name);
12672
Py_DECREF(py_name);
12673
return py_module;
12674
bad:
12675
Py_XDECREF(py_name);
12676
return 0;
12677
}
12678
#endif
12679
12680
/* TypeImport */
12681
#ifndef __PYX_HAVE_RT_ImportType
12682
#define __PYX_HAVE_RT_ImportType
12683
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
12684
size_t size, int strict)
12685
{
12686
PyObject *py_module = 0;
12687
PyObject *result = 0;
12688
PyObject *py_name = 0;
12689
char warning[200];
12690
Py_ssize_t basicsize;
12691
#ifdef Py_LIMITED_API
12692
PyObject *py_basicsize;
12693
#endif
12694
py_module = __Pyx_ImportModule(module_name);
12695
if (!py_module)
12696
goto bad;
12697
py_name = __Pyx_PyIdentifier_FromString(class_name);
12698
if (!py_name)
12699
goto bad;
12700
result = PyObject_GetAttr(py_module, py_name);
12701
Py_DECREF(py_name);
12702
py_name = 0;
12703
Py_DECREF(py_module);
12704
py_module = 0;
12705
if (!result)
12706
goto bad;
12707
if (!PyType_Check(result)) {
12708
PyErr_Format(PyExc_TypeError,
12709
"%.200s.%.200s is not a type object",
12710
module_name, class_name);
12711
goto bad;
12712
}
12713
#ifndef Py_LIMITED_API
12714
basicsize = ((PyTypeObject *)result)->tp_basicsize;
12715
#else
12716
py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
12717
if (!py_basicsize)
12718
goto bad;
12719
basicsize = PyLong_AsSsize_t(py_basicsize);
12720
Py_DECREF(py_basicsize);
12721
py_basicsize = 0;
12722
if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
12723
goto bad;
12724
#endif
12725
if (!strict && (size_t)basicsize > size) {
12726
PyOS_snprintf(warning, sizeof(warning),
12727
"%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
12728
module_name, class_name, basicsize, size);
12729
if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
12730
}
12731
else if ((size_t)basicsize != size) {
12732
PyErr_Format(PyExc_ValueError,
12733
"%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
12734
module_name, class_name, basicsize, size);
12735
goto bad;
12736
}
12737
return (PyTypeObject *)result;
12738
bad:
12739
Py_XDECREF(py_module);
12740
Py_XDECREF(result);
12741
return NULL;
12742
}
12743
#endif
12744
12745
/* VoidPtrImport */
12746
#ifndef __PYX_HAVE_RT_ImportVoidPtr
12747
#define __PYX_HAVE_RT_ImportVoidPtr
12748
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
12749
PyObject *d = 0;
12750
PyObject *cobj = 0;
12751
d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
12752
if (!d)
12753
goto bad;
12754
cobj = PyDict_GetItemString(d, name);
12755
if (!cobj) {
12756
PyErr_Format(PyExc_ImportError,
12757
"%.200s does not export expected C variable %.200s",
12758
PyModule_GetName(module), name);
12759
goto bad;
12760
}
12761
#if PY_VERSION_HEX >= 0x02070000
12762
if (!PyCapsule_IsValid(cobj, sig)) {
12763
PyErr_Format(PyExc_TypeError,
12764
"C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
12765
PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
12766
goto bad;
12767
}
12768
*p = PyCapsule_GetPointer(cobj, sig);
12769
#else
12770
{const char *desc, *s1, *s2;
12771
desc = (const char *)PyCObject_GetDesc(cobj);
12772
if (!desc)
12773
goto bad;
12774
s1 = desc; s2 = sig;
12775
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
12776
if (*s1 != *s2) {
12777
PyErr_Format(PyExc_TypeError,
12778
"C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
12779
PyModule_GetName(module), name, sig, desc);
12780
goto bad;
12781
}
12782
*p = PyCObject_AsVoidPtr(cobj);}
12783
#endif
12784
if (!(*p))
12785
goto bad;
12786
Py_DECREF(d);
12787
return 0;
12788
bad:
12789
Py_XDECREF(d);
12790
return -1;
12791
}
12792
#endif
12793
12794
/* InitStrings */
12795
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
12796
while (t->p) {
12797
#if PY_MAJOR_VERSION < 3
12798
if (t->is_unicode) {
12799
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
12800
} else if (t->intern) {
12801
*t->p = PyString_InternFromString(t->s);
12802
} else {
12803
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
12804
}
12805
#else
12806
if (t->is_unicode | t->is_str) {
12807
if (t->intern) {
12808
*t->p = PyUnicode_InternFromString(t->s);
12809
} else if (t->encoding) {
12810
*t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
12811
} else {
12812
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
12813
}
12814
} else {
12815
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
12816
}
12817
#endif
12818
if (!*t->p)
12819
return -1;
12820
++t;
12821
}
12822
return 0;
12823
}
12824
12825
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
12826
return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
12827
}
12828
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
12829
Py_ssize_t ignore;
12830
return __Pyx_PyObject_AsStringAndSize(o, &ignore);
12831
}
12832
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
12833
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
12834
if (
12835
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
12836
__Pyx_sys_getdefaultencoding_not_ascii &&
12837
#endif
12838
PyUnicode_Check(o)) {
12839
#if PY_VERSION_HEX < 0x03030000
12840
char* defenc_c;
12841
PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
12842
if (!defenc) return NULL;
12843
defenc_c = PyBytes_AS_STRING(defenc);
12844
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
12845
{
12846
char* end = defenc_c + PyBytes_GET_SIZE(defenc);
12847
char* c;
12848
for (c = defenc_c; c < end; c++) {
12849
if ((unsigned char) (*c) >= 128) {
12850
PyUnicode_AsASCIIString(o);
12851
return NULL;
12852
}
12853
}
12854
}
12855
#endif
12856
*length = PyBytes_GET_SIZE(defenc);
12857
return defenc_c;
12858
#else
12859
if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
12860
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
12861
if (PyUnicode_IS_ASCII(o)) {
12862
*length = PyUnicode_GET_LENGTH(o);
12863
return PyUnicode_AsUTF8(o);
12864
} else {
12865
PyUnicode_AsASCIIString(o);
12866
return NULL;
12867
}
12868
#else
12869
return PyUnicode_AsUTF8AndSize(o, length);
12870
#endif
12871
#endif
12872
} else
12873
#endif
12874
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
12875
if (PyByteArray_Check(o)) {
12876
*length = PyByteArray_GET_SIZE(o);
12877
return PyByteArray_AS_STRING(o);
12878
} else
12879
#endif
12880
{
12881
char* result;
12882
int r = PyBytes_AsStringAndSize(o, &result, length);
12883
if (unlikely(r < 0)) {
12884
return NULL;
12885
} else {
12886
return result;
12887
}
12888
}
12889
}
12890
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
12891
int is_true = x == Py_True;
12892
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
12893
else return PyObject_IsTrue(x);
12894
}
12895
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
12896
#if CYTHON_USE_TYPE_SLOTS
12897
PyNumberMethods *m;
12898
#endif
12899
const char *name = NULL;
12900
PyObject *res = NULL;
12901
#if PY_MAJOR_VERSION < 3
12902
if (PyInt_Check(x) || PyLong_Check(x))
12903
#else
12904
if (PyLong_Check(x))
12905
#endif
12906
return __Pyx_NewRef(x);
12907
#if CYTHON_USE_TYPE_SLOTS
12908
m = Py_TYPE(x)->tp_as_number;
12909
#if PY_MAJOR_VERSION < 3
12910
if (m && m->nb_int) {
12911
name = "int";
12912
res = PyNumber_Int(x);
12913
}
12914
else if (m && m->nb_long) {
12915
name = "long";
12916
res = PyNumber_Long(x);
12917
}
12918
#else
12919
if (m && m->nb_int) {
12920
name = "int";
12921
res = PyNumber_Long(x);
12922
}
12923
#endif
12924
#else
12925
res = PyNumber_Int(x);
12926
#endif
12927
if (res) {
12928
#if PY_MAJOR_VERSION < 3
12929
if (!PyInt_Check(res) && !PyLong_Check(res)) {
12930
#else
12931
if (!PyLong_Check(res)) {
12932
#endif
12933
PyErr_Format(PyExc_TypeError,
12934
"__%.4s__ returned non-%.4s (type %.200s)",
12935
name, name, Py_TYPE(res)->tp_name);
12936
Py_DECREF(res);
12937
return NULL;
12938
}
12939
}
12940
else if (!PyErr_Occurred()) {
12941
PyErr_SetString(PyExc_TypeError,
12942
"an integer is required");
12943
}
12944
return res;
12945
}
12946
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
12947
Py_ssize_t ival;
12948
PyObject *x;
12949
#if PY_MAJOR_VERSION < 3
12950
if (likely(PyInt_CheckExact(b))) {
12951
if (sizeof(Py_ssize_t) >= sizeof(long))
12952
return PyInt_AS_LONG(b);
12953
else
12954
return PyInt_AsSsize_t(x);
12955
}
12956
#endif
12957
if (likely(PyLong_CheckExact(b))) {
12958
#if CYTHON_USE_PYLONG_INTERNALS
12959
const digit* digits = ((PyLongObject*)b)->ob_digit;
12960
const Py_ssize_t size = Py_SIZE(b);
12961
if (likely(__Pyx_sst_abs(size) <= 1)) {
12962
ival = likely(size) ? digits[0] : 0;
12963
if (size == -1) ival = -ival;
12964
return ival;
12965
} else {
12966
switch (size) {
12967
case 2:
12968
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
12969
return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12970
}
12971
break;
12972
case -2:
12973
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
12974
return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12975
}
12976
break;
12977
case 3:
12978
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
12979
return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12980
}
12981
break;
12982
case -3:
12983
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
12984
return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12985
}
12986
break;
12987
case 4:
12988
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
12989
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]));
12990
}
12991
break;
12992
case -4:
12993
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
12994
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]));
12995
}
12996
break;
12997
}
12998
}
12999
#endif
13000
return PyLong_AsSsize_t(b);
13001
}
13002
x = PyNumber_Index(b);
13003
if (!x) return -1;
13004
ival = PyInt_AsSsize_t(x);
13005
Py_DECREF(x);
13006
return ival;
13007
}
13008
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
13009
return PyInt_FromSize_t(ival);
13010
}
13011
13012
13013
#endif /* Py_PYTHON_H */
13014
13015