1
2 /////////////// CDivisionWarning.proto ///////////////
3
4 static int __Pyx_cdivision_warning(const char *, int); /* proto */
5
6 /////////////// CDivisionWarning ///////////////
7
__Pyx_cdivision_warning(const char * filename,int lineno)8 static int __Pyx_cdivision_warning(const char *filename, int lineno) {
9 #if CYTHON_COMPILING_IN_PYPY
10 // avoid compiler warnings
11 filename++; lineno++;
12 return PyErr_Warn(PyExc_RuntimeWarning,
13 "division with oppositely signed operands, C and Python semantics differ");
14 #else
15 return PyErr_WarnExplicit(PyExc_RuntimeWarning,
16 "division with oppositely signed operands, C and Python semantics differ",
17 filename,
18 lineno,
19 __Pyx_MODULE_NAME,
20 NULL);
21 #endif
22 }
23
24
25 /////////////// DivInt.proto ///////////////
26
27 static CYTHON_INLINE %(type)s __Pyx_div_%(type_name)s(%(type)s, %(type)s); /* proto */
28
29 /////////////// DivInt ///////////////
30
31 static CYTHON_INLINE %(type)s __Pyx_div_%(type_name)s(%(type)s a, %(type)s b) {
32 %(type)s q = a / b;
33 %(type)s r = a - q*b;
34 q -= ((r != 0) & ((r ^ b) < 0));
35 return q;
36 }
37
38
39 /////////////// ModInt.proto ///////////////
40
41 static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s, %(type)s); /* proto */
42
43 /////////////// ModInt ///////////////
44
45 static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s a, %(type)s b) {
46 %(type)s r = a %% b;
47 r += ((r != 0) & ((r ^ b) < 0)) * b;
48 return r;
49 }
50
51
52 /////////////// ModFloat.proto ///////////////
53
54 static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s, %(type)s); /* proto */
55
56 /////////////// ModFloat ///////////////
57
58 static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s a, %(type)s b) {
59 %(type)s r = fmod%(math_h_modifier)s(a, b);
60 r += ((r != 0) & ((r < 0) ^ (b < 0))) * b;
61 return r;
62 }
63
64
65 /////////////// IntPow.proto ///////////////
66
67 static CYTHON_INLINE %(type)s %(func_name)s(%(type)s, %(type)s); /* proto */
68
69 /////////////// IntPow ///////////////
70
71 static CYTHON_INLINE %(type)s %(func_name)s(%(type)s b, %(type)s e) {
72 %(type)s t = b;
73 switch (e) {
74 case 3:
75 t *= b;
76 CYTHON_FALLTHROUGH;
77 case 2:
78 t *= b;
79 CYTHON_FALLTHROUGH;
80 case 1:
81 return t;
82 case 0:
83 return 1;
84 }
85 #if %(signed)s
86 if (unlikely(e<0)) return 0;
87 #endif
88 t = 1;
89 while (likely(e)) {
90 t *= (b * (e&1)) | ((~e)&1); /* 1 or b */
91 b *= b;
92 e >>= 1;
93 }
94 return t;
95 }
96