1 /* Generated by Cython 0.29.21 */
2
3 /* BEGIN: Cython Metadata
4 {
5 "distutils": {
6 "depends": [
7 "gensim/models/voidptr.h"
8 ],
9 "include_dirs": [
10 "gensim/models",
11 "./gensim/models"
12 ],
13 "language": "c",
14 "name": "gensim.models.fasttext_inner",
15 "sources": [
16 "gensim/models/fasttext_inner.pyx"
17 ]
18 },
19 "module_name": "gensim.models.fasttext_inner"
20 }
21 END: Cython Metadata */
22
23 #define PY_SSIZE_T_CLEAN
24 #include "Python.h"
25 #ifndef Py_PYTHON_H
26 #error Python headers needed to compile C extensions, please install development version of Python.
27 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
28 #error Cython requires Python 2.6+ or Python 3.3+.
29 #else
30 #define CYTHON_ABI "0_29_21"
31 #define CYTHON_HEX_VERSION 0x001D15F0
32 #define CYTHON_FUTURE_DIVISION 0
33 #include <stddef.h>
34 #ifndef offsetof
35 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
36 #endif
37 #if !defined(WIN32) && !defined(MS_WINDOWS)
38 #ifndef __stdcall
39 #define __stdcall
40 #endif
41 #ifndef __cdecl
42 #define __cdecl
43 #endif
44 #ifndef __fastcall
45 #define __fastcall
46 #endif
47 #endif
48 #ifndef DL_IMPORT
49 #define DL_IMPORT(t) t
50 #endif
51 #ifndef DL_EXPORT
52 #define DL_EXPORT(t) t
53 #endif
54 #define __PYX_COMMA ,
55 #ifndef HAVE_LONG_LONG
56 #if PY_VERSION_HEX >= 0x02070000
57 #define HAVE_LONG_LONG
58 #endif
59 #endif
60 #ifndef PY_LONG_LONG
61 #define PY_LONG_LONG LONG_LONG
62 #endif
63 #ifndef Py_HUGE_VAL
64 #define Py_HUGE_VAL HUGE_VAL
65 #endif
66 #ifdef PYPY_VERSION
67 #define CYTHON_COMPILING_IN_PYPY 1
68 #define CYTHON_COMPILING_IN_PYSTON 0
69 #define CYTHON_COMPILING_IN_CPYTHON 0
70 #undef CYTHON_USE_TYPE_SLOTS
71 #define CYTHON_USE_TYPE_SLOTS 0
72 #undef CYTHON_USE_PYTYPE_LOOKUP
73 #define CYTHON_USE_PYTYPE_LOOKUP 0
74 #if PY_VERSION_HEX < 0x03050000
75 #undef CYTHON_USE_ASYNC_SLOTS
76 #define CYTHON_USE_ASYNC_SLOTS 0
77 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
78 #define CYTHON_USE_ASYNC_SLOTS 1
79 #endif
80 #undef CYTHON_USE_PYLIST_INTERNALS
81 #define CYTHON_USE_PYLIST_INTERNALS 0
82 #undef CYTHON_USE_UNICODE_INTERNALS
83 #define CYTHON_USE_UNICODE_INTERNALS 0
84 #undef CYTHON_USE_UNICODE_WRITER
85 #define CYTHON_USE_UNICODE_WRITER 0
86 #undef CYTHON_USE_PYLONG_INTERNALS
87 #define CYTHON_USE_PYLONG_INTERNALS 0
88 #undef CYTHON_AVOID_BORROWED_REFS
89 #define CYTHON_AVOID_BORROWED_REFS 1
90 #undef CYTHON_ASSUME_SAFE_MACROS
91 #define CYTHON_ASSUME_SAFE_MACROS 0
92 #undef CYTHON_UNPACK_METHODS
93 #define CYTHON_UNPACK_METHODS 0
94 #undef CYTHON_FAST_THREAD_STATE
95 #define CYTHON_FAST_THREAD_STATE 0
96 #undef CYTHON_FAST_PYCALL
97 #define CYTHON_FAST_PYCALL 0
98 #undef CYTHON_PEP489_MULTI_PHASE_INIT
99 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
100 #undef CYTHON_USE_TP_FINALIZE
101 #define CYTHON_USE_TP_FINALIZE 0
102 #undef CYTHON_USE_DICT_VERSIONS
103 #define CYTHON_USE_DICT_VERSIONS 0
104 #undef CYTHON_USE_EXC_INFO_STACK
105 #define CYTHON_USE_EXC_INFO_STACK 0
106 #elif defined(PYSTON_VERSION)
107 #define CYTHON_COMPILING_IN_PYPY 0
108 #define CYTHON_COMPILING_IN_PYSTON 1
109 #define CYTHON_COMPILING_IN_CPYTHON 0
110 #ifndef CYTHON_USE_TYPE_SLOTS
111 #define CYTHON_USE_TYPE_SLOTS 1
112 #endif
113 #undef CYTHON_USE_PYTYPE_LOOKUP
114 #define CYTHON_USE_PYTYPE_LOOKUP 0
115 #undef CYTHON_USE_ASYNC_SLOTS
116 #define CYTHON_USE_ASYNC_SLOTS 0
117 #undef CYTHON_USE_PYLIST_INTERNALS
118 #define CYTHON_USE_PYLIST_INTERNALS 0
119 #ifndef CYTHON_USE_UNICODE_INTERNALS
120 #define CYTHON_USE_UNICODE_INTERNALS 1
121 #endif
122 #undef CYTHON_USE_UNICODE_WRITER
123 #define CYTHON_USE_UNICODE_WRITER 0
124 #undef CYTHON_USE_PYLONG_INTERNALS
125 #define CYTHON_USE_PYLONG_INTERNALS 0
126 #ifndef CYTHON_AVOID_BORROWED_REFS
127 #define CYTHON_AVOID_BORROWED_REFS 0
128 #endif
129 #ifndef CYTHON_ASSUME_SAFE_MACROS
130 #define CYTHON_ASSUME_SAFE_MACROS 1
131 #endif
132 #ifndef CYTHON_UNPACK_METHODS
133 #define CYTHON_UNPACK_METHODS 1
134 #endif
135 #undef CYTHON_FAST_THREAD_STATE
136 #define CYTHON_FAST_THREAD_STATE 0
137 #undef CYTHON_FAST_PYCALL
138 #define CYTHON_FAST_PYCALL 0
139 #undef CYTHON_PEP489_MULTI_PHASE_INIT
140 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
141 #undef CYTHON_USE_TP_FINALIZE
142 #define CYTHON_USE_TP_FINALIZE 0
143 #undef CYTHON_USE_DICT_VERSIONS
144 #define CYTHON_USE_DICT_VERSIONS 0
145 #undef CYTHON_USE_EXC_INFO_STACK
146 #define CYTHON_USE_EXC_INFO_STACK 0
147 #else
148 #define CYTHON_COMPILING_IN_PYPY 0
149 #define CYTHON_COMPILING_IN_PYSTON 0
150 #define CYTHON_COMPILING_IN_CPYTHON 1
151 #ifndef CYTHON_USE_TYPE_SLOTS
152 #define CYTHON_USE_TYPE_SLOTS 1
153 #endif
154 #if PY_VERSION_HEX < 0x02070000
155 #undef CYTHON_USE_PYTYPE_LOOKUP
156 #define CYTHON_USE_PYTYPE_LOOKUP 0
157 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
158 #define CYTHON_USE_PYTYPE_LOOKUP 1
159 #endif
160 #if PY_MAJOR_VERSION < 3
161 #undef CYTHON_USE_ASYNC_SLOTS
162 #define CYTHON_USE_ASYNC_SLOTS 0
163 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
164 #define CYTHON_USE_ASYNC_SLOTS 1
165 #endif
166 #if PY_VERSION_HEX < 0x02070000
167 #undef CYTHON_USE_PYLONG_INTERNALS
168 #define CYTHON_USE_PYLONG_INTERNALS 0
169 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
170 #define CYTHON_USE_PYLONG_INTERNALS 1
171 #endif
172 #ifndef CYTHON_USE_PYLIST_INTERNALS
173 #define CYTHON_USE_PYLIST_INTERNALS 1
174 #endif
175 #ifndef CYTHON_USE_UNICODE_INTERNALS
176 #define CYTHON_USE_UNICODE_INTERNALS 1
177 #endif
178 #if PY_VERSION_HEX < 0x030300F0
179 #undef CYTHON_USE_UNICODE_WRITER
180 #define CYTHON_USE_UNICODE_WRITER 0
181 #elif !defined(CYTHON_USE_UNICODE_WRITER)
182 #define CYTHON_USE_UNICODE_WRITER 1
183 #endif
184 #ifndef CYTHON_AVOID_BORROWED_REFS
185 #define CYTHON_AVOID_BORROWED_REFS 0
186 #endif
187 #ifndef CYTHON_ASSUME_SAFE_MACROS
188 #define CYTHON_ASSUME_SAFE_MACROS 1
189 #endif
190 #ifndef CYTHON_UNPACK_METHODS
191 #define CYTHON_UNPACK_METHODS 1
192 #endif
193 #ifndef CYTHON_FAST_THREAD_STATE
194 #define CYTHON_FAST_THREAD_STATE 1
195 #endif
196 #ifndef CYTHON_FAST_PYCALL
197 #define CYTHON_FAST_PYCALL 1
198 #endif
199 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
200 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
201 #endif
202 #ifndef CYTHON_USE_TP_FINALIZE
203 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
204 #endif
205 #ifndef CYTHON_USE_DICT_VERSIONS
206 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
207 #endif
208 #ifndef CYTHON_USE_EXC_INFO_STACK
209 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
210 #endif
211 #endif
212 #if !defined(CYTHON_FAST_PYCCALL)
213 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
214 #endif
215 #if CYTHON_USE_PYLONG_INTERNALS
216 #include "longintrepr.h"
217 #undef SHIFT
218 #undef BASE
219 #undef MASK
220 #ifdef SIZEOF_VOID_P
221 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
222 #endif
223 #endif
224 #ifndef __has_attribute
225 #define __has_attribute(x) 0
226 #endif
227 #ifndef __has_cpp_attribute
228 #define __has_cpp_attribute(x) 0
229 #endif
230 #ifndef CYTHON_RESTRICT
231 #if defined(__GNUC__)
232 #define CYTHON_RESTRICT __restrict__
233 #elif defined(_MSC_VER) && _MSC_VER >= 1400
234 #define CYTHON_RESTRICT __restrict
235 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
236 #define CYTHON_RESTRICT restrict
237 #else
238 #define CYTHON_RESTRICT
239 #endif
240 #endif
241 #ifndef CYTHON_UNUSED
242 # if defined(__GNUC__)
243 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
244 # define CYTHON_UNUSED __attribute__ ((__unused__))
245 # else
246 # define CYTHON_UNUSED
247 # endif
248 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
249 # define CYTHON_UNUSED __attribute__ ((__unused__))
250 # else
251 # define CYTHON_UNUSED
252 # endif
253 #endif
254 #ifndef CYTHON_MAYBE_UNUSED_VAR
255 # if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)256 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
257 # else
258 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
259 # endif
260 #endif
261 #ifndef CYTHON_NCP_UNUSED
262 # if CYTHON_COMPILING_IN_CPYTHON
263 # define CYTHON_NCP_UNUSED
264 # else
265 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
266 # endif
267 #endif
268 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
269 #ifdef _MSC_VER
270 #ifndef _MSC_STDINT_H_
271 #if _MSC_VER < 1300
272 typedef unsigned char uint8_t;
273 typedef unsigned int uint32_t;
274 #else
275 typedef unsigned __int8 uint8_t;
276 typedef unsigned __int32 uint32_t;
277 #endif
278 #endif
279 #else
280 #include <stdint.h>
281 #endif
282 #ifndef CYTHON_FALLTHROUGH
283 #if defined(__cplusplus) && __cplusplus >= 201103L
284 #if __has_cpp_attribute(fallthrough)
285 #define CYTHON_FALLTHROUGH [[fallthrough]]
286 #elif __has_cpp_attribute(clang::fallthrough)
287 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
288 #elif __has_cpp_attribute(gnu::fallthrough)
289 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
290 #endif
291 #endif
292 #ifndef CYTHON_FALLTHROUGH
293 #if __has_attribute(fallthrough)
294 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
295 #else
296 #define CYTHON_FALLTHROUGH
297 #endif
298 #endif
299 #if defined(__clang__ ) && defined(__apple_build_version__)
300 #if __apple_build_version__ < 7000000
301 #undef CYTHON_FALLTHROUGH
302 #define CYTHON_FALLTHROUGH
303 #endif
304 #endif
305 #endif
306
307 #ifndef CYTHON_INLINE
308 #if defined(__clang__)
309 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
310 #elif defined(__GNUC__)
311 #define CYTHON_INLINE __inline__
312 #elif defined(_MSC_VER)
313 #define CYTHON_INLINE __inline
314 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
315 #define CYTHON_INLINE inline
316 #else
317 #define CYTHON_INLINE
318 #endif
319 #endif
320
321 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
322 #define Py_OptimizeFlag 0
323 #endif
324 #define __PYX_BUILD_PY_SSIZE_T "n"
325 #define CYTHON_FORMAT_SSIZE_T "z"
326 #if PY_MAJOR_VERSION < 3
327 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
328 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
329 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
330 #define __Pyx_DefaultClassType PyClass_Type
331 #else
332 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
333 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
334 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
335 PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
336 #else
337 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
338 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
339 #endif
340 #define __Pyx_DefaultClassType PyType_Type
341 #endif
342 #ifndef Py_TPFLAGS_CHECKTYPES
343 #define Py_TPFLAGS_CHECKTYPES 0
344 #endif
345 #ifndef Py_TPFLAGS_HAVE_INDEX
346 #define Py_TPFLAGS_HAVE_INDEX 0
347 #endif
348 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
349 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
350 #endif
351 #ifndef Py_TPFLAGS_HAVE_FINALIZE
352 #define Py_TPFLAGS_HAVE_FINALIZE 0
353 #endif
354 #ifndef METH_STACKLESS
355 #define METH_STACKLESS 0
356 #endif
357 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
358 #ifndef METH_FASTCALL
359 #define METH_FASTCALL 0x80
360 #endif
361 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
362 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
363 Py_ssize_t nargs, PyObject *kwnames);
364 #else
365 #define __Pyx_PyCFunctionFast _PyCFunctionFast
366 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
367 #endif
368 #if CYTHON_FAST_PYCCALL
369 #define __Pyx_PyFastCFunction_Check(func)\
370 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
371 #else
372 #define __Pyx_PyFastCFunction_Check(func) 0
373 #endif
374 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
375 #define PyObject_Malloc(s) PyMem_Malloc(s)
376 #define PyObject_Free(p) PyMem_Free(p)
377 #define PyObject_Realloc(p) PyMem_Realloc(p)
378 #endif
379 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
380 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
381 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
382 #define PyMem_RawFree(p) PyMem_Free(p)
383 #endif
384 #if CYTHON_COMPILING_IN_PYSTON
385 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
386 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
387 #else
388 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
389 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
390 #endif
391 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
392 #define __Pyx_PyThreadState_Current PyThreadState_GET()
393 #elif PY_VERSION_HEX >= 0x03060000
394 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
395 #elif PY_VERSION_HEX >= 0x03000000
396 #define __Pyx_PyThreadState_Current PyThreadState_GET()
397 #else
398 #define __Pyx_PyThreadState_Current _PyThreadState_Current
399 #endif
400 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
401 #include "pythread.h"
402 #define Py_tss_NEEDS_INIT 0
403 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)404 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
405 *key = PyThread_create_key();
406 return 0;
407 }
PyThread_tss_alloc(void)408 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
409 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
410 *key = Py_tss_NEEDS_INIT;
411 return key;
412 }
PyThread_tss_free(Py_tss_t * key)413 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
414 PyObject_Free(key);
415 }
PyThread_tss_is_created(Py_tss_t * key)416 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
417 return *key != Py_tss_NEEDS_INIT;
418 }
PyThread_tss_delete(Py_tss_t * key)419 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
420 PyThread_delete_key(*key);
421 *key = Py_tss_NEEDS_INIT;
422 }
PyThread_tss_set(Py_tss_t * key,void * value)423 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
424 return PyThread_set_key_value(*key, value);
425 }
PyThread_tss_get(Py_tss_t * key)426 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
427 return PyThread_get_key_value(*key);
428 }
429 #endif
430 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
431 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
432 #else
433 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
434 #endif
435 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
436 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
437 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
438 #else
439 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
440 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
441 #endif
442 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
443 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
444 #else
445 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
446 #endif
447 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
448 #define CYTHON_PEP393_ENABLED 1
449 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
450 0 : _PyUnicode_Ready((PyObject *)(op)))
451 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
452 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
453 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
454 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
455 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
456 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
457 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
458 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
459 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
460 #else
461 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
462 #endif
463 #else
464 #define CYTHON_PEP393_ENABLED 0
465 #define PyUnicode_1BYTE_KIND 1
466 #define PyUnicode_2BYTE_KIND 2
467 #define PyUnicode_4BYTE_KIND 4
468 #define __Pyx_PyUnicode_READY(op) (0)
469 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
470 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
471 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
472 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
473 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
474 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
475 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
476 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
477 #endif
478 #if CYTHON_COMPILING_IN_PYPY
479 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
480 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
481 #else
482 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
483 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
484 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
485 #endif
486 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
487 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
488 #endif
489 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
490 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
491 #endif
492 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
493 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
494 #endif
495 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
496 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
497 #if PY_MAJOR_VERSION >= 3
498 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
499 #else
500 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
501 #endif
502 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
503 #define PyObject_ASCII(o) PyObject_Repr(o)
504 #endif
505 #if PY_MAJOR_VERSION >= 3
506 #define PyBaseString_Type PyUnicode_Type
507 #define PyStringObject PyUnicodeObject
508 #define PyString_Type PyUnicode_Type
509 #define PyString_Check PyUnicode_Check
510 #define PyString_CheckExact PyUnicode_CheckExact
511 #ifndef PyObject_Unicode
512 #define PyObject_Unicode PyObject_Str
513 #endif
514 #endif
515 #if PY_MAJOR_VERSION >= 3
516 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
517 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
518 #else
519 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
520 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
521 #endif
522 #ifndef PySet_CheckExact
523 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
524 #endif
525 #if PY_VERSION_HEX >= 0x030900A4
526 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
527 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
528 #else
529 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
530 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
531 #endif
532 #if CYTHON_ASSUME_SAFE_MACROS
533 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
534 #else
535 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
536 #endif
537 #if PY_MAJOR_VERSION >= 3
538 #define PyIntObject PyLongObject
539 #define PyInt_Type PyLong_Type
540 #define PyInt_Check(op) PyLong_Check(op)
541 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
542 #define PyInt_FromString PyLong_FromString
543 #define PyInt_FromUnicode PyLong_FromUnicode
544 #define PyInt_FromLong PyLong_FromLong
545 #define PyInt_FromSize_t PyLong_FromSize_t
546 #define PyInt_FromSsize_t PyLong_FromSsize_t
547 #define PyInt_AsLong PyLong_AsLong
548 #define PyInt_AS_LONG PyLong_AS_LONG
549 #define PyInt_AsSsize_t PyLong_AsSsize_t
550 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
551 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
552 #define PyNumber_Int PyNumber_Long
553 #endif
554 #if PY_MAJOR_VERSION >= 3
555 #define PyBoolObject PyLongObject
556 #endif
557 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
558 #ifndef PyUnicode_InternFromString
559 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
560 #endif
561 #endif
562 #if PY_VERSION_HEX < 0x030200A4
563 typedef long Py_hash_t;
564 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
565 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
566 #else
567 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
568 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
569 #endif
570 #if PY_MAJOR_VERSION >= 3
571 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
572 #else
573 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
574 #endif
575 #if CYTHON_USE_ASYNC_SLOTS
576 #if PY_VERSION_HEX >= 0x030500B1
577 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
578 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
579 #else
580 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
581 #endif
582 #else
583 #define __Pyx_PyType_AsAsync(obj) NULL
584 #endif
585 #ifndef __Pyx_PyAsyncMethodsStruct
586 typedef struct {
587 unaryfunc am_await;
588 unaryfunc am_aiter;
589 unaryfunc am_anext;
590 } __Pyx_PyAsyncMethodsStruct;
591 #endif
592
593 #if defined(WIN32) || defined(MS_WINDOWS)
594 #define _USE_MATH_DEFINES
595 #endif
596 #include <math.h>
597 #ifdef NAN
598 #define __PYX_NAN() ((float) NAN)
599 #else
__PYX_NAN()600 static CYTHON_INLINE float __PYX_NAN() {
601 float value;
602 memset(&value, 0xFF, sizeof(value));
603 return value;
604 }
605 #endif
606 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
607 #define __Pyx_truncl trunc
608 #else
609 #define __Pyx_truncl truncl
610 #endif
611
612 #define __PYX_MARK_ERR_POS(f_index, lineno) \
613 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
614 #define __PYX_ERR(f_index, lineno, Ln_error) \
615 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
616
617 #ifndef __PYX_EXTERN_C
618 #ifdef __cplusplus
619 #define __PYX_EXTERN_C extern "C"
620 #else
621 #define __PYX_EXTERN_C extern
622 #endif
623 #endif
624
625 #define __PYX_HAVE__gensim__models__fasttext_inner
626 #define __PYX_HAVE_API__gensim__models__fasttext_inner
627 /* Early includes */
628 #include <string.h>
629 #include <stdio.h>
630 #include "numpy/arrayobject.h"
631 #include "numpy/ufuncobject.h"
632
633 /* NumPy API declarations from "numpy/__init__.pxd" */
634
635 #include "voidptr.h"
636 #include <math.h>
637 #ifdef _OPENMP
638 #include <omp.h>
639 #endif /* _OPENMP */
640
641 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
642 #define CYTHON_WITHOUT_ASSERTIONS
643 #endif
644
645 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
646 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
647
648 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
649 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
650 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
651 #define __PYX_DEFAULT_STRING_ENCODING ""
652 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
653 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
654 #define __Pyx_uchar_cast(c) ((unsigned char)c)
655 #define __Pyx_long_cast(x) ((long)x)
656 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
657 (sizeof(type) < sizeof(Py_ssize_t)) ||\
658 (sizeof(type) > sizeof(Py_ssize_t) &&\
659 likely(v < (type)PY_SSIZE_T_MAX ||\
660 v == (type)PY_SSIZE_T_MAX) &&\
661 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
662 v == (type)PY_SSIZE_T_MIN))) ||\
663 (sizeof(type) == sizeof(Py_ssize_t) &&\
664 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
665 v == (type)PY_SSIZE_T_MAX))) )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)666 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
667 return (size_t) i < (size_t) limit;
668 }
669 #if defined (__cplusplus) && __cplusplus >= 201103L
670 #include <cstdlib>
671 #define __Pyx_sst_abs(value) std::abs(value)
672 #elif SIZEOF_INT >= SIZEOF_SIZE_T
673 #define __Pyx_sst_abs(value) abs(value)
674 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
675 #define __Pyx_sst_abs(value) labs(value)
676 #elif defined (_MSC_VER)
677 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
678 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
679 #define __Pyx_sst_abs(value) llabs(value)
680 #elif defined (__GNUC__)
681 #define __Pyx_sst_abs(value) __builtin_llabs(value)
682 #else
683 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
684 #endif
685 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
686 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
687 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
688 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
689 #define __Pyx_PyBytes_FromString PyBytes_FromString
690 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
691 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
692 #if PY_MAJOR_VERSION < 3
693 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
694 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
695 #else
696 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
697 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
698 #endif
699 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
700 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
701 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
702 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
703 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
704 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
705 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
706 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
707 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
708 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
709 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
710 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
711 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
712 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
713 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
714 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)715 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
716 const Py_UNICODE *u_end = u;
717 while (*u_end++) ;
718 return (size_t)(u_end - u - 1);
719 }
720 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
721 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
722 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
723 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
724 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
725 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
726 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
727 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
728 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
729 #define __Pyx_PySequence_Tuple(obj)\
730 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
731 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
732 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
733 #if CYTHON_ASSUME_SAFE_MACROS
734 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
735 #else
736 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
737 #endif
738 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
739 #if PY_MAJOR_VERSION >= 3
740 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
741 #else
742 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
743 #endif
744 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
745 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
746 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)747 static int __Pyx_init_sys_getdefaultencoding_params(void) {
748 PyObject* sys;
749 PyObject* default_encoding = NULL;
750 PyObject* ascii_chars_u = NULL;
751 PyObject* ascii_chars_b = NULL;
752 const char* default_encoding_c;
753 sys = PyImport_ImportModule("sys");
754 if (!sys) goto bad;
755 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
756 Py_DECREF(sys);
757 if (!default_encoding) goto bad;
758 default_encoding_c = PyBytes_AsString(default_encoding);
759 if (!default_encoding_c) goto bad;
760 if (strcmp(default_encoding_c, "ascii") == 0) {
761 __Pyx_sys_getdefaultencoding_not_ascii = 0;
762 } else {
763 char ascii_chars[128];
764 int c;
765 for (c = 0; c < 128; c++) {
766 ascii_chars[c] = c;
767 }
768 __Pyx_sys_getdefaultencoding_not_ascii = 1;
769 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
770 if (!ascii_chars_u) goto bad;
771 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
772 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
773 PyErr_Format(
774 PyExc_ValueError,
775 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
776 default_encoding_c);
777 goto bad;
778 }
779 Py_DECREF(ascii_chars_u);
780 Py_DECREF(ascii_chars_b);
781 }
782 Py_DECREF(default_encoding);
783 return 0;
784 bad:
785 Py_XDECREF(default_encoding);
786 Py_XDECREF(ascii_chars_u);
787 Py_XDECREF(ascii_chars_b);
788 return -1;
789 }
790 #endif
791 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
792 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
793 #else
794 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
795 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
796 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)797 static int __Pyx_init_sys_getdefaultencoding_params(void) {
798 PyObject* sys;
799 PyObject* default_encoding = NULL;
800 char* default_encoding_c;
801 sys = PyImport_ImportModule("sys");
802 if (!sys) goto bad;
803 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
804 Py_DECREF(sys);
805 if (!default_encoding) goto bad;
806 default_encoding_c = PyBytes_AsString(default_encoding);
807 if (!default_encoding_c) goto bad;
808 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
809 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
810 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
811 Py_DECREF(default_encoding);
812 return 0;
813 bad:
814 Py_XDECREF(default_encoding);
815 return -1;
816 }
817 #endif
818 #endif
819
820
821 /* Test for GCC > 2.95 */
822 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
823 #define likely(x) __builtin_expect(!!(x), 1)
824 #define unlikely(x) __builtin_expect(!!(x), 0)
825 #else /* !__GNUC__ or GCC < 2.95 */
826 #define likely(x) (x)
827 #define unlikely(x) (x)
828 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)829 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
830
831 static PyObject *__pyx_m = NULL;
832 static PyObject *__pyx_d;
833 static PyObject *__pyx_b;
834 static PyObject *__pyx_cython_runtime = NULL;
835 static PyObject *__pyx_empty_tuple;
836 static PyObject *__pyx_empty_bytes;
837 static PyObject *__pyx_empty_unicode;
838 static int __pyx_lineno;
839 static int __pyx_clineno = 0;
840 static const char * __pyx_cfilenm= __FILE__;
841 static const char *__pyx_filename;
842
843 /* Header.proto */
844 #if !defined(CYTHON_CCOMPLEX)
845 #if defined(__cplusplus)
846 #define CYTHON_CCOMPLEX 1
847 #elif defined(_Complex_I)
848 #define CYTHON_CCOMPLEX 1
849 #else
850 #define CYTHON_CCOMPLEX 0
851 #endif
852 #endif
853 #if CYTHON_CCOMPLEX
854 #ifdef __cplusplus
855 #include <complex>
856 #else
857 #include <complex.h>
858 #endif
859 #endif
860 #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
861 #undef _Complex_I
862 #define _Complex_I 1.0fj
863 #endif
864
865
866 static const char *__pyx_f[] = {
867 "gensim/models/fasttext_inner.pyx",
868 "__init__.pxd",
869 "type.pxd",
870 };
871 /* NoFastGil.proto */
872 #define __Pyx_PyGILState_Ensure PyGILState_Ensure
873 #define __Pyx_PyGILState_Release PyGILState_Release
874 #define __Pyx_FastGIL_Remember()
875 #define __Pyx_FastGIL_Forget()
876 #define __Pyx_FastGilFuncInit()
877
878 /* ForceInitThreads.proto */
879 #ifndef __PYX_FORCE_INIT_THREADS
880 #define __PYX_FORCE_INIT_THREADS 0
881 #endif
882
883
884 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":689
885 * # in Cython to enable them only on the right systems.
886 *
887 * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<<
888 * ctypedef npy_int16 int16_t
889 * ctypedef npy_int32 int32_t
890 */
891 typedef npy_int8 __pyx_t_5numpy_int8_t;
892
893 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":690
894 *
895 * ctypedef npy_int8 int8_t
896 * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<<
897 * ctypedef npy_int32 int32_t
898 * ctypedef npy_int64 int64_t
899 */
900 typedef npy_int16 __pyx_t_5numpy_int16_t;
901
902 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":691
903 * ctypedef npy_int8 int8_t
904 * ctypedef npy_int16 int16_t
905 * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<<
906 * ctypedef npy_int64 int64_t
907 * #ctypedef npy_int96 int96_t
908 */
909 typedef npy_int32 __pyx_t_5numpy_int32_t;
910
911 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":692
912 * ctypedef npy_int16 int16_t
913 * ctypedef npy_int32 int32_t
914 * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<<
915 * #ctypedef npy_int96 int96_t
916 * #ctypedef npy_int128 int128_t
917 */
918 typedef npy_int64 __pyx_t_5numpy_int64_t;
919
920 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":696
921 * #ctypedef npy_int128 int128_t
922 *
923 * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<<
924 * ctypedef npy_uint16 uint16_t
925 * ctypedef npy_uint32 uint32_t
926 */
927 typedef npy_uint8 __pyx_t_5numpy_uint8_t;
928
929 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":697
930 *
931 * ctypedef npy_uint8 uint8_t
932 * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<<
933 * ctypedef npy_uint32 uint32_t
934 * ctypedef npy_uint64 uint64_t
935 */
936 typedef npy_uint16 __pyx_t_5numpy_uint16_t;
937
938 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":698
939 * ctypedef npy_uint8 uint8_t
940 * ctypedef npy_uint16 uint16_t
941 * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<<
942 * ctypedef npy_uint64 uint64_t
943 * #ctypedef npy_uint96 uint96_t
944 */
945 typedef npy_uint32 __pyx_t_5numpy_uint32_t;
946
947 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":699
948 * ctypedef npy_uint16 uint16_t
949 * ctypedef npy_uint32 uint32_t
950 * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<<
951 * #ctypedef npy_uint96 uint96_t
952 * #ctypedef npy_uint128 uint128_t
953 */
954 typedef npy_uint64 __pyx_t_5numpy_uint64_t;
955
956 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":703
957 * #ctypedef npy_uint128 uint128_t
958 *
959 * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<<
960 * ctypedef npy_float64 float64_t
961 * #ctypedef npy_float80 float80_t
962 */
963 typedef npy_float32 __pyx_t_5numpy_float32_t;
964
965 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":704
966 *
967 * ctypedef npy_float32 float32_t
968 * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<<
969 * #ctypedef npy_float80 float80_t
970 * #ctypedef npy_float128 float128_t
971 */
972 typedef npy_float64 __pyx_t_5numpy_float64_t;
973
974 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":713
975 * # The int types are mapped a bit surprising --
976 * # numpy.int corresponds to 'l' and numpy.long to 'q'
977 * ctypedef npy_long int_t # <<<<<<<<<<<<<<
978 * ctypedef npy_longlong long_t
979 * ctypedef npy_longlong longlong_t
980 */
981 typedef npy_long __pyx_t_5numpy_int_t;
982
983 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":714
984 * # numpy.int corresponds to 'l' and numpy.long to 'q'
985 * ctypedef npy_long int_t
986 * ctypedef npy_longlong long_t # <<<<<<<<<<<<<<
987 * ctypedef npy_longlong longlong_t
988 *
989 */
990 typedef npy_longlong __pyx_t_5numpy_long_t;
991
992 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":715
993 * ctypedef npy_long int_t
994 * ctypedef npy_longlong long_t
995 * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<<
996 *
997 * ctypedef npy_ulong uint_t
998 */
999 typedef npy_longlong __pyx_t_5numpy_longlong_t;
1000
1001 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":717
1002 * ctypedef npy_longlong longlong_t
1003 *
1004 * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<<
1005 * ctypedef npy_ulonglong ulong_t
1006 * ctypedef npy_ulonglong ulonglong_t
1007 */
1008 typedef npy_ulong __pyx_t_5numpy_uint_t;
1009
1010 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":718
1011 *
1012 * ctypedef npy_ulong uint_t
1013 * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<<
1014 * ctypedef npy_ulonglong ulonglong_t
1015 *
1016 */
1017 typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
1018
1019 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":719
1020 * ctypedef npy_ulong uint_t
1021 * ctypedef npy_ulonglong ulong_t
1022 * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<<
1023 *
1024 * ctypedef npy_intp intp_t
1025 */
1026 typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
1027
1028 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":721
1029 * ctypedef npy_ulonglong ulonglong_t
1030 *
1031 * ctypedef npy_intp intp_t # <<<<<<<<<<<<<<
1032 * ctypedef npy_uintp uintp_t
1033 *
1034 */
1035 typedef npy_intp __pyx_t_5numpy_intp_t;
1036
1037 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":722
1038 *
1039 * ctypedef npy_intp intp_t
1040 * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<<
1041 *
1042 * ctypedef npy_double float_t
1043 */
1044 typedef npy_uintp __pyx_t_5numpy_uintp_t;
1045
1046 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":724
1047 * ctypedef npy_uintp uintp_t
1048 *
1049 * ctypedef npy_double float_t # <<<<<<<<<<<<<<
1050 * ctypedef npy_double double_t
1051 * ctypedef npy_longdouble longdouble_t
1052 */
1053 typedef npy_double __pyx_t_5numpy_float_t;
1054
1055 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":725
1056 *
1057 * ctypedef npy_double float_t
1058 * ctypedef npy_double double_t # <<<<<<<<<<<<<<
1059 * ctypedef npy_longdouble longdouble_t
1060 *
1061 */
1062 typedef npy_double __pyx_t_5numpy_double_t;
1063
1064 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":726
1065 * ctypedef npy_double float_t
1066 * ctypedef npy_double double_t
1067 * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<<
1068 *
1069 * ctypedef npy_cfloat cfloat_t
1070 */
1071 typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
1072
1073 /* "word2vec_inner.pxd":19
1074 * void* PyCObject_AsVoidPtr(object obj)
1075 *
1076 * ctypedef np.float32_t REAL_t # <<<<<<<<<<<<<<
1077 *
1078 * # BLAS routine signatures
1079 */
1080 typedef __pyx_t_5numpy_float32_t __pyx_t_6gensim_6models_14word2vec_inner_REAL_t;
1081 /* Declarations.proto */
1082 #if CYTHON_CCOMPLEX
1083 #ifdef __cplusplus
1084 typedef ::std::complex< float > __pyx_t_float_complex;
1085 #else
1086 typedef float _Complex __pyx_t_float_complex;
1087 #endif
1088 #else
1089 typedef struct { float real, imag; } __pyx_t_float_complex;
1090 #endif
1091 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
1092
1093 /* Declarations.proto */
1094 #if CYTHON_CCOMPLEX
1095 #ifdef __cplusplus
1096 typedef ::std::complex< double > __pyx_t_double_complex;
1097 #else
1098 typedef double _Complex __pyx_t_double_complex;
1099 #endif
1100 #else
1101 typedef struct { double real, imag; } __pyx_t_double_complex;
1102 #endif
1103 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
1104
1105
1106 /*--- Type declarations ---*/
1107
1108 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":728
1109 * ctypedef npy_longdouble longdouble_t
1110 *
1111 * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<<
1112 * ctypedef npy_cdouble cdouble_t
1113 * ctypedef npy_clongdouble clongdouble_t
1114 */
1115 typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
1116
1117 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":729
1118 *
1119 * ctypedef npy_cfloat cfloat_t
1120 * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<<
1121 * ctypedef npy_clongdouble clongdouble_t
1122 *
1123 */
1124 typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
1125
1126 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":730
1127 * ctypedef npy_cfloat cfloat_t
1128 * ctypedef npy_cdouble cdouble_t
1129 * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<<
1130 *
1131 * ctypedef npy_cdouble complex_t
1132 */
1133 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
1134
1135 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":732
1136 * ctypedef npy_clongdouble clongdouble_t
1137 *
1138 * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<<
1139 *
1140 * cdef inline object PyArray_MultiIterNew1(a):
1141 */
1142 typedef npy_cdouble __pyx_t_5numpy_complex_t;
1143 struct __pyx_t_6gensim_6models_14word2vec_inner_Word2VecConfig;
1144 struct __pyx_opt_args_6gensim_6models_14word2vec_inner_init_w2v_config;
1145
1146 /* "word2vec_inner.pxd":22
1147 *
1148 * # BLAS routine signatures
1149 * ctypedef void (*scopy_ptr) (const int *N, const float *X, const int *incX, float *Y, const int *incY) nogil # <<<<<<<<<<<<<<
1150 * ctypedef void (*saxpy_ptr) (const int *N, const float *alpha, const float *X, const int *incX, float *Y, const int *incY) nogil
1151 * ctypedef float (*sdot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil
1152 */
1153 typedef void (*__pyx_t_6gensim_6models_14word2vec_inner_scopy_ptr)(int const *, float const *, int const *, float *, int const *);
1154
1155 /* "word2vec_inner.pxd":23
1156 * # BLAS routine signatures
1157 * ctypedef void (*scopy_ptr) (const int *N, const float *X, const int *incX, float *Y, const int *incY) nogil
1158 * ctypedef void (*saxpy_ptr) (const int *N, const float *alpha, const float *X, const int *incX, float *Y, const int *incY) nogil # <<<<<<<<<<<<<<
1159 * ctypedef float (*sdot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil
1160 * ctypedef double (*dsdot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil
1161 */
1162 typedef void (*__pyx_t_6gensim_6models_14word2vec_inner_saxpy_ptr)(int const *, float const *, float const *, int const *, float *, int const *);
1163
1164 /* "word2vec_inner.pxd":24
1165 * ctypedef void (*scopy_ptr) (const int *N, const float *X, const int *incX, float *Y, const int *incY) nogil
1166 * ctypedef void (*saxpy_ptr) (const int *N, const float *alpha, const float *X, const int *incX, float *Y, const int *incY) nogil
1167 * ctypedef float (*sdot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil # <<<<<<<<<<<<<<
1168 * ctypedef double (*dsdot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil
1169 * ctypedef double (*snrm2_ptr) (const int *N, const float *X, const int *incX) nogil
1170 */
1171 typedef float (*__pyx_t_6gensim_6models_14word2vec_inner_sdot_ptr)(int const *, float const *, int const *, float const *, int const *);
1172
1173 /* "word2vec_inner.pxd":25
1174 * ctypedef void (*saxpy_ptr) (const int *N, const float *alpha, const float *X, const int *incX, float *Y, const int *incY) nogil
1175 * ctypedef float (*sdot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil
1176 * ctypedef double (*dsdot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil # <<<<<<<<<<<<<<
1177 * ctypedef double (*snrm2_ptr) (const int *N, const float *X, const int *incX) nogil
1178 * ctypedef void (*sscal_ptr) (const int *N, const float *alpha, const float *X, const int *incX) nogil
1179 */
1180 typedef double (*__pyx_t_6gensim_6models_14word2vec_inner_dsdot_ptr)(int const *, float const *, int const *, float const *, int const *);
1181
1182 /* "word2vec_inner.pxd":26
1183 * ctypedef float (*sdot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil
1184 * ctypedef double (*dsdot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil
1185 * ctypedef double (*snrm2_ptr) (const int *N, const float *X, const int *incX) nogil # <<<<<<<<<<<<<<
1186 * ctypedef void (*sscal_ptr) (const int *N, const float *alpha, const float *X, const int *incX) nogil
1187 *
1188 */
1189 typedef double (*__pyx_t_6gensim_6models_14word2vec_inner_snrm2_ptr)(int const *, float const *, int const *);
1190
1191 /* "word2vec_inner.pxd":27
1192 * ctypedef double (*dsdot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil
1193 * ctypedef double (*snrm2_ptr) (const int *N, const float *X, const int *incX) nogil
1194 * ctypedef void (*sscal_ptr) (const int *N, const float *alpha, const float *X, const int *incX) nogil # <<<<<<<<<<<<<<
1195 *
1196 * cdef scopy_ptr scopy
1197 */
1198 typedef void (*__pyx_t_6gensim_6models_14word2vec_inner_sscal_ptr)(int const *, float const *, float const *, int const *);
1199
1200 /* "word2vec_inner.pxd":44
1201 *
1202 * # function implementations swapped based on BLAS detected in word2vec_inner.pyx init()
1203 * ctypedef REAL_t (*our_dot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil # <<<<<<<<<<<<<<
1204 * ctypedef void (*our_saxpy_ptr) (const int *N, const float *alpha, const float *X, const int *incX, float *Y, const int *incY) nogil
1205 *
1206 */
1207 typedef __pyx_t_6gensim_6models_14word2vec_inner_REAL_t (*__pyx_t_6gensim_6models_14word2vec_inner_our_dot_ptr)(int const *, float const *, int const *, float const *, int const *);
1208
1209 /* "word2vec_inner.pxd":45
1210 * # function implementations swapped based on BLAS detected in word2vec_inner.pyx init()
1211 * ctypedef REAL_t (*our_dot_ptr) (const int *N, const float *X, const int *incX, const float *Y, const int *incY) nogil
1212 * ctypedef void (*our_saxpy_ptr) (const int *N, const float *alpha, const float *X, const int *incX, float *Y, const int *incY) nogil # <<<<<<<<<<<<<<
1213 *
1214 * cdef our_dot_ptr our_dot
1215 */
1216 typedef void (*__pyx_t_6gensim_6models_14word2vec_inner_our_saxpy_ptr)(int const *, float const *, float const *, int const *, float *, int const *);
1217
1218 /* "word2vec_inner.pxd":51
1219 *
1220 *
1221 * cdef struct Word2VecConfig: # <<<<<<<<<<<<<<
1222 * int hs, negative, sample, compute_loss, size, window, cbow_mean, workers
1223 * REAL_t running_training_loss, alpha
1224 */
1225 struct __pyx_t_6gensim_6models_14word2vec_inner_Word2VecConfig {
1226 int hs;
1227 int negative;
1228 int sample;
1229 int compute_loss;
1230 int size;
1231 int window;
1232 int cbow_mean;
1233 int workers;
1234 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t running_training_loss;
1235 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t alpha;
1236 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *syn0;
1237 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *words_lockf;
1238 __pyx_t_5numpy_uint32_t words_lockf_len;
1239 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *work;
1240 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *neu1;
1241 int codelens[0x2710];
1242 __pyx_t_5numpy_uint32_t indexes[0x2710];
1243 __pyx_t_5numpy_uint32_t reduced_windows[0x2710];
1244 int sentence_idx[(0x2710 + 1)];
1245 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *syn1;
1246 __pyx_t_5numpy_uint32_t *points[0x2710];
1247 __pyx_t_5numpy_uint8_t *codes[0x2710];
1248 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *syn1neg;
1249 __pyx_t_5numpy_uint32_t *cum_table;
1250 unsigned PY_LONG_LONG cum_table_len;
1251 unsigned PY_LONG_LONG next_random;
1252 };
1253
1254 /* "word2vec_inner.pxd":126
1255 *
1256 *
1257 * cdef init_w2v_config(Word2VecConfig *c, model, alpha, compute_loss, _work, _neu1=*) # <<<<<<<<<<<<<<
1258 */
1259 struct __pyx_opt_args_6gensim_6models_14word2vec_inner_init_w2v_config {
1260 int __pyx_n;
1261 PyObject *_neu1;
1262 };
1263 struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig;
1264
1265 /* "gensim/models/fasttext_inner.pxd":22
1266 *
1267 *
1268 * cdef struct FastTextConfig: # <<<<<<<<<<<<<<
1269 * #
1270 * # Contains model parameters and indices required for training.
1271 */
1272 struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig {
1273 int sg;
1274 int hs;
1275 int negative;
1276 int sample;
1277 int size;
1278 int window;
1279 int cbow_mean;
1280 int workers;
1281 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t alpha;
1282 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *syn0_vocab;
1283 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *syn0_ngrams;
1284 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *vocab_lockf;
1285 __pyx_t_5numpy_uint32_t vocab_lockf_len;
1286 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *ngrams_lockf;
1287 __pyx_t_5numpy_uint32_t ngrams_lockf_len;
1288 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *work;
1289 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *neu1;
1290 __pyx_t_5numpy_uint32_t indexes[0x2710];
1291 __pyx_t_5numpy_uint32_t reduced_windows[0x2710];
1292 int sentence_idx[(0x2710 + 1)];
1293 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *syn1;
1294 __pyx_t_5numpy_uint32_t *points[0x2710];
1295 __pyx_t_5numpy_uint8_t *codes[0x2710];
1296 int codelens[0x2710];
1297 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t *syn1neg;
1298 __pyx_t_5numpy_uint32_t *cum_table;
1299 unsigned PY_LONG_LONG cum_table_len;
1300 unsigned PY_LONG_LONG next_random;
1301 int subwords_idx_len[0x2710];
1302 __pyx_t_5numpy_uint32_t *subwords_idx[0x2710];
1303 };
1304
1305 /* --- Runtime support code (head) --- */
1306 /* Refnanny.proto */
1307 #ifndef CYTHON_REFNANNY
1308 #define CYTHON_REFNANNY 0
1309 #endif
1310 #if CYTHON_REFNANNY
1311 typedef struct {
1312 void (*INCREF)(void*, PyObject*, int);
1313 void (*DECREF)(void*, PyObject*, int);
1314 void (*GOTREF)(void*, PyObject*, int);
1315 void (*GIVEREF)(void*, PyObject*, int);
1316 void* (*SetupContext)(const char*, int, const char*);
1317 void (*FinishContext)(void**);
1318 } __Pyx_RefNannyAPIStruct;
1319 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1320 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1321 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1322 #ifdef WITH_THREAD
1323 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1324 if (acquire_gil) {\
1325 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1326 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1327 PyGILState_Release(__pyx_gilstate_save);\
1328 } else {\
1329 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1330 }
1331 #else
1332 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1333 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1334 #endif
1335 #define __Pyx_RefNannyFinishContext()\
1336 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1337 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1338 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1339 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1340 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1341 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1342 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1343 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1344 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1345 #else
1346 #define __Pyx_RefNannyDeclarations
1347 #define __Pyx_RefNannySetupContext(name, acquire_gil)
1348 #define __Pyx_RefNannyFinishContext()
1349 #define __Pyx_INCREF(r) Py_INCREF(r)
1350 #define __Pyx_DECREF(r) Py_DECREF(r)
1351 #define __Pyx_GOTREF(r)
1352 #define __Pyx_GIVEREF(r)
1353 #define __Pyx_XINCREF(r) Py_XINCREF(r)
1354 #define __Pyx_XDECREF(r) Py_XDECREF(r)
1355 #define __Pyx_XGOTREF(r)
1356 #define __Pyx_XGIVEREF(r)
1357 #endif
1358 #define __Pyx_XDECREF_SET(r, v) do {\
1359 PyObject *tmp = (PyObject *) r;\
1360 r = v; __Pyx_XDECREF(tmp);\
1361 } while (0)
1362 #define __Pyx_DECREF_SET(r, v) do {\
1363 PyObject *tmp = (PyObject *) r;\
1364 r = v; __Pyx_DECREF(tmp);\
1365 } while (0)
1366 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1367 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1368
1369 /* PyObjectGetAttrStr.proto */
1370 #if CYTHON_USE_TYPE_SLOTS
1371 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1372 #else
1373 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1374 #endif
1375
1376 /* GetBuiltinName.proto */
1377 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1378
1379 /* PyIntCompare.proto */
1380 static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
1381
1382 /* ExtTypeTest.proto */
1383 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1384
1385 /* PyObjectCall.proto */
1386 #if CYTHON_COMPILING_IN_CPYTHON
1387 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1388 #else
1389 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1390 #endif
1391
1392 /* PyThreadStateGet.proto */
1393 #if CYTHON_FAST_THREAD_STATE
1394 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1395 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1396 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1397 #else
1398 #define __Pyx_PyThreadState_declare
1399 #define __Pyx_PyThreadState_assign
1400 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1401 #endif
1402
1403 /* PyErrFetchRestore.proto */
1404 #if CYTHON_FAST_THREAD_STATE
1405 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1406 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1407 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1408 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1409 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1410 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1411 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1412 #if CYTHON_COMPILING_IN_CPYTHON
1413 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1414 #else
1415 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1416 #endif
1417 #else
1418 #define __Pyx_PyErr_Clear() PyErr_Clear()
1419 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1420 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1421 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1422 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1423 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1424 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1425 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1426 #endif
1427
1428 /* WriteUnraisableException.proto */
1429 static void __Pyx_WriteUnraisable(const char *name, int clineno,
1430 int lineno, const char *filename,
1431 int full_traceback, int nogil);
1432
1433 /* DictGetItem.proto */
1434 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
1435 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
1436 #define __Pyx_PyObject_Dict_GetItem(obj, name)\
1437 (likely(PyDict_CheckExact(obj)) ?\
1438 __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
1439 #else
1440 #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
1441 #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
1442 #endif
1443
1444 /* PyFunctionFastCall.proto */
1445 #if CYTHON_FAST_PYCALL
1446 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1447 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1448 #if 1 || PY_VERSION_HEX < 0x030600B1
1449 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1450 #else
1451 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1452 #endif
1453 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1454 (sizeof(char [1 - 2*!(cond)]) - 1)
1455 #ifndef Py_MEMBER_SIZE
1456 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1457 #endif
1458 static size_t __pyx_pyframe_localsplus_offset = 0;
1459 #include "frameobject.h"
1460 #define __Pxy_PyFrame_Initialize_Offsets()\
1461 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1462 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1463 #define __Pyx_PyFrame_GetLocalsplus(frame)\
1464 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1465 #endif
1466
1467 /* PyCFunctionFastCall.proto */
1468 #if CYTHON_FAST_PYCCALL
1469 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1470 #else
1471 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
1472 #endif
1473
1474 /* GetItemInt.proto */
1475 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1476 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1477 __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1478 (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1479 __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1480 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1481 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1482 __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1483 (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1484 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1485 int wraparound, int boundscheck);
1486 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1487 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1488 __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1489 (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1490 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1491 int wraparound, int boundscheck);
1492 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1493 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1494 int is_list, int wraparound, int boundscheck);
1495
1496 /* ObjectGetItem.proto */
1497 #if CYTHON_USE_TYPE_SLOTS
1498 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
1499 #else
1500 #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
1501 #endif
1502
1503 /* None.proto */
1504 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
1505
1506 /* RaiseArgTupleInvalid.proto */
1507 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1508 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1509
1510 /* RaiseDoubleKeywords.proto */
1511 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1512
1513 /* ParseKeywords.proto */
1514 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1515 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1516 const char* function_name);
1517
1518 /* RaiseTooManyValuesToUnpack.proto */
1519 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1520
1521 /* RaiseNeedMoreValuesToUnpack.proto */
1522 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1523
1524 /* IterFinish.proto */
1525 static CYTHON_INLINE int __Pyx_IterFinish(void);
1526
1527 /* UnpackItemEndCheck.proto */
1528 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
1529
1530 /* PyIntBinop.proto */
1531 #if !CYTHON_COMPILING_IN_PYPY
1532 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1533 #else
1534 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
1535 (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
1536 #endif
1537
1538 /* ArgTypeTest.proto */
1539 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
1540 ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
1541 __Pyx__ArgTypeTest(obj, type, name, exact))
1542 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
1543
1544 /* PyObjectFormatSimple.proto */
1545 #if CYTHON_COMPILING_IN_PYPY
1546 #define __Pyx_PyObject_FormatSimple(s, f) (\
1547 likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
1548 PyObject_Format(s, f))
1549 #elif PY_MAJOR_VERSION < 3
1550 #define __Pyx_PyObject_FormatSimple(s, f) (\
1551 likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
1552 likely(PyString_CheckExact(s)) ? PyUnicode_FromEncodedObject(s, NULL, "strict") :\
1553 PyObject_Format(s, f))
1554 #elif CYTHON_USE_TYPE_SLOTS
1555 #define __Pyx_PyObject_FormatSimple(s, f) (\
1556 likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
1557 likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_str(s) :\
1558 likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_str(s) :\
1559 PyObject_Format(s, f))
1560 #else
1561 #define __Pyx_PyObject_FormatSimple(s, f) (\
1562 likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
1563 PyObject_Format(s, f))
1564 #endif
1565
1566 /* IncludeStringH.proto */
1567 #include <string.h>
1568
1569 /* JoinPyUnicode.proto */
1570 static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
1571 Py_UCS4 max_char);
1572
1573 /* ListAppend.proto */
1574 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)1575 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1576 PyListObject* L = (PyListObject*) list;
1577 Py_ssize_t len = Py_SIZE(list);
1578 if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1579 Py_INCREF(x);
1580 PyList_SET_ITEM(list, len, x);
1581 __Pyx_SET_SIZE(list, len + 1);
1582 return 0;
1583 }
1584 return PyList_Append(list, x);
1585 }
1586 #else
1587 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1588 #endif
1589
1590 /* PyUnicode_Substring.proto */
1591 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
1592 PyObject* text, Py_ssize_t start, Py_ssize_t stop);
1593
1594 /* PyObjectCall2Args.proto */
1595 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1596
1597 /* PyObjectCallMethO.proto */
1598 #if CYTHON_COMPILING_IN_CPYTHON
1599 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1600 #endif
1601
1602 /* PyObjectCallOneArg.proto */
1603 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1604
1605 /* GetTopmostException.proto */
1606 #if CYTHON_USE_EXC_INFO_STACK
1607 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1608 #endif
1609
1610 /* SaveResetException.proto */
1611 #if CYTHON_FAST_THREAD_STATE
1612 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1613 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1614 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1615 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1616 #else
1617 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
1618 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
1619 #endif
1620
1621 /* PyErrExceptionMatches.proto */
1622 #if CYTHON_FAST_THREAD_STATE
1623 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1624 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1625 #else
1626 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1627 #endif
1628
1629 /* GetException.proto */
1630 #if CYTHON_FAST_THREAD_STATE
1631 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
1632 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1633 #else
1634 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1635 #endif
1636
1637 /* RaiseException.proto */
1638 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1639
1640 /* TypeImport.proto */
1641 #ifndef __PYX_HAVE_RT_ImportType_proto
1642 #define __PYX_HAVE_RT_ImportType_proto
1643 enum __Pyx_ImportType_CheckSize {
1644 __Pyx_ImportType_CheckSize_Error = 0,
1645 __Pyx_ImportType_CheckSize_Warn = 1,
1646 __Pyx_ImportType_CheckSize_Ignore = 2
1647 };
1648 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1649 #endif
1650
1651 /* Import.proto */
1652 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1653
1654 /* PyDictVersioning.proto */
1655 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1656 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1657 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1658 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1659 (version_var) = __PYX_GET_DICT_VERSION(dict);\
1660 (cache_var) = (value);
1661 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1662 static PY_UINT64_T __pyx_dict_version = 0;\
1663 static PyObject *__pyx_dict_cached_value = NULL;\
1664 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1665 (VAR) = __pyx_dict_cached_value;\
1666 } else {\
1667 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1668 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1669 }\
1670 }
1671 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1672 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1673 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1674 #else
1675 #define __PYX_GET_DICT_VERSION(dict) (0)
1676 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1677 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1678 #endif
1679
1680 /* GetModuleGlobalName.proto */
1681 #if CYTHON_USE_DICT_VERSIONS
1682 #define __Pyx_GetModuleGlobalName(var, name) {\
1683 static PY_UINT64_T __pyx_dict_version = 0;\
1684 static PyObject *__pyx_dict_cached_value = NULL;\
1685 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1686 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1687 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1688 }
1689 #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
1690 PY_UINT64_T __pyx_dict_version;\
1691 PyObject *__pyx_dict_cached_value;\
1692 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1693 }
1694 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1695 #else
1696 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1697 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1698 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1699 #endif
1700
1701 /* PyObjectCallNoArg.proto */
1702 #if CYTHON_COMPILING_IN_CPYTHON
1703 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1704 #else
1705 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1706 #endif
1707
1708 /* CLineInTraceback.proto */
1709 #ifdef CYTHON_CLINE_IN_TRACEBACK
1710 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1711 #else
1712 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1713 #endif
1714
1715 /* CodeObjectCache.proto */
1716 typedef struct {
1717 PyCodeObject* code_object;
1718 int code_line;
1719 } __Pyx_CodeObjectCacheEntry;
1720 struct __Pyx_CodeObjectCache {
1721 int count;
1722 int max_count;
1723 __Pyx_CodeObjectCacheEntry* entries;
1724 };
1725 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1726 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1727 static PyCodeObject *__pyx_find_code_object(int code_line);
1728 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1729
1730 /* AddTraceback.proto */
1731 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1732 int py_line, const char *filename);
1733
1734 /* CIntToPy.proto */
1735 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_uint32(npy_uint32 value);
1736
1737 /* CIntToPy.proto */
1738 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1739
1740 /* CIntToPy.proto */
1741 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1742
1743 /* CIntToPy.proto */
1744 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
1745
1746 /* RealImag.proto */
1747 #if CYTHON_CCOMPLEX
1748 #ifdef __cplusplus
1749 #define __Pyx_CREAL(z) ((z).real())
1750 #define __Pyx_CIMAG(z) ((z).imag())
1751 #else
1752 #define __Pyx_CREAL(z) (__real__(z))
1753 #define __Pyx_CIMAG(z) (__imag__(z))
1754 #endif
1755 #else
1756 #define __Pyx_CREAL(z) ((z).real)
1757 #define __Pyx_CIMAG(z) ((z).imag)
1758 #endif
1759 #if defined(__cplusplus) && CYTHON_CCOMPLEX\
1760 && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
1761 #define __Pyx_SET_CREAL(z,x) ((z).real(x))
1762 #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
1763 #else
1764 #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
1765 #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
1766 #endif
1767
1768 /* Arithmetic.proto */
1769 #if CYTHON_CCOMPLEX
1770 #define __Pyx_c_eq_float(a, b) ((a)==(b))
1771 #define __Pyx_c_sum_float(a, b) ((a)+(b))
1772 #define __Pyx_c_diff_float(a, b) ((a)-(b))
1773 #define __Pyx_c_prod_float(a, b) ((a)*(b))
1774 #define __Pyx_c_quot_float(a, b) ((a)/(b))
1775 #define __Pyx_c_neg_float(a) (-(a))
1776 #ifdef __cplusplus
1777 #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
1778 #define __Pyx_c_conj_float(z) (::std::conj(z))
1779 #if 1
1780 #define __Pyx_c_abs_float(z) (::std::abs(z))
1781 #define __Pyx_c_pow_float(a, b) (::std::pow(a, b))
1782 #endif
1783 #else
1784 #define __Pyx_c_is_zero_float(z) ((z)==0)
1785 #define __Pyx_c_conj_float(z) (conjf(z))
1786 #if 1
1787 #define __Pyx_c_abs_float(z) (cabsf(z))
1788 #define __Pyx_c_pow_float(a, b) (cpowf(a, b))
1789 #endif
1790 #endif
1791 #else
1792 static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
1793 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
1794 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
1795 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
1796 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
1797 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
1798 static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
1799 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
1800 #if 1
1801 static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
1802 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
1803 #endif
1804 #endif
1805
1806 /* Arithmetic.proto */
1807 #if CYTHON_CCOMPLEX
1808 #define __Pyx_c_eq_double(a, b) ((a)==(b))
1809 #define __Pyx_c_sum_double(a, b) ((a)+(b))
1810 #define __Pyx_c_diff_double(a, b) ((a)-(b))
1811 #define __Pyx_c_prod_double(a, b) ((a)*(b))
1812 #define __Pyx_c_quot_double(a, b) ((a)/(b))
1813 #define __Pyx_c_neg_double(a) (-(a))
1814 #ifdef __cplusplus
1815 #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
1816 #define __Pyx_c_conj_double(z) (::std::conj(z))
1817 #if 1
1818 #define __Pyx_c_abs_double(z) (::std::abs(z))
1819 #define __Pyx_c_pow_double(a, b) (::std::pow(a, b))
1820 #endif
1821 #else
1822 #define __Pyx_c_is_zero_double(z) ((z)==0)
1823 #define __Pyx_c_conj_double(z) (conj(z))
1824 #if 1
1825 #define __Pyx_c_abs_double(z) (cabs(z))
1826 #define __Pyx_c_pow_double(a, b) (cpow(a, b))
1827 #endif
1828 #endif
1829 #else
1830 static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
1831 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
1832 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
1833 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
1834 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
1835 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
1836 static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
1837 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
1838 #if 1
1839 static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
1840 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
1841 #endif
1842 #endif
1843
1844 /* CIntFromPy.proto */
1845 static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *);
1846
1847 /* CIntFromPy.proto */
1848 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1849
1850 /* CIntFromPy.proto */
1851 static CYTHON_INLINE npy_uint32 __Pyx_PyInt_As_npy_uint32(PyObject *);
1852
1853 /* CIntFromPy.proto */
1854 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_As_PY_LONG_LONG(PyObject *);
1855
1856 /* CIntFromPy.proto */
1857 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *);
1858
1859 /* CIntFromPy.proto */
1860 static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
1861
1862 /* CIntFromPy.proto */
1863 static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
1864
1865 /* CIntFromPy.proto */
1866 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1867
1868 /* FastTypeChecks.proto */
1869 #if CYTHON_COMPILING_IN_CPYTHON
1870 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1871 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1872 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1873 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1874 #else
1875 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1876 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1877 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1878 #endif
1879 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1880
1881 /* CheckBinaryVersion.proto */
1882 static int __Pyx_check_binary_version(void);
1883
1884 /* FunctionExport.proto */
1885 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
1886
1887 /* VoidPtrImport.proto */
1888 static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);
1889
1890 /* FunctionImport.proto */
1891 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
1892
1893 /* InitStrings.proto */
1894 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1895
1896
1897 /* Module declarations from 'cpython.buffer' */
1898
1899 /* Module declarations from 'libc.string' */
1900
1901 /* Module declarations from 'libc.stdio' */
1902
1903 /* Module declarations from '__builtin__' */
1904
1905 /* Module declarations from 'cpython.type' */
1906 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1907
1908 /* Module declarations from 'cpython' */
1909
1910 /* Module declarations from 'cpython.object' */
1911
1912 /* Module declarations from 'cpython.ref' */
1913
1914 /* Module declarations from 'cpython.mem' */
1915
1916 /* Module declarations from 'numpy' */
1917
1918 /* Module declarations from 'numpy' */
1919 static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
1920 static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
1921 static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
1922 static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
1923 static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
1924
1925 /* Module declarations from 'gensim.models.word2vec_inner' */
1926 static __pyx_t_6gensim_6models_14word2vec_inner_scopy_ptr *__pyx_vp_6gensim_6models_14word2vec_inner_scopy = 0;
1927 #define __pyx_v_6gensim_6models_14word2vec_inner_scopy (*__pyx_vp_6gensim_6models_14word2vec_inner_scopy)
1928 static __pyx_t_6gensim_6models_14word2vec_inner_saxpy_ptr *__pyx_vp_6gensim_6models_14word2vec_inner_saxpy = 0;
1929 #define __pyx_v_6gensim_6models_14word2vec_inner_saxpy (*__pyx_vp_6gensim_6models_14word2vec_inner_saxpy)
1930 static __pyx_t_6gensim_6models_14word2vec_inner_sdot_ptr *__pyx_vp_6gensim_6models_14word2vec_inner_sdot = 0;
1931 #define __pyx_v_6gensim_6models_14word2vec_inner_sdot (*__pyx_vp_6gensim_6models_14word2vec_inner_sdot)
1932 static __pyx_t_6gensim_6models_14word2vec_inner_dsdot_ptr *__pyx_vp_6gensim_6models_14word2vec_inner_dsdot = 0;
1933 #define __pyx_v_6gensim_6models_14word2vec_inner_dsdot (*__pyx_vp_6gensim_6models_14word2vec_inner_dsdot)
1934 static __pyx_t_6gensim_6models_14word2vec_inner_snrm2_ptr *__pyx_vp_6gensim_6models_14word2vec_inner_snrm2 = 0;
1935 #define __pyx_v_6gensim_6models_14word2vec_inner_snrm2 (*__pyx_vp_6gensim_6models_14word2vec_inner_snrm2)
1936 static __pyx_t_6gensim_6models_14word2vec_inner_sscal_ptr *__pyx_vp_6gensim_6models_14word2vec_inner_sscal = 0;
1937 #define __pyx_v_6gensim_6models_14word2vec_inner_sscal (*__pyx_vp_6gensim_6models_14word2vec_inner_sscal)
1938 static __pyx_t_6gensim_6models_14word2vec_inner_REAL_t (*__pyx_vp_6gensim_6models_14word2vec_inner_EXP_TABLE)[0x3E8] = 0;
1939 #define __pyx_v_6gensim_6models_14word2vec_inner_EXP_TABLE (*__pyx_vp_6gensim_6models_14word2vec_inner_EXP_TABLE)
1940 static __pyx_t_6gensim_6models_14word2vec_inner_our_dot_ptr *__pyx_vp_6gensim_6models_14word2vec_inner_our_dot = 0;
1941 #define __pyx_v_6gensim_6models_14word2vec_inner_our_dot (*__pyx_vp_6gensim_6models_14word2vec_inner_our_dot)
1942 static __pyx_t_6gensim_6models_14word2vec_inner_our_saxpy_ptr *__pyx_vp_6gensim_6models_14word2vec_inner_our_saxpy = 0;
1943 #define __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy (*__pyx_vp_6gensim_6models_14word2vec_inner_our_saxpy)
1944 static unsigned PY_LONG_LONG (*__pyx_f_6gensim_6models_14word2vec_inner_bisect_left)(__pyx_t_5numpy_uint32_t *, unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, unsigned PY_LONG_LONG); /*proto*/
1945 static unsigned PY_LONG_LONG (*__pyx_f_6gensim_6models_14word2vec_inner_random_int32)(unsigned PY_LONG_LONG *); /*proto*/
1946
1947 /* Module declarations from 'cython' */
1948
1949 /* Module declarations from 'libc.math' */
1950
1951 /* Module declarations from 'gensim.models.fasttext_inner' */
1952 static __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_6gensim_6models_14fasttext_inner_EXP_TABLE[0x200];
1953 static __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_6gensim_6models_14fasttext_inner_LOG_TABLE[0x200];
1954 static int __pyx_v_6gensim_6models_14fasttext_inner_ONE;
1955 static __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_6gensim_6models_14fasttext_inner_ONEF;
1956 static unsigned char __pyx_v_6gensim_6models_14fasttext_inner__MB_MASK;
1957 static unsigned char __pyx_v_6gensim_6models_14fasttext_inner__MB_START;
1958 static void __pyx_f_6gensim_6models_14fasttext_inner_init_ft_config(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
1959 static PyObject *__pyx_f_6gensim_6models_14fasttext_inner_populate_ft_config(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, PyObject *, PyObject *, PyObject *); /*proto*/
1960 static void __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_sg_neg(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, int, int); /*proto*/
1961 static void __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_sg_hs(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, int, int); /*proto*/
1962 static void __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_cbow_neg(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, int, int, int); /*proto*/
1963 static void __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_cbow_hs(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, int, int, int); /*proto*/
1964 static void __pyx_f_6gensim_6models_14fasttext_inner_fasttext_train_any(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, int); /*proto*/
1965 static PyObject *__pyx_f_6gensim_6models_14fasttext_inner_ft_hash_bytes(PyObject *, int __pyx_skip_dispatch); /*proto*/
1966 static PyObject *__pyx_f_6gensim_6models_14fasttext_inner_compute_ngrams(PyObject *, unsigned int, unsigned int, int __pyx_skip_dispatch); /*proto*/
1967 static PyObject *__pyx_f_6gensim_6models_14fasttext_inner_compute_ngrams_bytes(PyObject *, unsigned int, unsigned int, int __pyx_skip_dispatch); /*proto*/
1968 #define __Pyx_MODULE_NAME "gensim.models.fasttext_inner"
1969 extern int __pyx_module_is_main_gensim__models__fasttext_inner;
1970 int __pyx_module_is_main_gensim__models__fasttext_inner = 0;
1971
1972 /* Implementation of 'gensim.models.fasttext_inner' */
1973 static PyObject *__pyx_builtin_range;
1974 static PyObject *__pyx_builtin_enumerate;
1975 static PyObject *__pyx_builtin_ImportError;
1976 static const char __pyx_k_c[] = "c";
1977 static const char __pyx_k_i[] = "i";
1978 static const char __pyx_k_s[] = "<%s>";
1979 static const char __pyx_k__2[] = "<";
1980 static const char __pyx_k__3[] = ">";
1981 static const char __pyx_k_hs[] = "hs";
1982 static const char __pyx_k_np[] = "np";
1983 static const char __pyx_k_sg[] = "sg";
1984 static const char __pyx_k_wv[] = "wv";
1985 static const char __pyx_k_get[] = "get";
1986 static const char __pyx_k_code[] = "code";
1987 static const char __pyx_k_init[] = "init";
1988 static const char __pyx_k_main[] = "__main__";
1989 static const char __pyx_k_name[] = "__name__";
1990 static const char __pyx_k_neu1[] = "_neu1";
1991 static const char __pyx_k_syn1[] = "syn1";
1992 static const char __pyx_k_test[] = "__test__";
1993 static const char __pyx_k_word[] = "word";
1994 static const char __pyx_k_work[] = "_work";
1995 static const char __pyx_k_alpha[] = "alpha";
1996 static const char __pyx_k_max_n[] = "max_n";
1997 static const char __pyx_k_min_n[] = "min_n";
1998 static const char __pyx_k_model[] = "model";
1999 static const char __pyx_k_numpy[] = "numpy";
2000 static const char __pyx_k_point[] = "point";
2001 static const char __pyx_k_range[] = "range";
2002 static const char __pyx_k_utf_8[] = "utf-8";
2003 static const char __pyx_k_bucket[] = "bucket";
2004 static const char __pyx_k_encode[] = "encode";
2005 static const char __pyx_k_import[] = "__import__";
2006 static const char __pyx_k_random[] = "random";
2007 static const char __pyx_k_sample[] = "sample";
2008 static const char __pyx_k_window[] = "window";
2009 static const char __pyx_k_randint[] = "randint";
2010 static const char __pyx_k_syn1neg[] = "syn1neg";
2011 static const char __pyx_k_workers[] = "workers";
2012 static const char __pyx_k_expandos[] = "expandos";
2013 static const char __pyx_k_negative[] = "negative";
2014 static const char __pyx_k_cbow_mean[] = "cbow_mean";
2015 static const char __pyx_k_cum_table[] = "cum_table";
2016 static const char __pyx_k_enumerate[] = "enumerate";
2017 static const char __pyx_k_num_words[] = "num_words";
2018 static const char __pyx_k_sentences[] = "sentences";
2019 static const char __pyx_k_sample_int[] = "sample_int";
2020 static const char __pyx_k_ImportError[] = "ImportError";
2021 static const char __pyx_k_vector_size[] = "vector_size";
2022 static const char __pyx_k_buckets_word[] = "buckets_word";
2023 static const char __pyx_k_key_to_index[] = "key_to_index";
2024 static const char __pyx_k_num_sentences[] = "num_sentences";
2025 static const char __pyx_k_vectors_vocab[] = "vectors_vocab";
2026 static const char __pyx_k_vectors_ngrams[] = "vectors_ngrams";
2027 static const char __pyx_k_train_batch_any[] = "train_batch_any";
2028 static const char __pyx_k_MAX_WORDS_IN_BATCH[] = "MAX_WORDS_IN_BATCH";
2029 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
2030 static const char __pyx_k_vectors_vocab_lockf[] = "vectors_vocab_lockf";
2031 static const char __pyx_k_vectors_ngrams_lockf[] = "vectors_ngrams_lockf";
2032 static const char __pyx_k_gensim_models_fasttext_inner[] = "gensim.models.fasttext_inner";
2033 static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
2034 static const char __pyx_k_Optimized_Cython_functions_for_t[] = "Optimized Cython functions for training a :class:`~gensim.models.fasttext.FastText` model.\n\nThe main entry point is :func:`~gensim.models.fasttext_inner.train_batch_any`\nwhich may be called directly from Python code.\n\nNotes\n-----\nThe implementation of the above functions heavily depends on the\nFastTextConfig struct defined in :file:`gensim/models/fasttext_inner.pxd`.\n\nThe gensim.models.word2vec.FAST_VERSION value reports what flavor of BLAS\nwe're currently using:\n\n 0: double\n 1: float\n 2: no BLAS, use Cython loops instead\n\nSee Also\n--------\n`Basic Linear Algebra Subprograms <http://www.netlib.org/blas/>`_\n\n";
2035 static const char __pyx_k_gensim_models_fasttext_inner_pyx[] = "gensim/models/fasttext_inner.pyx";
2036 static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
2037 static PyObject *__pyx_n_s_ImportError;
2038 static PyObject *__pyx_n_s_MAX_WORDS_IN_BATCH;
2039 static PyObject *__pyx_kp_u__2;
2040 static PyObject *__pyx_kp_u__3;
2041 static PyObject *__pyx_n_s_alpha;
2042 static PyObject *__pyx_n_s_bucket;
2043 static PyObject *__pyx_n_s_buckets_word;
2044 static PyObject *__pyx_n_s_c;
2045 static PyObject *__pyx_n_s_cbow_mean;
2046 static PyObject *__pyx_n_s_cline_in_traceback;
2047 static PyObject *__pyx_n_s_code;
2048 static PyObject *__pyx_n_s_cum_table;
2049 static PyObject *__pyx_n_s_encode;
2050 static PyObject *__pyx_n_s_enumerate;
2051 static PyObject *__pyx_n_s_expandos;
2052 static PyObject *__pyx_n_s_gensim_models_fasttext_inner;
2053 static PyObject *__pyx_kp_s_gensim_models_fasttext_inner_pyx;
2054 static PyObject *__pyx_n_s_get;
2055 static PyObject *__pyx_n_s_hs;
2056 static PyObject *__pyx_n_s_i;
2057 static PyObject *__pyx_n_s_import;
2058 static PyObject *__pyx_n_s_init;
2059 static PyObject *__pyx_n_s_key_to_index;
2060 static PyObject *__pyx_n_s_main;
2061 static PyObject *__pyx_n_s_max_n;
2062 static PyObject *__pyx_n_s_min_n;
2063 static PyObject *__pyx_n_s_model;
2064 static PyObject *__pyx_n_s_name;
2065 static PyObject *__pyx_n_s_negative;
2066 static PyObject *__pyx_n_s_neu1;
2067 static PyObject *__pyx_n_s_np;
2068 static PyObject *__pyx_n_s_num_sentences;
2069 static PyObject *__pyx_n_s_num_words;
2070 static PyObject *__pyx_n_s_numpy;
2071 static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to;
2072 static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor;
2073 static PyObject *__pyx_n_s_point;
2074 static PyObject *__pyx_n_s_randint;
2075 static PyObject *__pyx_n_s_random;
2076 static PyObject *__pyx_n_s_range;
2077 static PyObject *__pyx_kp_s_s;
2078 static PyObject *__pyx_n_s_sample;
2079 static PyObject *__pyx_n_s_sample_int;
2080 static PyObject *__pyx_n_s_sentences;
2081 static PyObject *__pyx_n_s_sg;
2082 static PyObject *__pyx_n_s_syn1;
2083 static PyObject *__pyx_n_s_syn1neg;
2084 static PyObject *__pyx_n_s_test;
2085 static PyObject *__pyx_n_s_train_batch_any;
2086 static PyObject *__pyx_kp_s_utf_8;
2087 static PyObject *__pyx_n_s_vector_size;
2088 static PyObject *__pyx_n_s_vectors_ngrams;
2089 static PyObject *__pyx_n_s_vectors_ngrams_lockf;
2090 static PyObject *__pyx_n_s_vectors_vocab;
2091 static PyObject *__pyx_n_s_vectors_vocab_lockf;
2092 static PyObject *__pyx_n_s_window;
2093 static PyObject *__pyx_n_s_word;
2094 static PyObject *__pyx_n_s_work;
2095 static PyObject *__pyx_n_s_workers;
2096 static PyObject *__pyx_n_s_wv;
2097 static PyObject *__pyx_pf_6gensim_6models_14fasttext_inner_train_batch_any(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_model, PyObject *__pyx_v_sentences, PyObject *__pyx_v_alpha, PyObject *__pyx_v__work, PyObject *__pyx_v__neu1); /* proto */
2098 static PyObject *__pyx_pf_6gensim_6models_14fasttext_inner_2ft_hash_bytes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_bytez); /* proto */
2099 static PyObject *__pyx_pf_6gensim_6models_14fasttext_inner_4compute_ngrams(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_word, unsigned int __pyx_v_min_n, unsigned int __pyx_v_max_n); /* proto */
2100 static PyObject *__pyx_pf_6gensim_6models_14fasttext_inner_6compute_ngrams_bytes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_word, unsigned int __pyx_v_min_n, unsigned int __pyx_v_max_n); /* proto */
2101 static PyObject *__pyx_pf_6gensim_6models_14fasttext_inner_8init(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
2102 static PyObject *__pyx_int_0;
2103 static PyObject *__pyx_int_1;
2104 static PyObject *__pyx_int_10000;
2105 static PyObject *__pyx_int_16777216;
2106 static PyObject *__pyx_tuple_;
2107 static PyObject *__pyx_tuple__4;
2108 static PyObject *__pyx_tuple__5;
2109 static PyObject *__pyx_tuple__6;
2110 static PyObject *__pyx_tuple__8;
2111 static PyObject *__pyx_codeobj__7;
2112 static PyObject *__pyx_codeobj__9;
2113 /* Late includes */
2114
2115 /* "gensim/models/fasttext_inner.pyx":74
2116 *
2117 *
2118 * cdef void fasttext_fast_sentence_sg_neg(FastTextConfig *c, int i, int j) nogil: # <<<<<<<<<<<<<<
2119 * """Perform skipgram training with negative sampling.
2120 *
2121 */
2122
__pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_sg_neg(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig * __pyx_v_c,int __pyx_v_i,int __pyx_v_j)2123 static void __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_sg_neg(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *__pyx_v_c, int __pyx_v_i, int __pyx_v_j) {
2124 __pyx_t_5numpy_uint32_t __pyx_v_word_index;
2125 __pyx_t_5numpy_uint32_t __pyx_v_word2_index;
2126 __pyx_t_5numpy_uint32_t *__pyx_v_subwords_index;
2127 __pyx_t_5numpy_uint32_t __pyx_v_subwords_len;
2128 PY_LONG_LONG __pyx_v_row1;
2129 PY_LONG_LONG __pyx_v_row2;
2130 unsigned PY_LONG_LONG __pyx_v_modulo;
2131 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_f;
2132 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_g;
2133 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_label;
2134 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_f_dot;
2135 __pyx_t_5numpy_uint32_t __pyx_v_target_index;
2136 int __pyx_v_d;
2137 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_norm_factor;
2138 int __pyx_t_1;
2139 __pyx_t_5numpy_uint32_t __pyx_t_2;
2140 __pyx_t_5numpy_uint32_t __pyx_t_3;
2141 int __pyx_t_4;
2142 long __pyx_t_5;
2143 long __pyx_t_6;
2144 int __pyx_t_7;
2145
2146 /* "gensim/models/fasttext_inner.pyx":95
2147 *
2148 * cdef:
2149 * np.uint32_t word_index = c.indexes[j] # <<<<<<<<<<<<<<
2150 * np.uint32_t word2_index = c.indexes[i]
2151 * np.uint32_t *subwords_index = c.subwords_idx[i]
2152 */
2153 __pyx_v_word_index = (__pyx_v_c->indexes[__pyx_v_j]);
2154
2155 /* "gensim/models/fasttext_inner.pyx":96
2156 * cdef:
2157 * np.uint32_t word_index = c.indexes[j]
2158 * np.uint32_t word2_index = c.indexes[i] # <<<<<<<<<<<<<<
2159 * np.uint32_t *subwords_index = c.subwords_idx[i]
2160 * np.uint32_t subwords_len = c.subwords_idx_len[i]
2161 */
2162 __pyx_v_word2_index = (__pyx_v_c->indexes[__pyx_v_i]);
2163
2164 /* "gensim/models/fasttext_inner.pyx":97
2165 * np.uint32_t word_index = c.indexes[j]
2166 * np.uint32_t word2_index = c.indexes[i]
2167 * np.uint32_t *subwords_index = c.subwords_idx[i] # <<<<<<<<<<<<<<
2168 * np.uint32_t subwords_len = c.subwords_idx_len[i]
2169 *
2170 */
2171 __pyx_v_subwords_index = (__pyx_v_c->subwords_idx[__pyx_v_i]);
2172
2173 /* "gensim/models/fasttext_inner.pyx":98
2174 * np.uint32_t word2_index = c.indexes[i]
2175 * np.uint32_t *subwords_index = c.subwords_idx[i]
2176 * np.uint32_t subwords_len = c.subwords_idx_len[i] # <<<<<<<<<<<<<<
2177 *
2178 * cdef long long row1 = word2_index * c.size, row2
2179 */
2180 __pyx_v_subwords_len = (__pyx_v_c->subwords_idx_len[__pyx_v_i]);
2181
2182 /* "gensim/models/fasttext_inner.pyx":100
2183 * np.uint32_t subwords_len = c.subwords_idx_len[i]
2184 *
2185 * cdef long long row1 = word2_index * c.size, row2 # <<<<<<<<<<<<<<
2186 * cdef unsigned long long modulo = 281474976710655ULL
2187 * cdef REAL_t f, g, label, f_dot
2188 */
2189 __pyx_v_row1 = (__pyx_v_word2_index * __pyx_v_c->size);
2190
2191 /* "gensim/models/fasttext_inner.pyx":101
2192 *
2193 * cdef long long row1 = word2_index * c.size, row2
2194 * cdef unsigned long long modulo = 281474976710655ULL # <<<<<<<<<<<<<<
2195 * cdef REAL_t f, g, label, f_dot
2196 * cdef np.uint32_t target_index
2197 */
2198 __pyx_v_modulo = 281474976710655ULL;
2199
2200 /* "gensim/models/fasttext_inner.pyx":106
2201 * cdef int d
2202 *
2203 * memset(c.work, 0, c.size * cython.sizeof(REAL_t)) # <<<<<<<<<<<<<<
2204 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t))
2205 *
2206 */
2207 (void)(memset(__pyx_v_c->work, 0, (__pyx_v_c->size * (sizeof(__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)))));
2208
2209 /* "gensim/models/fasttext_inner.pyx":107
2210 *
2211 * memset(c.work, 0, c.size * cython.sizeof(REAL_t))
2212 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t)) # <<<<<<<<<<<<<<
2213 *
2214 * scopy(&c.size, &c.syn0_vocab[row1], &ONE, c.neu1, &ONE)
2215 */
2216 (void)(memset(__pyx_v_c->neu1, 0, (__pyx_v_c->size * (sizeof(__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)))));
2217
2218 /* "gensim/models/fasttext_inner.pyx":109
2219 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t))
2220 *
2221 * scopy(&c.size, &c.syn0_vocab[row1], &ONE, c.neu1, &ONE) # <<<<<<<<<<<<<<
2222 *
2223 * #
2224 */
2225 __pyx_v_6gensim_6models_14word2vec_inner_scopy((&__pyx_v_c->size), (&(__pyx_v_c->syn0_vocab[__pyx_v_row1])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2226
2227 /* "gensim/models/fasttext_inner.pyx":115
2228 * #
2229 * cdef REAL_t norm_factor
2230 * if subwords_len: # <<<<<<<<<<<<<<
2231 * for d in range(subwords_len):
2232 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[subwords_index[d] * c.size], &ONE, c.neu1, &ONE)
2233 */
2234 __pyx_t_1 = (__pyx_v_subwords_len != 0);
2235 if (__pyx_t_1) {
2236
2237 /* "gensim/models/fasttext_inner.pyx":116
2238 * cdef REAL_t norm_factor
2239 * if subwords_len:
2240 * for d in range(subwords_len): # <<<<<<<<<<<<<<
2241 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[subwords_index[d] * c.size], &ONE, c.neu1, &ONE)
2242 * norm_factor = ONEF / subwords_len
2243 */
2244 __pyx_t_2 = __pyx_v_subwords_len;
2245 __pyx_t_3 = __pyx_t_2;
2246 for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
2247 __pyx_v_d = __pyx_t_4;
2248
2249 /* "gensim/models/fasttext_inner.pyx":117
2250 * if subwords_len:
2251 * for d in range(subwords_len):
2252 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[subwords_index[d] * c.size], &ONE, c.neu1, &ONE) # <<<<<<<<<<<<<<
2253 * norm_factor = ONEF / subwords_len
2254 * sscal(&c.size, &norm_factor, c.neu1, &ONE)
2255 */
2256 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_6gensim_6models_14fasttext_inner_ONEF), (&(__pyx_v_c->syn0_ngrams[((__pyx_v_subwords_index[__pyx_v_d]) * __pyx_v_c->size)])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2257 }
2258
2259 /* "gensim/models/fasttext_inner.pyx":118
2260 * for d in range(subwords_len):
2261 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[subwords_index[d] * c.size], &ONE, c.neu1, &ONE)
2262 * norm_factor = ONEF / subwords_len # <<<<<<<<<<<<<<
2263 * sscal(&c.size, &norm_factor, c.neu1, &ONE)
2264 *
2265 */
2266 __pyx_v_norm_factor = (__pyx_v_6gensim_6models_14fasttext_inner_ONEF / __pyx_v_subwords_len);
2267
2268 /* "gensim/models/fasttext_inner.pyx":119
2269 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[subwords_index[d] * c.size], &ONE, c.neu1, &ONE)
2270 * norm_factor = ONEF / subwords_len
2271 * sscal(&c.size, &norm_factor, c.neu1, &ONE) # <<<<<<<<<<<<<<
2272 *
2273 * for d in range(c.negative+1):
2274 */
2275 __pyx_v_6gensim_6models_14word2vec_inner_sscal((&__pyx_v_c->size), (&__pyx_v_norm_factor), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2276
2277 /* "gensim/models/fasttext_inner.pyx":115
2278 * #
2279 * cdef REAL_t norm_factor
2280 * if subwords_len: # <<<<<<<<<<<<<<
2281 * for d in range(subwords_len):
2282 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[subwords_index[d] * c.size], &ONE, c.neu1, &ONE)
2283 */
2284 }
2285
2286 /* "gensim/models/fasttext_inner.pyx":121
2287 * sscal(&c.size, &norm_factor, c.neu1, &ONE)
2288 *
2289 * for d in range(c.negative+1): # <<<<<<<<<<<<<<
2290 * if d == 0:
2291 * target_index = word_index
2292 */
2293 __pyx_t_5 = (__pyx_v_c->negative + 1);
2294 __pyx_t_6 = __pyx_t_5;
2295 for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_6; __pyx_t_4+=1) {
2296 __pyx_v_d = __pyx_t_4;
2297
2298 /* "gensim/models/fasttext_inner.pyx":122
2299 *
2300 * for d in range(c.negative+1):
2301 * if d == 0: # <<<<<<<<<<<<<<
2302 * target_index = word_index
2303 * label = ONEF
2304 */
2305 __pyx_t_1 = ((__pyx_v_d == 0) != 0);
2306 if (__pyx_t_1) {
2307
2308 /* "gensim/models/fasttext_inner.pyx":123
2309 * for d in range(c.negative+1):
2310 * if d == 0:
2311 * target_index = word_index # <<<<<<<<<<<<<<
2312 * label = ONEF
2313 * else:
2314 */
2315 __pyx_v_target_index = __pyx_v_word_index;
2316
2317 /* "gensim/models/fasttext_inner.pyx":124
2318 * if d == 0:
2319 * target_index = word_index
2320 * label = ONEF # <<<<<<<<<<<<<<
2321 * else:
2322 * target_index = bisect_left(
2323 */
2324 __pyx_v_label = __pyx_v_6gensim_6models_14fasttext_inner_ONEF;
2325
2326 /* "gensim/models/fasttext_inner.pyx":122
2327 *
2328 * for d in range(c.negative+1):
2329 * if d == 0: # <<<<<<<<<<<<<<
2330 * target_index = word_index
2331 * label = ONEF
2332 */
2333 goto __pyx_L8;
2334 }
2335
2336 /* "gensim/models/fasttext_inner.pyx":126
2337 * label = ONEF
2338 * else:
2339 * target_index = bisect_left( # <<<<<<<<<<<<<<
2340 * c.cum_table, (c.next_random >> 16) % c.cum_table[c.cum_table_len-1], 0, c.cum_table_len)
2341 * c.next_random = (c.next_random * <unsigned long long>25214903917ULL + 11) & modulo
2342 */
2343 /*else*/ {
2344
2345 /* "gensim/models/fasttext_inner.pyx":127
2346 * else:
2347 * target_index = bisect_left(
2348 * c.cum_table, (c.next_random >> 16) % c.cum_table[c.cum_table_len-1], 0, c.cum_table_len) # <<<<<<<<<<<<<<
2349 * c.next_random = (c.next_random * <unsigned long long>25214903917ULL + 11) & modulo
2350 * if target_index == word_index:
2351 */
2352 __pyx_v_target_index = __pyx_f_6gensim_6models_14word2vec_inner_bisect_left(__pyx_v_c->cum_table, ((__pyx_v_c->next_random >> 16) % (__pyx_v_c->cum_table[(__pyx_v_c->cum_table_len - 1)])), 0, __pyx_v_c->cum_table_len);
2353
2354 /* "gensim/models/fasttext_inner.pyx":128
2355 * target_index = bisect_left(
2356 * c.cum_table, (c.next_random >> 16) % c.cum_table[c.cum_table_len-1], 0, c.cum_table_len)
2357 * c.next_random = (c.next_random * <unsigned long long>25214903917ULL + 11) & modulo # <<<<<<<<<<<<<<
2358 * if target_index == word_index:
2359 * continue
2360 */
2361 __pyx_v_c->next_random = (((__pyx_v_c->next_random * ((unsigned PY_LONG_LONG)25214903917ULL)) + 11) & __pyx_v_modulo);
2362
2363 /* "gensim/models/fasttext_inner.pyx":129
2364 * c.cum_table, (c.next_random >> 16) % c.cum_table[c.cum_table_len-1], 0, c.cum_table_len)
2365 * c.next_random = (c.next_random * <unsigned long long>25214903917ULL + 11) & modulo
2366 * if target_index == word_index: # <<<<<<<<<<<<<<
2367 * continue
2368 * label = <REAL_t>0.0
2369 */
2370 __pyx_t_1 = ((__pyx_v_target_index == __pyx_v_word_index) != 0);
2371 if (__pyx_t_1) {
2372
2373 /* "gensim/models/fasttext_inner.pyx":130
2374 * c.next_random = (c.next_random * <unsigned long long>25214903917ULL + 11) & modulo
2375 * if target_index == word_index:
2376 * continue # <<<<<<<<<<<<<<
2377 * label = <REAL_t>0.0
2378 *
2379 */
2380 goto __pyx_L6_continue;
2381
2382 /* "gensim/models/fasttext_inner.pyx":129
2383 * c.cum_table, (c.next_random >> 16) % c.cum_table[c.cum_table_len-1], 0, c.cum_table_len)
2384 * c.next_random = (c.next_random * <unsigned long long>25214903917ULL + 11) & modulo
2385 * if target_index == word_index: # <<<<<<<<<<<<<<
2386 * continue
2387 * label = <REAL_t>0.0
2388 */
2389 }
2390
2391 /* "gensim/models/fasttext_inner.pyx":131
2392 * if target_index == word_index:
2393 * continue
2394 * label = <REAL_t>0.0 # <<<<<<<<<<<<<<
2395 *
2396 * row2 = target_index * c.size
2397 */
2398 __pyx_v_label = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)0.0);
2399 }
2400 __pyx_L8:;
2401
2402 /* "gensim/models/fasttext_inner.pyx":133
2403 * label = <REAL_t>0.0
2404 *
2405 * row2 = target_index * c.size # <<<<<<<<<<<<<<
2406 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
2407 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
2408 */
2409 __pyx_v_row2 = (__pyx_v_target_index * __pyx_v_c->size);
2410
2411 /* "gensim/models/fasttext_inner.pyx":134
2412 *
2413 * row2 = target_index * c.size
2414 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1neg[row2], &ONE) # <<<<<<<<<<<<<<
2415 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
2416 * continue
2417 */
2418 __pyx_v_f_dot = __pyx_v_6gensim_6models_14word2vec_inner_our_dot((&__pyx_v_c->size), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn1neg[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2419
2420 /* "gensim/models/fasttext_inner.pyx":135
2421 * row2 = target_index * c.size
2422 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
2423 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP: # <<<<<<<<<<<<<<
2424 * continue
2425 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
2426 */
2427 __pyx_t_7 = ((__pyx_v_f_dot <= -8.0) != 0);
2428 if (!__pyx_t_7) {
2429 } else {
2430 __pyx_t_1 = __pyx_t_7;
2431 goto __pyx_L11_bool_binop_done;
2432 }
2433 __pyx_t_7 = ((__pyx_v_f_dot >= 8.0) != 0);
2434 __pyx_t_1 = __pyx_t_7;
2435 __pyx_L11_bool_binop_done:;
2436 if (__pyx_t_1) {
2437
2438 /* "gensim/models/fasttext_inner.pyx":136
2439 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
2440 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
2441 * continue # <<<<<<<<<<<<<<
2442 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
2443 * g = (label - f) * c.alpha
2444 */
2445 goto __pyx_L6_continue;
2446
2447 /* "gensim/models/fasttext_inner.pyx":135
2448 * row2 = target_index * c.size
2449 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
2450 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP: # <<<<<<<<<<<<<<
2451 * continue
2452 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
2453 */
2454 }
2455
2456 /* "gensim/models/fasttext_inner.pyx":137
2457 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
2458 * continue
2459 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))] # <<<<<<<<<<<<<<
2460 * g = (label - f) * c.alpha
2461 * our_saxpy(&c.size, &g, &c.syn1neg[row2], &ONE, c.work, &ONE)
2462 */
2463 __pyx_v_f = (__pyx_v_6gensim_6models_14fasttext_inner_EXP_TABLE[((int)((__pyx_v_f_dot + 8.0) * 32.0))]);
2464
2465 /* "gensim/models/fasttext_inner.pyx":138
2466 * continue
2467 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
2468 * g = (label - f) * c.alpha # <<<<<<<<<<<<<<
2469 * our_saxpy(&c.size, &g, &c.syn1neg[row2], &ONE, c.work, &ONE)
2470 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
2471 */
2472 __pyx_v_g = ((__pyx_v_label - __pyx_v_f) * __pyx_v_c->alpha);
2473
2474 /* "gensim/models/fasttext_inner.pyx":139
2475 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
2476 * g = (label - f) * c.alpha
2477 * our_saxpy(&c.size, &g, &c.syn1neg[row2], &ONE, c.work, &ONE) # <<<<<<<<<<<<<<
2478 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
2479 * our_saxpy(&c.size, &c.vocab_lockf[word2_index % c.vocab_lockf_len], c.work, &ONE, &c.syn0_vocab[row1], &ONE)
2480 */
2481 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_g), (&(__pyx_v_c->syn1neg[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2482
2483 /* "gensim/models/fasttext_inner.pyx":140
2484 * g = (label - f) * c.alpha
2485 * our_saxpy(&c.size, &g, &c.syn1neg[row2], &ONE, c.work, &ONE)
2486 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1neg[row2], &ONE) # <<<<<<<<<<<<<<
2487 * our_saxpy(&c.size, &c.vocab_lockf[word2_index % c.vocab_lockf_len], c.work, &ONE, &c.syn0_vocab[row1], &ONE)
2488 * for d in range(subwords_len):
2489 */
2490 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_g), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn1neg[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2491 __pyx_L6_continue:;
2492 }
2493
2494 /* "gensim/models/fasttext_inner.pyx":141
2495 * our_saxpy(&c.size, &g, &c.syn1neg[row2], &ONE, c.work, &ONE)
2496 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
2497 * our_saxpy(&c.size, &c.vocab_lockf[word2_index % c.vocab_lockf_len], c.work, &ONE, &c.syn0_vocab[row1], &ONE) # <<<<<<<<<<<<<<
2498 * for d in range(subwords_len):
2499 * our_saxpy(&c.size, &c.ngrams_lockf[subwords_index[d] % c.ngrams_lockf_len],
2500 */
2501 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&(__pyx_v_c->vocab_lockf[(__pyx_v_word2_index % __pyx_v_c->vocab_lockf_len)])), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn0_vocab[__pyx_v_row1])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2502
2503 /* "gensim/models/fasttext_inner.pyx":142
2504 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
2505 * our_saxpy(&c.size, &c.vocab_lockf[word2_index % c.vocab_lockf_len], c.work, &ONE, &c.syn0_vocab[row1], &ONE)
2506 * for d in range(subwords_len): # <<<<<<<<<<<<<<
2507 * our_saxpy(&c.size, &c.ngrams_lockf[subwords_index[d] % c.ngrams_lockf_len],
2508 * c.work, &ONE, &c.syn0_ngrams[subwords_index[d]*c.size], &ONE)
2509 */
2510 __pyx_t_2 = __pyx_v_subwords_len;
2511 __pyx_t_3 = __pyx_t_2;
2512 for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
2513 __pyx_v_d = __pyx_t_4;
2514
2515 /* "gensim/models/fasttext_inner.pyx":143
2516 * our_saxpy(&c.size, &c.vocab_lockf[word2_index % c.vocab_lockf_len], c.work, &ONE, &c.syn0_vocab[row1], &ONE)
2517 * for d in range(subwords_len):
2518 * our_saxpy(&c.size, &c.ngrams_lockf[subwords_index[d] % c.ngrams_lockf_len], # <<<<<<<<<<<<<<
2519 * c.work, &ONE, &c.syn0_ngrams[subwords_index[d]*c.size], &ONE)
2520 *
2521 */
2522 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&(__pyx_v_c->ngrams_lockf[((__pyx_v_subwords_index[__pyx_v_d]) % __pyx_v_c->ngrams_lockf_len)])), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn0_ngrams[((__pyx_v_subwords_index[__pyx_v_d]) * __pyx_v_c->size)])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2523 }
2524
2525 /* "gensim/models/fasttext_inner.pyx":74
2526 *
2527 *
2528 * cdef void fasttext_fast_sentence_sg_neg(FastTextConfig *c, int i, int j) nogil: # <<<<<<<<<<<<<<
2529 * """Perform skipgram training with negative sampling.
2530 *
2531 */
2532
2533 /* function exit code */
2534 }
2535
2536 /* "gensim/models/fasttext_inner.pyx":147
2537 *
2538 *
2539 * cdef void fasttext_fast_sentence_sg_hs(FastTextConfig *c, int i, int j) nogil: # <<<<<<<<<<<<<<
2540 * """Perform skipgram training with hierarchical sampling.
2541 *
2542 */
2543
__pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_sg_hs(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig * __pyx_v_c,int __pyx_v_i,int __pyx_v_j)2544 static void __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_sg_hs(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *__pyx_v_c, int __pyx_v_i, int __pyx_v_j) {
2545 __pyx_t_5numpy_uint32_t *__pyx_v_word_point;
2546 __pyx_t_5numpy_uint8_t *__pyx_v_word_code;
2547 int __pyx_v_codelen;
2548 __pyx_t_5numpy_uint32_t __pyx_v_word2_index;
2549 __pyx_t_5numpy_uint32_t *__pyx_v_subwords_index;
2550 __pyx_t_5numpy_uint32_t __pyx_v_subwords_len;
2551 PY_LONG_LONG __pyx_v_b;
2552 PY_LONG_LONG __pyx_v_row1;
2553 PY_LONG_LONG __pyx_v_row2;
2554 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_f;
2555 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_g;
2556 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_f_dot;
2557 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_norm_factor;
2558 __pyx_t_5numpy_uint32_t __pyx_v_d;
2559 int __pyx_t_1;
2560 __pyx_t_5numpy_uint32_t __pyx_t_2;
2561 __pyx_t_5numpy_uint32_t __pyx_t_3;
2562 __pyx_t_5numpy_uint32_t __pyx_t_4;
2563 int __pyx_t_5;
2564 int __pyx_t_6;
2565 PY_LONG_LONG __pyx_t_7;
2566 int __pyx_t_8;
2567
2568 /* "gensim/models/fasttext_inner.pyx":163
2569 * """
2570 * cdef:
2571 * np.uint32_t *word_point = c.points[j] # <<<<<<<<<<<<<<
2572 * np.uint8_t *word_code = c.codes[j]
2573 * int codelen = c.codelens[j]
2574 */
2575 __pyx_v_word_point = (__pyx_v_c->points[__pyx_v_j]);
2576
2577 /* "gensim/models/fasttext_inner.pyx":164
2578 * cdef:
2579 * np.uint32_t *word_point = c.points[j]
2580 * np.uint8_t *word_code = c.codes[j] # <<<<<<<<<<<<<<
2581 * int codelen = c.codelens[j]
2582 * np.uint32_t word2_index = c.indexes[i]
2583 */
2584 __pyx_v_word_code = (__pyx_v_c->codes[__pyx_v_j]);
2585
2586 /* "gensim/models/fasttext_inner.pyx":165
2587 * np.uint32_t *word_point = c.points[j]
2588 * np.uint8_t *word_code = c.codes[j]
2589 * int codelen = c.codelens[j] # <<<<<<<<<<<<<<
2590 * np.uint32_t word2_index = c.indexes[i]
2591 * np.uint32_t *subwords_index = c.subwords_idx[i]
2592 */
2593 __pyx_v_codelen = (__pyx_v_c->codelens[__pyx_v_j]);
2594
2595 /* "gensim/models/fasttext_inner.pyx":166
2596 * np.uint8_t *word_code = c.codes[j]
2597 * int codelen = c.codelens[j]
2598 * np.uint32_t word2_index = c.indexes[i] # <<<<<<<<<<<<<<
2599 * np.uint32_t *subwords_index = c.subwords_idx[i]
2600 * np.uint32_t subwords_len = c.subwords_idx_len[i]
2601 */
2602 __pyx_v_word2_index = (__pyx_v_c->indexes[__pyx_v_i]);
2603
2604 /* "gensim/models/fasttext_inner.pyx":167
2605 * int codelen = c.codelens[j]
2606 * np.uint32_t word2_index = c.indexes[i]
2607 * np.uint32_t *subwords_index = c.subwords_idx[i] # <<<<<<<<<<<<<<
2608 * np.uint32_t subwords_len = c.subwords_idx_len[i]
2609 *
2610 */
2611 __pyx_v_subwords_index = (__pyx_v_c->subwords_idx[__pyx_v_i]);
2612
2613 /* "gensim/models/fasttext_inner.pyx":168
2614 * np.uint32_t word2_index = c.indexes[i]
2615 * np.uint32_t *subwords_index = c.subwords_idx[i]
2616 * np.uint32_t subwords_len = c.subwords_idx_len[i] # <<<<<<<<<<<<<<
2617 *
2618 * #
2619 */
2620 __pyx_v_subwords_len = (__pyx_v_c->subwords_idx_len[__pyx_v_i]);
2621
2622 /* "gensim/models/fasttext_inner.pyx":185
2623 * #
2624 * cdef long long b
2625 * cdef long long row1 = word2_index * c.size, row2 # <<<<<<<<<<<<<<
2626 * cdef REAL_t f, g, f_dot
2627 *
2628 */
2629 __pyx_v_row1 = (__pyx_v_word2_index * __pyx_v_c->size);
2630
2631 /* "gensim/models/fasttext_inner.pyx":188
2632 * cdef REAL_t f, g, f_dot
2633 *
2634 * memset(c.work, 0, c.size * cython.sizeof(REAL_t)) # <<<<<<<<<<<<<<
2635 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t))
2636 *
2637 */
2638 (void)(memset(__pyx_v_c->work, 0, (__pyx_v_c->size * (sizeof(__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)))));
2639
2640 /* "gensim/models/fasttext_inner.pyx":189
2641 *
2642 * memset(c.work, 0, c.size * cython.sizeof(REAL_t))
2643 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t)) # <<<<<<<<<<<<<<
2644 *
2645 * scopy(&c.size, &c.syn0_vocab[row1], &ONE, c.neu1, &ONE)
2646 */
2647 (void)(memset(__pyx_v_c->neu1, 0, (__pyx_v_c->size * (sizeof(__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)))));
2648
2649 /* "gensim/models/fasttext_inner.pyx":191
2650 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t))
2651 *
2652 * scopy(&c.size, &c.syn0_vocab[row1], &ONE, c.neu1, &ONE) # <<<<<<<<<<<<<<
2653 *
2654 * #
2655 */
2656 __pyx_v_6gensim_6models_14word2vec_inner_scopy((&__pyx_v_c->size), (&(__pyx_v_c->syn0_vocab[__pyx_v_row1])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2657
2658 /* "gensim/models/fasttext_inner.pyx":197
2659 * #
2660 * cdef REAL_t norm_factor
2661 * if subwords_len: # <<<<<<<<<<<<<<
2662 * for d in range(subwords_len):
2663 * row2 = subwords_index[d] * c.size
2664 */
2665 __pyx_t_1 = (__pyx_v_subwords_len != 0);
2666 if (__pyx_t_1) {
2667
2668 /* "gensim/models/fasttext_inner.pyx":198
2669 * cdef REAL_t norm_factor
2670 * if subwords_len:
2671 * for d in range(subwords_len): # <<<<<<<<<<<<<<
2672 * row2 = subwords_index[d] * c.size
2673 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[row2], &ONE, c.neu1, &ONE)
2674 */
2675 __pyx_t_2 = __pyx_v_subwords_len;
2676 __pyx_t_3 = __pyx_t_2;
2677 for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
2678 __pyx_v_d = __pyx_t_4;
2679
2680 /* "gensim/models/fasttext_inner.pyx":199
2681 * if subwords_len:
2682 * for d in range(subwords_len):
2683 * row2 = subwords_index[d] * c.size # <<<<<<<<<<<<<<
2684 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[row2], &ONE, c.neu1, &ONE)
2685 * norm_factor = ONEF / subwords_len
2686 */
2687 __pyx_v_row2 = ((__pyx_v_subwords_index[__pyx_v_d]) * __pyx_v_c->size);
2688
2689 /* "gensim/models/fasttext_inner.pyx":200
2690 * for d in range(subwords_len):
2691 * row2 = subwords_index[d] * c.size
2692 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[row2], &ONE, c.neu1, &ONE) # <<<<<<<<<<<<<<
2693 * norm_factor = ONEF / subwords_len
2694 * sscal(&c.size, &norm_factor, c.neu1, &ONE)
2695 */
2696 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_6gensim_6models_14fasttext_inner_ONEF), (&(__pyx_v_c->syn0_ngrams[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2697 }
2698
2699 /* "gensim/models/fasttext_inner.pyx":201
2700 * row2 = subwords_index[d] * c.size
2701 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[row2], &ONE, c.neu1, &ONE)
2702 * norm_factor = ONEF / subwords_len # <<<<<<<<<<<<<<
2703 * sscal(&c.size, &norm_factor, c.neu1, &ONE)
2704 *
2705 */
2706 __pyx_v_norm_factor = (__pyx_v_6gensim_6models_14fasttext_inner_ONEF / __pyx_v_subwords_len);
2707
2708 /* "gensim/models/fasttext_inner.pyx":202
2709 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[row2], &ONE, c.neu1, &ONE)
2710 * norm_factor = ONEF / subwords_len
2711 * sscal(&c.size, &norm_factor, c.neu1, &ONE) # <<<<<<<<<<<<<<
2712 *
2713 * for b in range(codelen):
2714 */
2715 __pyx_v_6gensim_6models_14word2vec_inner_sscal((&__pyx_v_c->size), (&__pyx_v_norm_factor), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2716
2717 /* "gensim/models/fasttext_inner.pyx":197
2718 * #
2719 * cdef REAL_t norm_factor
2720 * if subwords_len: # <<<<<<<<<<<<<<
2721 * for d in range(subwords_len):
2722 * row2 = subwords_index[d] * c.size
2723 */
2724 }
2725
2726 /* "gensim/models/fasttext_inner.pyx":204
2727 * sscal(&c.size, &norm_factor, c.neu1, &ONE)
2728 *
2729 * for b in range(codelen): # <<<<<<<<<<<<<<
2730 * row2 = word_point[b] * c.size
2731 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE)
2732 */
2733 __pyx_t_5 = __pyx_v_codelen;
2734 __pyx_t_6 = __pyx_t_5;
2735 for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
2736 __pyx_v_b = __pyx_t_7;
2737
2738 /* "gensim/models/fasttext_inner.pyx":205
2739 *
2740 * for b in range(codelen):
2741 * row2 = word_point[b] * c.size # <<<<<<<<<<<<<<
2742 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE)
2743 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
2744 */
2745 __pyx_v_row2 = ((__pyx_v_word_point[__pyx_v_b]) * __pyx_v_c->size);
2746
2747 /* "gensim/models/fasttext_inner.pyx":206
2748 * for b in range(codelen):
2749 * row2 = word_point[b] * c.size
2750 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE) # <<<<<<<<<<<<<<
2751 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
2752 * continue
2753 */
2754 __pyx_v_f_dot = __pyx_v_6gensim_6models_14word2vec_inner_our_dot((&__pyx_v_c->size), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn1[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2755
2756 /* "gensim/models/fasttext_inner.pyx":207
2757 * row2 = word_point[b] * c.size
2758 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE)
2759 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP: # <<<<<<<<<<<<<<
2760 * continue
2761 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
2762 */
2763 __pyx_t_8 = ((__pyx_v_f_dot <= -8.0) != 0);
2764 if (!__pyx_t_8) {
2765 } else {
2766 __pyx_t_1 = __pyx_t_8;
2767 goto __pyx_L9_bool_binop_done;
2768 }
2769 __pyx_t_8 = ((__pyx_v_f_dot >= 8.0) != 0);
2770 __pyx_t_1 = __pyx_t_8;
2771 __pyx_L9_bool_binop_done:;
2772 if (__pyx_t_1) {
2773
2774 /* "gensim/models/fasttext_inner.pyx":208
2775 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE)
2776 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
2777 * continue # <<<<<<<<<<<<<<
2778 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
2779 * g = (1 - word_code[b] - f) * c.alpha
2780 */
2781 goto __pyx_L6_continue;
2782
2783 /* "gensim/models/fasttext_inner.pyx":207
2784 * row2 = word_point[b] * c.size
2785 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE)
2786 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP: # <<<<<<<<<<<<<<
2787 * continue
2788 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
2789 */
2790 }
2791
2792 /* "gensim/models/fasttext_inner.pyx":209
2793 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
2794 * continue
2795 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))] # <<<<<<<<<<<<<<
2796 * g = (1 - word_code[b] - f) * c.alpha
2797 *
2798 */
2799 __pyx_v_f = (__pyx_v_6gensim_6models_14fasttext_inner_EXP_TABLE[((int)((__pyx_v_f_dot + 8.0) * 32.0))]);
2800
2801 /* "gensim/models/fasttext_inner.pyx":210
2802 * continue
2803 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
2804 * g = (1 - word_code[b] - f) * c.alpha # <<<<<<<<<<<<<<
2805 *
2806 * our_saxpy(&c.size, &g, &c.syn1[row2], &ONE, c.work, &ONE)
2807 */
2808 __pyx_v_g = (((1 - (__pyx_v_word_code[__pyx_v_b])) - __pyx_v_f) * __pyx_v_c->alpha);
2809
2810 /* "gensim/models/fasttext_inner.pyx":212
2811 * g = (1 - word_code[b] - f) * c.alpha
2812 *
2813 * our_saxpy(&c.size, &g, &c.syn1[row2], &ONE, c.work, &ONE) # <<<<<<<<<<<<<<
2814 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1[row2], &ONE)
2815 *
2816 */
2817 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_g), (&(__pyx_v_c->syn1[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2818
2819 /* "gensim/models/fasttext_inner.pyx":213
2820 *
2821 * our_saxpy(&c.size, &g, &c.syn1[row2], &ONE, c.work, &ONE)
2822 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1[row2], &ONE) # <<<<<<<<<<<<<<
2823 *
2824 * our_saxpy(&c.size, &c.vocab_lockf[word2_index % c.vocab_lockf_len], c.work, &ONE, &c.syn0_vocab[row1], &ONE)
2825 */
2826 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_g), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn1[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2827 __pyx_L6_continue:;
2828 }
2829
2830 /* "gensim/models/fasttext_inner.pyx":215
2831 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1[row2], &ONE)
2832 *
2833 * our_saxpy(&c.size, &c.vocab_lockf[word2_index % c.vocab_lockf_len], c.work, &ONE, &c.syn0_vocab[row1], &ONE) # <<<<<<<<<<<<<<
2834 * for d in range(subwords_len):
2835 * row2 = subwords_index[d] * c.size
2836 */
2837 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&(__pyx_v_c->vocab_lockf[(__pyx_v_word2_index % __pyx_v_c->vocab_lockf_len)])), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn0_vocab[__pyx_v_row1])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2838
2839 /* "gensim/models/fasttext_inner.pyx":216
2840 *
2841 * our_saxpy(&c.size, &c.vocab_lockf[word2_index % c.vocab_lockf_len], c.work, &ONE, &c.syn0_vocab[row1], &ONE)
2842 * for d in range(subwords_len): # <<<<<<<<<<<<<<
2843 * row2 = subwords_index[d] * c.size
2844 * our_saxpy(
2845 */
2846 __pyx_t_2 = __pyx_v_subwords_len;
2847 __pyx_t_3 = __pyx_t_2;
2848 for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
2849 __pyx_v_d = __pyx_t_4;
2850
2851 /* "gensim/models/fasttext_inner.pyx":217
2852 * our_saxpy(&c.size, &c.vocab_lockf[word2_index % c.vocab_lockf_len], c.work, &ONE, &c.syn0_vocab[row1], &ONE)
2853 * for d in range(subwords_len):
2854 * row2 = subwords_index[d] * c.size # <<<<<<<<<<<<<<
2855 * our_saxpy(
2856 * &c.size, &c.ngrams_lockf[subwords_index[d] % c.ngrams_lockf_len], c.work, &ONE,
2857 */
2858 __pyx_v_row2 = ((__pyx_v_subwords_index[__pyx_v_d]) * __pyx_v_c->size);
2859
2860 /* "gensim/models/fasttext_inner.pyx":218
2861 * for d in range(subwords_len):
2862 * row2 = subwords_index[d] * c.size
2863 * our_saxpy( # <<<<<<<<<<<<<<
2864 * &c.size, &c.ngrams_lockf[subwords_index[d] % c.ngrams_lockf_len], c.work, &ONE,
2865 * &c.syn0_ngrams[row2], &ONE)
2866 */
2867 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&(__pyx_v_c->ngrams_lockf[((__pyx_v_subwords_index[__pyx_v_d]) % __pyx_v_c->ngrams_lockf_len)])), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn0_ngrams[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
2868 }
2869
2870 /* "gensim/models/fasttext_inner.pyx":147
2871 *
2872 *
2873 * cdef void fasttext_fast_sentence_sg_hs(FastTextConfig *c, int i, int j) nogil: # <<<<<<<<<<<<<<
2874 * """Perform skipgram training with hierarchical sampling.
2875 *
2876 */
2877
2878 /* function exit code */
2879 }
2880
2881 /* "gensim/models/fasttext_inner.pyx":223
2882 *
2883 *
2884 * cdef void fasttext_fast_sentence_cbow_neg(FastTextConfig *c, int i, int j, int k) nogil: # <<<<<<<<<<<<<<
2885 * """Perform CBOW training with negative sampling.
2886 *
2887 */
2888
__pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_cbow_neg(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig * __pyx_v_c,int __pyx_v_i,int __pyx_v_j,int __pyx_v_k)2889 static void __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_cbow_neg(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *__pyx_v_c, int __pyx_v_i, int __pyx_v_j, int __pyx_v_k) {
2890 PY_LONG_LONG __pyx_v_row2;
2891 unsigned PY_LONG_LONG __pyx_v_modulo;
2892 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_f;
2893 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_g;
2894 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_count;
2895 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_inv_count;
2896 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_label;
2897 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_f_dot;
2898 __pyx_t_5numpy_uint32_t __pyx_v_target_index;
2899 __pyx_t_5numpy_uint32_t __pyx_v_word_index;
2900 int __pyx_v_d;
2901 int __pyx_v_m;
2902 int __pyx_t_1;
2903 int __pyx_t_2;
2904 int __pyx_t_3;
2905 int __pyx_t_4;
2906 int __pyx_t_5;
2907 int __pyx_t_6;
2908 int __pyx_t_7;
2909 long __pyx_t_8;
2910 long __pyx_t_9;
2911
2912 /* "gensim/models/fasttext_inner.pyx":244
2913 *
2914 * cdef long long row2
2915 * cdef unsigned long long modulo = 281474976710655ULL # <<<<<<<<<<<<<<
2916 * cdef REAL_t f, g, count, inv_count = 1.0, label, f_dot
2917 * cdef np.uint32_t target_index, word_index
2918 */
2919 __pyx_v_modulo = 281474976710655ULL;
2920
2921 /* "gensim/models/fasttext_inner.pyx":245
2922 * cdef long long row2
2923 * cdef unsigned long long modulo = 281474976710655ULL
2924 * cdef REAL_t f, g, count, inv_count = 1.0, label, f_dot # <<<<<<<<<<<<<<
2925 * cdef np.uint32_t target_index, word_index
2926 * cdef int d, m
2927 */
2928 __pyx_v_inv_count = 1.0;
2929
2930 /* "gensim/models/fasttext_inner.pyx":249
2931 * cdef int d, m
2932 *
2933 * word_index = c.indexes[i] # <<<<<<<<<<<<<<
2934 *
2935 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t))
2936 */
2937 __pyx_v_word_index = (__pyx_v_c->indexes[__pyx_v_i]);
2938
2939 /* "gensim/models/fasttext_inner.pyx":251
2940 * word_index = c.indexes[i]
2941 *
2942 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t)) # <<<<<<<<<<<<<<
2943 * count = <REAL_t>0.0
2944 * for m in range(j, k):
2945 */
2946 (void)(memset(__pyx_v_c->neu1, 0, (__pyx_v_c->size * (sizeof(__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)))));
2947
2948 /* "gensim/models/fasttext_inner.pyx":252
2949 *
2950 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t))
2951 * count = <REAL_t>0.0 # <<<<<<<<<<<<<<
2952 * for m in range(j, k):
2953 * if m == i:
2954 */
2955 __pyx_v_count = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)0.0);
2956
2957 /* "gensim/models/fasttext_inner.pyx":253
2958 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t))
2959 * count = <REAL_t>0.0
2960 * for m in range(j, k): # <<<<<<<<<<<<<<
2961 * if m == i:
2962 * continue
2963 */
2964 __pyx_t_1 = __pyx_v_k;
2965 __pyx_t_2 = __pyx_t_1;
2966 for (__pyx_t_3 = __pyx_v_j; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
2967 __pyx_v_m = __pyx_t_3;
2968
2969 /* "gensim/models/fasttext_inner.pyx":254
2970 * count = <REAL_t>0.0
2971 * for m in range(j, k):
2972 * if m == i: # <<<<<<<<<<<<<<
2973 * continue
2974 * count += ONEF
2975 */
2976 __pyx_t_4 = ((__pyx_v_m == __pyx_v_i) != 0);
2977 if (__pyx_t_4) {
2978
2979 /* "gensim/models/fasttext_inner.pyx":255
2980 * for m in range(j, k):
2981 * if m == i:
2982 * continue # <<<<<<<<<<<<<<
2983 * count += ONEF
2984 * our_saxpy(&c.size, &ONEF, &c.syn0_vocab[c.indexes[m] * c.size], &ONE, c.neu1, &ONE)
2985 */
2986 goto __pyx_L3_continue;
2987
2988 /* "gensim/models/fasttext_inner.pyx":254
2989 * count = <REAL_t>0.0
2990 * for m in range(j, k):
2991 * if m == i: # <<<<<<<<<<<<<<
2992 * continue
2993 * count += ONEF
2994 */
2995 }
2996
2997 /* "gensim/models/fasttext_inner.pyx":256
2998 * if m == i:
2999 * continue
3000 * count += ONEF # <<<<<<<<<<<<<<
3001 * our_saxpy(&c.size, &ONEF, &c.syn0_vocab[c.indexes[m] * c.size], &ONE, c.neu1, &ONE)
3002 * for d in range(c.subwords_idx_len[m]):
3003 */
3004 __pyx_v_count = (__pyx_v_count + __pyx_v_6gensim_6models_14fasttext_inner_ONEF);
3005
3006 /* "gensim/models/fasttext_inner.pyx":257
3007 * continue
3008 * count += ONEF
3009 * our_saxpy(&c.size, &ONEF, &c.syn0_vocab[c.indexes[m] * c.size], &ONE, c.neu1, &ONE) # <<<<<<<<<<<<<<
3010 * for d in range(c.subwords_idx_len[m]):
3011 * count += ONEF
3012 */
3013 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_6gensim_6models_14fasttext_inner_ONEF), (&(__pyx_v_c->syn0_vocab[((__pyx_v_c->indexes[__pyx_v_m]) * __pyx_v_c->size)])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3014
3015 /* "gensim/models/fasttext_inner.pyx":258
3016 * count += ONEF
3017 * our_saxpy(&c.size, &ONEF, &c.syn0_vocab[c.indexes[m] * c.size], &ONE, c.neu1, &ONE)
3018 * for d in range(c.subwords_idx_len[m]): # <<<<<<<<<<<<<<
3019 * count += ONEF
3020 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[c.subwords_idx[m][d] * c.size], &ONE, c.neu1, &ONE)
3021 */
3022 __pyx_t_5 = (__pyx_v_c->subwords_idx_len[__pyx_v_m]);
3023 __pyx_t_6 = __pyx_t_5;
3024 for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
3025 __pyx_v_d = __pyx_t_7;
3026
3027 /* "gensim/models/fasttext_inner.pyx":259
3028 * our_saxpy(&c.size, &ONEF, &c.syn0_vocab[c.indexes[m] * c.size], &ONE, c.neu1, &ONE)
3029 * for d in range(c.subwords_idx_len[m]):
3030 * count += ONEF # <<<<<<<<<<<<<<
3031 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[c.subwords_idx[m][d] * c.size], &ONE, c.neu1, &ONE)
3032 *
3033 */
3034 __pyx_v_count = (__pyx_v_count + __pyx_v_6gensim_6models_14fasttext_inner_ONEF);
3035
3036 /* "gensim/models/fasttext_inner.pyx":260
3037 * for d in range(c.subwords_idx_len[m]):
3038 * count += ONEF
3039 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[c.subwords_idx[m][d] * c.size], &ONE, c.neu1, &ONE) # <<<<<<<<<<<<<<
3040 *
3041 * if count > (<REAL_t>0.5):
3042 */
3043 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_6gensim_6models_14fasttext_inner_ONEF), (&(__pyx_v_c->syn0_ngrams[(((__pyx_v_c->subwords_idx[__pyx_v_m])[__pyx_v_d]) * __pyx_v_c->size)])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3044 }
3045 __pyx_L3_continue:;
3046 }
3047
3048 /* "gensim/models/fasttext_inner.pyx":262
3049 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[c.subwords_idx[m][d] * c.size], &ONE, c.neu1, &ONE)
3050 *
3051 * if count > (<REAL_t>0.5): # <<<<<<<<<<<<<<
3052 * inv_count = ONEF / count
3053 * if c.cbow_mean:
3054 */
3055 __pyx_t_4 = ((__pyx_v_count > ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)0.5)) != 0);
3056 if (__pyx_t_4) {
3057
3058 /* "gensim/models/fasttext_inner.pyx":263
3059 *
3060 * if count > (<REAL_t>0.5):
3061 * inv_count = ONEF / count # <<<<<<<<<<<<<<
3062 * if c.cbow_mean:
3063 * sscal(&c.size, &inv_count, c.neu1, &ONE)
3064 */
3065 __pyx_v_inv_count = (__pyx_v_6gensim_6models_14fasttext_inner_ONEF / __pyx_v_count);
3066
3067 /* "gensim/models/fasttext_inner.pyx":262
3068 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[c.subwords_idx[m][d] * c.size], &ONE, c.neu1, &ONE)
3069 *
3070 * if count > (<REAL_t>0.5): # <<<<<<<<<<<<<<
3071 * inv_count = ONEF / count
3072 * if c.cbow_mean:
3073 */
3074 }
3075
3076 /* "gensim/models/fasttext_inner.pyx":264
3077 * if count > (<REAL_t>0.5):
3078 * inv_count = ONEF / count
3079 * if c.cbow_mean: # <<<<<<<<<<<<<<
3080 * sscal(&c.size, &inv_count, c.neu1, &ONE)
3081 *
3082 */
3083 __pyx_t_4 = (__pyx_v_c->cbow_mean != 0);
3084 if (__pyx_t_4) {
3085
3086 /* "gensim/models/fasttext_inner.pyx":265
3087 * inv_count = ONEF / count
3088 * if c.cbow_mean:
3089 * sscal(&c.size, &inv_count, c.neu1, &ONE) # <<<<<<<<<<<<<<
3090 *
3091 * memset(c.work, 0, c.size * cython.sizeof(REAL_t))
3092 */
3093 __pyx_v_6gensim_6models_14word2vec_inner_sscal((&__pyx_v_c->size), (&__pyx_v_inv_count), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3094
3095 /* "gensim/models/fasttext_inner.pyx":264
3096 * if count > (<REAL_t>0.5):
3097 * inv_count = ONEF / count
3098 * if c.cbow_mean: # <<<<<<<<<<<<<<
3099 * sscal(&c.size, &inv_count, c.neu1, &ONE)
3100 *
3101 */
3102 }
3103
3104 /* "gensim/models/fasttext_inner.pyx":267
3105 * sscal(&c.size, &inv_count, c.neu1, &ONE)
3106 *
3107 * memset(c.work, 0, c.size * cython.sizeof(REAL_t)) # <<<<<<<<<<<<<<
3108 *
3109 * for d in range(c.negative+1):
3110 */
3111 (void)(memset(__pyx_v_c->work, 0, (__pyx_v_c->size * (sizeof(__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)))));
3112
3113 /* "gensim/models/fasttext_inner.pyx":269
3114 * memset(c.work, 0, c.size * cython.sizeof(REAL_t))
3115 *
3116 * for d in range(c.negative+1): # <<<<<<<<<<<<<<
3117 * if d == 0:
3118 * target_index = word_index
3119 */
3120 __pyx_t_8 = (__pyx_v_c->negative + 1);
3121 __pyx_t_9 = __pyx_t_8;
3122 for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_9; __pyx_t_1+=1) {
3123 __pyx_v_d = __pyx_t_1;
3124
3125 /* "gensim/models/fasttext_inner.pyx":270
3126 *
3127 * for d in range(c.negative+1):
3128 * if d == 0: # <<<<<<<<<<<<<<
3129 * target_index = word_index
3130 * label = ONEF
3131 */
3132 __pyx_t_4 = ((__pyx_v_d == 0) != 0);
3133 if (__pyx_t_4) {
3134
3135 /* "gensim/models/fasttext_inner.pyx":271
3136 * for d in range(c.negative+1):
3137 * if d == 0:
3138 * target_index = word_index # <<<<<<<<<<<<<<
3139 * label = ONEF
3140 * else:
3141 */
3142 __pyx_v_target_index = __pyx_v_word_index;
3143
3144 /* "gensim/models/fasttext_inner.pyx":272
3145 * if d == 0:
3146 * target_index = word_index
3147 * label = ONEF # <<<<<<<<<<<<<<
3148 * else:
3149 * target_index = bisect_left(c.cum_table, (c.next_random >> 16) % c.cum_table[c.cum_table_len-1], 0, c.cum_table_len)
3150 */
3151 __pyx_v_label = __pyx_v_6gensim_6models_14fasttext_inner_ONEF;
3152
3153 /* "gensim/models/fasttext_inner.pyx":270
3154 *
3155 * for d in range(c.negative+1):
3156 * if d == 0: # <<<<<<<<<<<<<<
3157 * target_index = word_index
3158 * label = ONEF
3159 */
3160 goto __pyx_L12;
3161 }
3162
3163 /* "gensim/models/fasttext_inner.pyx":274
3164 * label = ONEF
3165 * else:
3166 * target_index = bisect_left(c.cum_table, (c.next_random >> 16) % c.cum_table[c.cum_table_len-1], 0, c.cum_table_len) # <<<<<<<<<<<<<<
3167 * c.next_random = (c.next_random * <unsigned long long>25214903917ULL + 11) & modulo
3168 * if target_index == word_index:
3169 */
3170 /*else*/ {
3171 __pyx_v_target_index = __pyx_f_6gensim_6models_14word2vec_inner_bisect_left(__pyx_v_c->cum_table, ((__pyx_v_c->next_random >> 16) % (__pyx_v_c->cum_table[(__pyx_v_c->cum_table_len - 1)])), 0, __pyx_v_c->cum_table_len);
3172
3173 /* "gensim/models/fasttext_inner.pyx":275
3174 * else:
3175 * target_index = bisect_left(c.cum_table, (c.next_random >> 16) % c.cum_table[c.cum_table_len-1], 0, c.cum_table_len)
3176 * c.next_random = (c.next_random * <unsigned long long>25214903917ULL + 11) & modulo # <<<<<<<<<<<<<<
3177 * if target_index == word_index:
3178 * continue
3179 */
3180 __pyx_v_c->next_random = (((__pyx_v_c->next_random * ((unsigned PY_LONG_LONG)25214903917ULL)) + 11) & __pyx_v_modulo);
3181
3182 /* "gensim/models/fasttext_inner.pyx":276
3183 * target_index = bisect_left(c.cum_table, (c.next_random >> 16) % c.cum_table[c.cum_table_len-1], 0, c.cum_table_len)
3184 * c.next_random = (c.next_random * <unsigned long long>25214903917ULL + 11) & modulo
3185 * if target_index == word_index: # <<<<<<<<<<<<<<
3186 * continue
3187 * label = <REAL_t>0.0
3188 */
3189 __pyx_t_4 = ((__pyx_v_target_index == __pyx_v_word_index) != 0);
3190 if (__pyx_t_4) {
3191
3192 /* "gensim/models/fasttext_inner.pyx":277
3193 * c.next_random = (c.next_random * <unsigned long long>25214903917ULL + 11) & modulo
3194 * if target_index == word_index:
3195 * continue # <<<<<<<<<<<<<<
3196 * label = <REAL_t>0.0
3197 *
3198 */
3199 goto __pyx_L10_continue;
3200
3201 /* "gensim/models/fasttext_inner.pyx":276
3202 * target_index = bisect_left(c.cum_table, (c.next_random >> 16) % c.cum_table[c.cum_table_len-1], 0, c.cum_table_len)
3203 * c.next_random = (c.next_random * <unsigned long long>25214903917ULL + 11) & modulo
3204 * if target_index == word_index: # <<<<<<<<<<<<<<
3205 * continue
3206 * label = <REAL_t>0.0
3207 */
3208 }
3209
3210 /* "gensim/models/fasttext_inner.pyx":278
3211 * if target_index == word_index:
3212 * continue
3213 * label = <REAL_t>0.0 # <<<<<<<<<<<<<<
3214 *
3215 * row2 = target_index * c.size
3216 */
3217 __pyx_v_label = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)0.0);
3218 }
3219 __pyx_L12:;
3220
3221 /* "gensim/models/fasttext_inner.pyx":280
3222 * label = <REAL_t>0.0
3223 *
3224 * row2 = target_index * c.size # <<<<<<<<<<<<<<
3225 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
3226 * if f_dot <= -MAX_EXP:
3227 */
3228 __pyx_v_row2 = (__pyx_v_target_index * __pyx_v_c->size);
3229
3230 /* "gensim/models/fasttext_inner.pyx":281
3231 *
3232 * row2 = target_index * c.size
3233 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1neg[row2], &ONE) # <<<<<<<<<<<<<<
3234 * if f_dot <= -MAX_EXP:
3235 * f = 0.0
3236 */
3237 __pyx_v_f_dot = __pyx_v_6gensim_6models_14word2vec_inner_our_dot((&__pyx_v_c->size), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn1neg[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3238
3239 /* "gensim/models/fasttext_inner.pyx":282
3240 * row2 = target_index * c.size
3241 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
3242 * if f_dot <= -MAX_EXP: # <<<<<<<<<<<<<<
3243 * f = 0.0
3244 * elif f_dot >= MAX_EXP:
3245 */
3246 __pyx_t_4 = ((__pyx_v_f_dot <= -8.0) != 0);
3247 if (__pyx_t_4) {
3248
3249 /* "gensim/models/fasttext_inner.pyx":283
3250 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
3251 * if f_dot <= -MAX_EXP:
3252 * f = 0.0 # <<<<<<<<<<<<<<
3253 * elif f_dot >= MAX_EXP:
3254 * f = 1.0
3255 */
3256 __pyx_v_f = 0.0;
3257
3258 /* "gensim/models/fasttext_inner.pyx":282
3259 * row2 = target_index * c.size
3260 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
3261 * if f_dot <= -MAX_EXP: # <<<<<<<<<<<<<<
3262 * f = 0.0
3263 * elif f_dot >= MAX_EXP:
3264 */
3265 goto __pyx_L14;
3266 }
3267
3268 /* "gensim/models/fasttext_inner.pyx":284
3269 * if f_dot <= -MAX_EXP:
3270 * f = 0.0
3271 * elif f_dot >= MAX_EXP: # <<<<<<<<<<<<<<
3272 * f = 1.0
3273 * else:
3274 */
3275 __pyx_t_4 = ((__pyx_v_f_dot >= 8.0) != 0);
3276 if (__pyx_t_4) {
3277
3278 /* "gensim/models/fasttext_inner.pyx":285
3279 * f = 0.0
3280 * elif f_dot >= MAX_EXP:
3281 * f = 1.0 # <<<<<<<<<<<<<<
3282 * else:
3283 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
3284 */
3285 __pyx_v_f = 1.0;
3286
3287 /* "gensim/models/fasttext_inner.pyx":284
3288 * if f_dot <= -MAX_EXP:
3289 * f = 0.0
3290 * elif f_dot >= MAX_EXP: # <<<<<<<<<<<<<<
3291 * f = 1.0
3292 * else:
3293 */
3294 goto __pyx_L14;
3295 }
3296
3297 /* "gensim/models/fasttext_inner.pyx":287
3298 * f = 1.0
3299 * else:
3300 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))] # <<<<<<<<<<<<<<
3301 * g = (label - f) * c.alpha
3302 *
3303 */
3304 /*else*/ {
3305 __pyx_v_f = (__pyx_v_6gensim_6models_14fasttext_inner_EXP_TABLE[((int)((__pyx_v_f_dot + 8.0) * 32.0))]);
3306 }
3307 __pyx_L14:;
3308
3309 /* "gensim/models/fasttext_inner.pyx":288
3310 * else:
3311 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
3312 * g = (label - f) * c.alpha # <<<<<<<<<<<<<<
3313 *
3314 * our_saxpy(&c.size, &g, &c.syn1neg[row2], &ONE, c.work, &ONE)
3315 */
3316 __pyx_v_g = ((__pyx_v_label - __pyx_v_f) * __pyx_v_c->alpha);
3317
3318 /* "gensim/models/fasttext_inner.pyx":290
3319 * g = (label - f) * c.alpha
3320 *
3321 * our_saxpy(&c.size, &g, &c.syn1neg[row2], &ONE, c.work, &ONE) # <<<<<<<<<<<<<<
3322 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
3323 *
3324 */
3325 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_g), (&(__pyx_v_c->syn1neg[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3326
3327 /* "gensim/models/fasttext_inner.pyx":291
3328 *
3329 * our_saxpy(&c.size, &g, &c.syn1neg[row2], &ONE, c.work, &ONE)
3330 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1neg[row2], &ONE) # <<<<<<<<<<<<<<
3331 *
3332 * if not c.cbow_mean: # divide error over summed window vectors
3333 */
3334 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_g), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn1neg[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3335 __pyx_L10_continue:;
3336 }
3337
3338 /* "gensim/models/fasttext_inner.pyx":293
3339 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
3340 *
3341 * if not c.cbow_mean: # divide error over summed window vectors # <<<<<<<<<<<<<<
3342 * sscal(&c.size, &inv_count, c.work, &ONE)
3343 *
3344 */
3345 __pyx_t_4 = ((!(__pyx_v_c->cbow_mean != 0)) != 0);
3346 if (__pyx_t_4) {
3347
3348 /* "gensim/models/fasttext_inner.pyx":294
3349 *
3350 * if not c.cbow_mean: # divide error over summed window vectors
3351 * sscal(&c.size, &inv_count, c.work, &ONE) # <<<<<<<<<<<<<<
3352 *
3353 * for m in range(j,k):
3354 */
3355 __pyx_v_6gensim_6models_14word2vec_inner_sscal((&__pyx_v_c->size), (&__pyx_v_inv_count), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3356
3357 /* "gensim/models/fasttext_inner.pyx":293
3358 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1neg[row2], &ONE)
3359 *
3360 * if not c.cbow_mean: # divide error over summed window vectors # <<<<<<<<<<<<<<
3361 * sscal(&c.size, &inv_count, c.work, &ONE)
3362 *
3363 */
3364 }
3365
3366 /* "gensim/models/fasttext_inner.pyx":296
3367 * sscal(&c.size, &inv_count, c.work, &ONE)
3368 *
3369 * for m in range(j,k): # <<<<<<<<<<<<<<
3370 * if m == i:
3371 * continue
3372 */
3373 __pyx_t_1 = __pyx_v_k;
3374 __pyx_t_2 = __pyx_t_1;
3375 for (__pyx_t_3 = __pyx_v_j; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
3376 __pyx_v_m = __pyx_t_3;
3377
3378 /* "gensim/models/fasttext_inner.pyx":297
3379 *
3380 * for m in range(j,k):
3381 * if m == i: # <<<<<<<<<<<<<<
3382 * continue
3383 * our_saxpy(
3384 */
3385 __pyx_t_4 = ((__pyx_v_m == __pyx_v_i) != 0);
3386 if (__pyx_t_4) {
3387
3388 /* "gensim/models/fasttext_inner.pyx":298
3389 * for m in range(j,k):
3390 * if m == i:
3391 * continue # <<<<<<<<<<<<<<
3392 * our_saxpy(
3393 * &c.size, &c.vocab_lockf[c.indexes[m] % c.vocab_lockf_len], c.work, &ONE,
3394 */
3395 goto __pyx_L16_continue;
3396
3397 /* "gensim/models/fasttext_inner.pyx":297
3398 *
3399 * for m in range(j,k):
3400 * if m == i: # <<<<<<<<<<<<<<
3401 * continue
3402 * our_saxpy(
3403 */
3404 }
3405
3406 /* "gensim/models/fasttext_inner.pyx":299
3407 * if m == i:
3408 * continue
3409 * our_saxpy( # <<<<<<<<<<<<<<
3410 * &c.size, &c.vocab_lockf[c.indexes[m] % c.vocab_lockf_len], c.work, &ONE,
3411 * &c.syn0_vocab[c.indexes[m]*c.size], &ONE)
3412 */
3413 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&(__pyx_v_c->vocab_lockf[((__pyx_v_c->indexes[__pyx_v_m]) % __pyx_v_c->vocab_lockf_len)])), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn0_vocab[((__pyx_v_c->indexes[__pyx_v_m]) * __pyx_v_c->size)])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3414
3415 /* "gensim/models/fasttext_inner.pyx":302
3416 * &c.size, &c.vocab_lockf[c.indexes[m] % c.vocab_lockf_len], c.work, &ONE,
3417 * &c.syn0_vocab[c.indexes[m]*c.size], &ONE)
3418 * for d in range(c.subwords_idx_len[m]): # <<<<<<<<<<<<<<
3419 * our_saxpy(
3420 * &c.size, &c.ngrams_lockf[c.subwords_idx[m][d] % c.ngrams_lockf_len], c.work, &ONE,
3421 */
3422 __pyx_t_5 = (__pyx_v_c->subwords_idx_len[__pyx_v_m]);
3423 __pyx_t_6 = __pyx_t_5;
3424 for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
3425 __pyx_v_d = __pyx_t_7;
3426
3427 /* "gensim/models/fasttext_inner.pyx":303
3428 * &c.syn0_vocab[c.indexes[m]*c.size], &ONE)
3429 * for d in range(c.subwords_idx_len[m]):
3430 * our_saxpy( # <<<<<<<<<<<<<<
3431 * &c.size, &c.ngrams_lockf[c.subwords_idx[m][d] % c.ngrams_lockf_len], c.work, &ONE,
3432 * &c.syn0_ngrams[c.subwords_idx[m][d]*c.size], &ONE)
3433 */
3434 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&(__pyx_v_c->ngrams_lockf[(((__pyx_v_c->subwords_idx[__pyx_v_m])[__pyx_v_d]) % __pyx_v_c->ngrams_lockf_len)])), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn0_ngrams[(((__pyx_v_c->subwords_idx[__pyx_v_m])[__pyx_v_d]) * __pyx_v_c->size)])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3435 }
3436 __pyx_L16_continue:;
3437 }
3438
3439 /* "gensim/models/fasttext_inner.pyx":223
3440 *
3441 *
3442 * cdef void fasttext_fast_sentence_cbow_neg(FastTextConfig *c, int i, int j, int k) nogil: # <<<<<<<<<<<<<<
3443 * """Perform CBOW training with negative sampling.
3444 *
3445 */
3446
3447 /* function exit code */
3448 }
3449
3450 /* "gensim/models/fasttext_inner.pyx":308
3451 *
3452 *
3453 * cdef void fasttext_fast_sentence_cbow_hs(FastTextConfig *c, int i, int j, int k) nogil: # <<<<<<<<<<<<<<
3454 * """Perform CBOW training with hierarchical sampling.
3455 *
3456 */
3457
__pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_cbow_hs(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig * __pyx_v_c,int __pyx_v_i,int __pyx_v_j,int __pyx_v_k)3458 static void __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_cbow_hs(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *__pyx_v_c, int __pyx_v_i, int __pyx_v_j, int __pyx_v_k) {
3459 __pyx_t_5numpy_uint32_t *__pyx_v_word_point;
3460 __pyx_t_5numpy_uint8_t *__pyx_v_word_code;
3461 PY_LONG_LONG __pyx_v_b;
3462 PY_LONG_LONG __pyx_v_row2;
3463 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_f;
3464 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_g;
3465 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_count;
3466 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_inv_count;
3467 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_v_f_dot;
3468 int __pyx_v_m;
3469 int __pyx_v_d;
3470 int __pyx_t_1;
3471 int __pyx_t_2;
3472 int __pyx_t_3;
3473 int __pyx_t_4;
3474 int __pyx_t_5;
3475 int __pyx_t_6;
3476 int __pyx_t_7;
3477 PY_LONG_LONG __pyx_t_8;
3478 int __pyx_t_9;
3479
3480 /* "gensim/models/fasttext_inner.pyx":325
3481 *
3482 * cdef:
3483 * np.uint32_t *word_point = c.points[i] # <<<<<<<<<<<<<<
3484 * np.uint8_t *word_code = c.codes[i]
3485 *
3486 */
3487 __pyx_v_word_point = (__pyx_v_c->points[__pyx_v_i]);
3488
3489 /* "gensim/models/fasttext_inner.pyx":326
3490 * cdef:
3491 * np.uint32_t *word_point = c.points[i]
3492 * np.uint8_t *word_code = c.codes[i] # <<<<<<<<<<<<<<
3493 *
3494 * cdef long long b
3495 */
3496 __pyx_v_word_code = (__pyx_v_c->codes[__pyx_v_i]);
3497
3498 /* "gensim/models/fasttext_inner.pyx":330
3499 * cdef long long b
3500 * cdef long long row2
3501 * cdef REAL_t f, g, count, inv_count = 1.0, f_dot # <<<<<<<<<<<<<<
3502 * cdef int m
3503 *
3504 */
3505 __pyx_v_inv_count = 1.0;
3506
3507 /* "gensim/models/fasttext_inner.pyx":333
3508 * cdef int m
3509 *
3510 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t)) # <<<<<<<<<<<<<<
3511 * count = <REAL_t>0.0
3512 * for m in range(j, k):
3513 */
3514 (void)(memset(__pyx_v_c->neu1, 0, (__pyx_v_c->size * (sizeof(__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)))));
3515
3516 /* "gensim/models/fasttext_inner.pyx":334
3517 *
3518 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t))
3519 * count = <REAL_t>0.0 # <<<<<<<<<<<<<<
3520 * for m in range(j, k):
3521 * if m == i:
3522 */
3523 __pyx_v_count = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)0.0);
3524
3525 /* "gensim/models/fasttext_inner.pyx":335
3526 * memset(c.neu1, 0, c.size * cython.sizeof(REAL_t))
3527 * count = <REAL_t>0.0
3528 * for m in range(j, k): # <<<<<<<<<<<<<<
3529 * if m == i:
3530 * continue
3531 */
3532 __pyx_t_1 = __pyx_v_k;
3533 __pyx_t_2 = __pyx_t_1;
3534 for (__pyx_t_3 = __pyx_v_j; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
3535 __pyx_v_m = __pyx_t_3;
3536
3537 /* "gensim/models/fasttext_inner.pyx":336
3538 * count = <REAL_t>0.0
3539 * for m in range(j, k):
3540 * if m == i: # <<<<<<<<<<<<<<
3541 * continue
3542 * count += ONEF
3543 */
3544 __pyx_t_4 = ((__pyx_v_m == __pyx_v_i) != 0);
3545 if (__pyx_t_4) {
3546
3547 /* "gensim/models/fasttext_inner.pyx":337
3548 * for m in range(j, k):
3549 * if m == i:
3550 * continue # <<<<<<<<<<<<<<
3551 * count += ONEF
3552 * our_saxpy(&c.size, &ONEF, &c.syn0_vocab[c.indexes[m] * c.size], &ONE, c.neu1, &ONE)
3553 */
3554 goto __pyx_L3_continue;
3555
3556 /* "gensim/models/fasttext_inner.pyx":336
3557 * count = <REAL_t>0.0
3558 * for m in range(j, k):
3559 * if m == i: # <<<<<<<<<<<<<<
3560 * continue
3561 * count += ONEF
3562 */
3563 }
3564
3565 /* "gensim/models/fasttext_inner.pyx":338
3566 * if m == i:
3567 * continue
3568 * count += ONEF # <<<<<<<<<<<<<<
3569 * our_saxpy(&c.size, &ONEF, &c.syn0_vocab[c.indexes[m] * c.size], &ONE, c.neu1, &ONE)
3570 * for d in range(c.subwords_idx_len[m]):
3571 */
3572 __pyx_v_count = (__pyx_v_count + __pyx_v_6gensim_6models_14fasttext_inner_ONEF);
3573
3574 /* "gensim/models/fasttext_inner.pyx":339
3575 * continue
3576 * count += ONEF
3577 * our_saxpy(&c.size, &ONEF, &c.syn0_vocab[c.indexes[m] * c.size], &ONE, c.neu1, &ONE) # <<<<<<<<<<<<<<
3578 * for d in range(c.subwords_idx_len[m]):
3579 * count += ONEF
3580 */
3581 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_6gensim_6models_14fasttext_inner_ONEF), (&(__pyx_v_c->syn0_vocab[((__pyx_v_c->indexes[__pyx_v_m]) * __pyx_v_c->size)])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3582
3583 /* "gensim/models/fasttext_inner.pyx":340
3584 * count += ONEF
3585 * our_saxpy(&c.size, &ONEF, &c.syn0_vocab[c.indexes[m] * c.size], &ONE, c.neu1, &ONE)
3586 * for d in range(c.subwords_idx_len[m]): # <<<<<<<<<<<<<<
3587 * count += ONEF
3588 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[c.subwords_idx[m][d] * c.size], &ONE, c.neu1, &ONE)
3589 */
3590 __pyx_t_5 = (__pyx_v_c->subwords_idx_len[__pyx_v_m]);
3591 __pyx_t_6 = __pyx_t_5;
3592 for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
3593 __pyx_v_d = __pyx_t_7;
3594
3595 /* "gensim/models/fasttext_inner.pyx":341
3596 * our_saxpy(&c.size, &ONEF, &c.syn0_vocab[c.indexes[m] * c.size], &ONE, c.neu1, &ONE)
3597 * for d in range(c.subwords_idx_len[m]):
3598 * count += ONEF # <<<<<<<<<<<<<<
3599 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[c.subwords_idx[m][d] * c.size], &ONE, c.neu1, &ONE)
3600 * if count > (<REAL_t>0.5):
3601 */
3602 __pyx_v_count = (__pyx_v_count + __pyx_v_6gensim_6models_14fasttext_inner_ONEF);
3603
3604 /* "gensim/models/fasttext_inner.pyx":342
3605 * for d in range(c.subwords_idx_len[m]):
3606 * count += ONEF
3607 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[c.subwords_idx[m][d] * c.size], &ONE, c.neu1, &ONE) # <<<<<<<<<<<<<<
3608 * if count > (<REAL_t>0.5):
3609 * inv_count = ONEF / count
3610 */
3611 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_6gensim_6models_14fasttext_inner_ONEF), (&(__pyx_v_c->syn0_ngrams[(((__pyx_v_c->subwords_idx[__pyx_v_m])[__pyx_v_d]) * __pyx_v_c->size)])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3612 }
3613 __pyx_L3_continue:;
3614 }
3615
3616 /* "gensim/models/fasttext_inner.pyx":343
3617 * count += ONEF
3618 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[c.subwords_idx[m][d] * c.size], &ONE, c.neu1, &ONE)
3619 * if count > (<REAL_t>0.5): # <<<<<<<<<<<<<<
3620 * inv_count = ONEF / count
3621 * if c.cbow_mean:
3622 */
3623 __pyx_t_4 = ((__pyx_v_count > ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)0.5)) != 0);
3624 if (__pyx_t_4) {
3625
3626 /* "gensim/models/fasttext_inner.pyx":344
3627 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[c.subwords_idx[m][d] * c.size], &ONE, c.neu1, &ONE)
3628 * if count > (<REAL_t>0.5):
3629 * inv_count = ONEF / count # <<<<<<<<<<<<<<
3630 * if c.cbow_mean:
3631 * sscal(&c.size, &inv_count, c.neu1, &ONE)
3632 */
3633 __pyx_v_inv_count = (__pyx_v_6gensim_6models_14fasttext_inner_ONEF / __pyx_v_count);
3634
3635 /* "gensim/models/fasttext_inner.pyx":343
3636 * count += ONEF
3637 * our_saxpy(&c.size, &ONEF, &c.syn0_ngrams[c.subwords_idx[m][d] * c.size], &ONE, c.neu1, &ONE)
3638 * if count > (<REAL_t>0.5): # <<<<<<<<<<<<<<
3639 * inv_count = ONEF / count
3640 * if c.cbow_mean:
3641 */
3642 }
3643
3644 /* "gensim/models/fasttext_inner.pyx":345
3645 * if count > (<REAL_t>0.5):
3646 * inv_count = ONEF / count
3647 * if c.cbow_mean: # <<<<<<<<<<<<<<
3648 * sscal(&c.size, &inv_count, c.neu1, &ONE)
3649 *
3650 */
3651 __pyx_t_4 = (__pyx_v_c->cbow_mean != 0);
3652 if (__pyx_t_4) {
3653
3654 /* "gensim/models/fasttext_inner.pyx":346
3655 * inv_count = ONEF / count
3656 * if c.cbow_mean:
3657 * sscal(&c.size, &inv_count, c.neu1, &ONE) # <<<<<<<<<<<<<<
3658 *
3659 * memset(c.work, 0, c.size * cython.sizeof(REAL_t))
3660 */
3661 __pyx_v_6gensim_6models_14word2vec_inner_sscal((&__pyx_v_c->size), (&__pyx_v_inv_count), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3662
3663 /* "gensim/models/fasttext_inner.pyx":345
3664 * if count > (<REAL_t>0.5):
3665 * inv_count = ONEF / count
3666 * if c.cbow_mean: # <<<<<<<<<<<<<<
3667 * sscal(&c.size, &inv_count, c.neu1, &ONE)
3668 *
3669 */
3670 }
3671
3672 /* "gensim/models/fasttext_inner.pyx":348
3673 * sscal(&c.size, &inv_count, c.neu1, &ONE)
3674 *
3675 * memset(c.work, 0, c.size * cython.sizeof(REAL_t)) # <<<<<<<<<<<<<<
3676 * for b in range(c.codelens[i]):
3677 * row2 = word_point[b] * c.size
3678 */
3679 (void)(memset(__pyx_v_c->work, 0, (__pyx_v_c->size * (sizeof(__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)))));
3680
3681 /* "gensim/models/fasttext_inner.pyx":349
3682 *
3683 * memset(c.work, 0, c.size * cython.sizeof(REAL_t))
3684 * for b in range(c.codelens[i]): # <<<<<<<<<<<<<<
3685 * row2 = word_point[b] * c.size
3686 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE)
3687 */
3688 __pyx_t_1 = (__pyx_v_c->codelens[__pyx_v_i]);
3689 __pyx_t_2 = __pyx_t_1;
3690 for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_2; __pyx_t_8+=1) {
3691 __pyx_v_b = __pyx_t_8;
3692
3693 /* "gensim/models/fasttext_inner.pyx":350
3694 * memset(c.work, 0, c.size * cython.sizeof(REAL_t))
3695 * for b in range(c.codelens[i]):
3696 * row2 = word_point[b] * c.size # <<<<<<<<<<<<<<
3697 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE)
3698 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
3699 */
3700 __pyx_v_row2 = ((__pyx_v_word_point[__pyx_v_b]) * __pyx_v_c->size);
3701
3702 /* "gensim/models/fasttext_inner.pyx":351
3703 * for b in range(c.codelens[i]):
3704 * row2 = word_point[b] * c.size
3705 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE) # <<<<<<<<<<<<<<
3706 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
3707 * continue
3708 */
3709 __pyx_v_f_dot = __pyx_v_6gensim_6models_14word2vec_inner_our_dot((&__pyx_v_c->size), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn1[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3710
3711 /* "gensim/models/fasttext_inner.pyx":352
3712 * row2 = word_point[b] * c.size
3713 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE)
3714 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP: # <<<<<<<<<<<<<<
3715 * continue
3716 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
3717 */
3718 __pyx_t_9 = ((__pyx_v_f_dot <= -8.0) != 0);
3719 if (!__pyx_t_9) {
3720 } else {
3721 __pyx_t_4 = __pyx_t_9;
3722 goto __pyx_L13_bool_binop_done;
3723 }
3724 __pyx_t_9 = ((__pyx_v_f_dot >= 8.0) != 0);
3725 __pyx_t_4 = __pyx_t_9;
3726 __pyx_L13_bool_binop_done:;
3727 if (__pyx_t_4) {
3728
3729 /* "gensim/models/fasttext_inner.pyx":353
3730 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE)
3731 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
3732 * continue # <<<<<<<<<<<<<<
3733 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
3734 * g = (1 - word_code[b] - f) * c.alpha
3735 */
3736 goto __pyx_L10_continue;
3737
3738 /* "gensim/models/fasttext_inner.pyx":352
3739 * row2 = word_point[b] * c.size
3740 * f_dot = our_dot(&c.size, c.neu1, &ONE, &c.syn1[row2], &ONE)
3741 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP: # <<<<<<<<<<<<<<
3742 * continue
3743 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
3744 */
3745 }
3746
3747 /* "gensim/models/fasttext_inner.pyx":354
3748 * if f_dot <= -MAX_EXP or f_dot >= MAX_EXP:
3749 * continue
3750 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))] # <<<<<<<<<<<<<<
3751 * g = (1 - word_code[b] - f) * c.alpha
3752 *
3753 */
3754 __pyx_v_f = (__pyx_v_6gensim_6models_14fasttext_inner_EXP_TABLE[((int)((__pyx_v_f_dot + 8.0) * 32.0))]);
3755
3756 /* "gensim/models/fasttext_inner.pyx":355
3757 * continue
3758 * f = EXP_TABLE[<int>((f_dot + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
3759 * g = (1 - word_code[b] - f) * c.alpha # <<<<<<<<<<<<<<
3760 *
3761 * our_saxpy(&c.size, &g, &c.syn1[row2], &ONE, c.work, &ONE)
3762 */
3763 __pyx_v_g = (((1 - (__pyx_v_word_code[__pyx_v_b])) - __pyx_v_f) * __pyx_v_c->alpha);
3764
3765 /* "gensim/models/fasttext_inner.pyx":357
3766 * g = (1 - word_code[b] - f) * c.alpha
3767 *
3768 * our_saxpy(&c.size, &g, &c.syn1[row2], &ONE, c.work, &ONE) # <<<<<<<<<<<<<<
3769 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1[row2], &ONE)
3770 *
3771 */
3772 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_g), (&(__pyx_v_c->syn1[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3773
3774 /* "gensim/models/fasttext_inner.pyx":358
3775 *
3776 * our_saxpy(&c.size, &g, &c.syn1[row2], &ONE, c.work, &ONE)
3777 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1[row2], &ONE) # <<<<<<<<<<<<<<
3778 *
3779 * if not c.cbow_mean: # divide error over summed window vectors
3780 */
3781 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&__pyx_v_g), __pyx_v_c->neu1, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn1[__pyx_v_row2])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3782 __pyx_L10_continue:;
3783 }
3784
3785 /* "gensim/models/fasttext_inner.pyx":360
3786 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1[row2], &ONE)
3787 *
3788 * if not c.cbow_mean: # divide error over summed window vectors # <<<<<<<<<<<<<<
3789 * sscal(&c.size, &inv_count, c.work, &ONE)
3790 *
3791 */
3792 __pyx_t_4 = ((!(__pyx_v_c->cbow_mean != 0)) != 0);
3793 if (__pyx_t_4) {
3794
3795 /* "gensim/models/fasttext_inner.pyx":361
3796 *
3797 * if not c.cbow_mean: # divide error over summed window vectors
3798 * sscal(&c.size, &inv_count, c.work, &ONE) # <<<<<<<<<<<<<<
3799 *
3800 * for m in range(j,k):
3801 */
3802 __pyx_v_6gensim_6models_14word2vec_inner_sscal((&__pyx_v_c->size), (&__pyx_v_inv_count), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3803
3804 /* "gensim/models/fasttext_inner.pyx":360
3805 * our_saxpy(&c.size, &g, c.neu1, &ONE, &c.syn1[row2], &ONE)
3806 *
3807 * if not c.cbow_mean: # divide error over summed window vectors # <<<<<<<<<<<<<<
3808 * sscal(&c.size, &inv_count, c.work, &ONE)
3809 *
3810 */
3811 }
3812
3813 /* "gensim/models/fasttext_inner.pyx":363
3814 * sscal(&c.size, &inv_count, c.work, &ONE)
3815 *
3816 * for m in range(j,k): # <<<<<<<<<<<<<<
3817 * if m == i:
3818 * continue
3819 */
3820 __pyx_t_1 = __pyx_v_k;
3821 __pyx_t_2 = __pyx_t_1;
3822 for (__pyx_t_3 = __pyx_v_j; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
3823 __pyx_v_m = __pyx_t_3;
3824
3825 /* "gensim/models/fasttext_inner.pyx":364
3826 *
3827 * for m in range(j,k):
3828 * if m == i: # <<<<<<<<<<<<<<
3829 * continue
3830 * our_saxpy(
3831 */
3832 __pyx_t_4 = ((__pyx_v_m == __pyx_v_i) != 0);
3833 if (__pyx_t_4) {
3834
3835 /* "gensim/models/fasttext_inner.pyx":365
3836 * for m in range(j,k):
3837 * if m == i:
3838 * continue # <<<<<<<<<<<<<<
3839 * our_saxpy(
3840 * &c.size, &c.vocab_lockf[c.indexes[m] % c.vocab_lockf_len], c.work, &ONE,
3841 */
3842 goto __pyx_L16_continue;
3843
3844 /* "gensim/models/fasttext_inner.pyx":364
3845 *
3846 * for m in range(j,k):
3847 * if m == i: # <<<<<<<<<<<<<<
3848 * continue
3849 * our_saxpy(
3850 */
3851 }
3852
3853 /* "gensim/models/fasttext_inner.pyx":366
3854 * if m == i:
3855 * continue
3856 * our_saxpy( # <<<<<<<<<<<<<<
3857 * &c.size, &c.vocab_lockf[c.indexes[m] % c.vocab_lockf_len], c.work, &ONE,
3858 * &c.syn0_vocab[c.indexes[m]*c.size], &ONE)
3859 */
3860 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&(__pyx_v_c->vocab_lockf[((__pyx_v_c->indexes[__pyx_v_m]) % __pyx_v_c->vocab_lockf_len)])), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn0_vocab[((__pyx_v_c->indexes[__pyx_v_m]) * __pyx_v_c->size)])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3861
3862 /* "gensim/models/fasttext_inner.pyx":369
3863 * &c.size, &c.vocab_lockf[c.indexes[m] % c.vocab_lockf_len], c.work, &ONE,
3864 * &c.syn0_vocab[c.indexes[m]*c.size], &ONE)
3865 * for d in range(c.subwords_idx_len[m]): # <<<<<<<<<<<<<<
3866 * our_saxpy(
3867 * &c.size, &c.ngrams_lockf[c.subwords_idx[m][d] % c.ngrams_lockf_len], c.work, &ONE,
3868 */
3869 __pyx_t_5 = (__pyx_v_c->subwords_idx_len[__pyx_v_m]);
3870 __pyx_t_6 = __pyx_t_5;
3871 for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
3872 __pyx_v_d = __pyx_t_7;
3873
3874 /* "gensim/models/fasttext_inner.pyx":370
3875 * &c.syn0_vocab[c.indexes[m]*c.size], &ONE)
3876 * for d in range(c.subwords_idx_len[m]):
3877 * our_saxpy( # <<<<<<<<<<<<<<
3878 * &c.size, &c.ngrams_lockf[c.subwords_idx[m][d] % c.ngrams_lockf_len], c.work, &ONE,
3879 * &c.syn0_ngrams[c.subwords_idx[m][d]*c.size], &ONE)
3880 */
3881 __pyx_v_6gensim_6models_14word2vec_inner_our_saxpy((&__pyx_v_c->size), (&(__pyx_v_c->ngrams_lockf[(((__pyx_v_c->subwords_idx[__pyx_v_m])[__pyx_v_d]) % __pyx_v_c->ngrams_lockf_len)])), __pyx_v_c->work, (&__pyx_v_6gensim_6models_14fasttext_inner_ONE), (&(__pyx_v_c->syn0_ngrams[(((__pyx_v_c->subwords_idx[__pyx_v_m])[__pyx_v_d]) * __pyx_v_c->size)])), (&__pyx_v_6gensim_6models_14fasttext_inner_ONE));
3882 }
3883 __pyx_L16_continue:;
3884 }
3885
3886 /* "gensim/models/fasttext_inner.pyx":308
3887 *
3888 *
3889 * cdef void fasttext_fast_sentence_cbow_hs(FastTextConfig *c, int i, int j, int k) nogil: # <<<<<<<<<<<<<<
3890 * """Perform CBOW training with hierarchical sampling.
3891 *
3892 */
3893
3894 /* function exit code */
3895 }
3896
3897 /* "gensim/models/fasttext_inner.pyx":375
3898 *
3899 *
3900 * cdef void init_ft_config(FastTextConfig *c, model, alpha, _work, _neu1): # <<<<<<<<<<<<<<
3901 * """Load model parameters into a FastTextConfig struct.
3902 *
3903 */
3904
__pyx_f_6gensim_6models_14fasttext_inner_init_ft_config(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig * __pyx_v_c,PyObject * __pyx_v_model,PyObject * __pyx_v_alpha,PyObject * __pyx_v__work,PyObject * __pyx_v__neu1)3905 static void __pyx_f_6gensim_6models_14fasttext_inner_init_ft_config(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *__pyx_v_c, PyObject *__pyx_v_model, PyObject *__pyx_v_alpha, PyObject *__pyx_v__work, PyObject *__pyx_v__neu1) {
3906 __Pyx_RefNannyDeclarations
3907 PyObject *__pyx_t_1 = NULL;
3908 int __pyx_t_2;
3909 PyObject *__pyx_t_3 = NULL;
3910 Py_ssize_t __pyx_t_4;
3911 __pyx_t_6gensim_6models_14word2vec_inner_REAL_t __pyx_t_5;
3912 int __pyx_t_6;
3913 int __pyx_t_7;
3914 PyObject *__pyx_t_8 = NULL;
3915 unsigned PY_LONG_LONG __pyx_t_9;
3916 int __pyx_lineno = 0;
3917 const char *__pyx_filename = NULL;
3918 int __pyx_clineno = 0;
3919 __Pyx_RefNannySetupContext("init_ft_config", 0);
3920
3921 /* "gensim/models/fasttext_inner.pyx":394
3922 *
3923 * """
3924 * c.sg = model.sg # <<<<<<<<<<<<<<
3925 * c.hs = model.hs
3926 * c.negative = model.negative
3927 */
3928 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_sg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 394, __pyx_L1_error)
3929 __Pyx_GOTREF(__pyx_t_1);
3930 __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 394, __pyx_L1_error)
3931 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3932 __pyx_v_c->sg = __pyx_t_2;
3933
3934 /* "gensim/models/fasttext_inner.pyx":395
3935 * """
3936 * c.sg = model.sg
3937 * c.hs = model.hs # <<<<<<<<<<<<<<
3938 * c.negative = model.negative
3939 * c.sample = (model.sample != 0)
3940 */
3941 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_hs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 395, __pyx_L1_error)
3942 __Pyx_GOTREF(__pyx_t_1);
3943 __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L1_error)
3944 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3945 __pyx_v_c->hs = __pyx_t_2;
3946
3947 /* "gensim/models/fasttext_inner.pyx":396
3948 * c.sg = model.sg
3949 * c.hs = model.hs
3950 * c.negative = model.negative # <<<<<<<<<<<<<<
3951 * c.sample = (model.sample != 0)
3952 * c.cbow_mean = model.cbow_mean
3953 */
3954 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_negative); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
3955 __Pyx_GOTREF(__pyx_t_1);
3956 __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 396, __pyx_L1_error)
3957 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3958 __pyx_v_c->negative = __pyx_t_2;
3959
3960 /* "gensim/models/fasttext_inner.pyx":397
3961 * c.hs = model.hs
3962 * c.negative = model.negative
3963 * c.sample = (model.sample != 0) # <<<<<<<<<<<<<<
3964 * c.cbow_mean = model.cbow_mean
3965 * c.window = model.window
3966 */
3967 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_sample); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 397, __pyx_L1_error)
3968 __Pyx_GOTREF(__pyx_t_1);
3969 __pyx_t_3 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 397, __pyx_L1_error)
3970 __Pyx_GOTREF(__pyx_t_3);
3971 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3972 __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 397, __pyx_L1_error)
3973 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3974 __pyx_v_c->sample = __pyx_t_2;
3975
3976 /* "gensim/models/fasttext_inner.pyx":398
3977 * c.negative = model.negative
3978 * c.sample = (model.sample != 0)
3979 * c.cbow_mean = model.cbow_mean # <<<<<<<<<<<<<<
3980 * c.window = model.window
3981 * c.workers = model.workers
3982 */
3983 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_cbow_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L1_error)
3984 __Pyx_GOTREF(__pyx_t_3);
3985 __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 398, __pyx_L1_error)
3986 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3987 __pyx_v_c->cbow_mean = __pyx_t_2;
3988
3989 /* "gensim/models/fasttext_inner.pyx":399
3990 * c.sample = (model.sample != 0)
3991 * c.cbow_mean = model.cbow_mean
3992 * c.window = model.window # <<<<<<<<<<<<<<
3993 * c.workers = model.workers
3994 *
3995 */
3996 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_window); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 399, __pyx_L1_error)
3997 __Pyx_GOTREF(__pyx_t_3);
3998 __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 399, __pyx_L1_error)
3999 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4000 __pyx_v_c->window = __pyx_t_2;
4001
4002 /* "gensim/models/fasttext_inner.pyx":400
4003 * c.cbow_mean = model.cbow_mean
4004 * c.window = model.window
4005 * c.workers = model.workers # <<<<<<<<<<<<<<
4006 *
4007 * c.syn0_vocab = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_vocab))
4008 */
4009 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_workers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 400, __pyx_L1_error)
4010 __Pyx_GOTREF(__pyx_t_3);
4011 __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error)
4012 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4013 __pyx_v_c->workers = __pyx_t_2;
4014
4015 /* "gensim/models/fasttext_inner.pyx":402
4016 * c.workers = model.workers
4017 *
4018 * c.syn0_vocab = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_vocab)) # <<<<<<<<<<<<<<
4019 * c.syn0_ngrams = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_ngrams))
4020 *
4021 */
4022 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_wv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 402, __pyx_L1_error)
4023 __Pyx_GOTREF(__pyx_t_3);
4024 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_vectors_vocab); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error)
4025 __Pyx_GOTREF(__pyx_t_1);
4026 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4027 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 402, __pyx_L1_error)
4028 __pyx_v_c->syn0_vocab = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t *)PyArray_DATA(((PyArrayObject *)__pyx_t_1)));
4029 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4030
4031 /* "gensim/models/fasttext_inner.pyx":403
4032 *
4033 * c.syn0_vocab = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_vocab))
4034 * c.syn0_ngrams = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_ngrams)) # <<<<<<<<<<<<<<
4035 *
4036 * # EXPERIMENTAL lockf scaled suppression/enablement of training
4037 */
4038 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_wv); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error)
4039 __Pyx_GOTREF(__pyx_t_1);
4040 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_vectors_ngrams); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error)
4041 __Pyx_GOTREF(__pyx_t_3);
4042 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4043 if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 403, __pyx_L1_error)
4044 __pyx_v_c->syn0_ngrams = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t *)PyArray_DATA(((PyArrayObject *)__pyx_t_3)));
4045 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4046
4047 /* "gensim/models/fasttext_inner.pyx":406
4048 *
4049 * # EXPERIMENTAL lockf scaled suppression/enablement of training
4050 * c.vocab_lockf = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_vocab_lockf)) # <<<<<<<<<<<<<<
4051 * c.vocab_lockf_len = len(model.wv.vectors_vocab_lockf)
4052 * c.ngrams_lockf = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_ngrams_lockf))
4053 */
4054 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_wv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 406, __pyx_L1_error)
4055 __Pyx_GOTREF(__pyx_t_3);
4056 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_vectors_vocab_lockf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 406, __pyx_L1_error)
4057 __Pyx_GOTREF(__pyx_t_1);
4058 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4059 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 406, __pyx_L1_error)
4060 __pyx_v_c->vocab_lockf = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t *)PyArray_DATA(((PyArrayObject *)__pyx_t_1)));
4061 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4062
4063 /* "gensim/models/fasttext_inner.pyx":407
4064 * # EXPERIMENTAL lockf scaled suppression/enablement of training
4065 * c.vocab_lockf = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_vocab_lockf))
4066 * c.vocab_lockf_len = len(model.wv.vectors_vocab_lockf) # <<<<<<<<<<<<<<
4067 * c.ngrams_lockf = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_ngrams_lockf))
4068 * c.ngrams_lockf_len = len(model.wv.vectors_ngrams_lockf)
4069 */
4070 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_wv); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 407, __pyx_L1_error)
4071 __Pyx_GOTREF(__pyx_t_1);
4072 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_vectors_vocab_lockf); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error)
4073 __Pyx_GOTREF(__pyx_t_3);
4074 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4075 __pyx_t_4 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 407, __pyx_L1_error)
4076 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4077 __pyx_v_c->vocab_lockf_len = __pyx_t_4;
4078
4079 /* "gensim/models/fasttext_inner.pyx":408
4080 * c.vocab_lockf = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_vocab_lockf))
4081 * c.vocab_lockf_len = len(model.wv.vectors_vocab_lockf)
4082 * c.ngrams_lockf = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_ngrams_lockf)) # <<<<<<<<<<<<<<
4083 * c.ngrams_lockf_len = len(model.wv.vectors_ngrams_lockf)
4084 *
4085 */
4086 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_wv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 408, __pyx_L1_error)
4087 __Pyx_GOTREF(__pyx_t_3);
4088 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_vectors_ngrams_lockf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 408, __pyx_L1_error)
4089 __Pyx_GOTREF(__pyx_t_1);
4090 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4091 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 408, __pyx_L1_error)
4092 __pyx_v_c->ngrams_lockf = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t *)PyArray_DATA(((PyArrayObject *)__pyx_t_1)));
4093 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4094
4095 /* "gensim/models/fasttext_inner.pyx":409
4096 * c.vocab_lockf_len = len(model.wv.vectors_vocab_lockf)
4097 * c.ngrams_lockf = <REAL_t *>(np.PyArray_DATA(model.wv.vectors_ngrams_lockf))
4098 * c.ngrams_lockf_len = len(model.wv.vectors_ngrams_lockf) # <<<<<<<<<<<<<<
4099 *
4100 * c.alpha = alpha
4101 */
4102 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_wv); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __pyx_L1_error)
4103 __Pyx_GOTREF(__pyx_t_1);
4104 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_vectors_ngrams_lockf); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error)
4105 __Pyx_GOTREF(__pyx_t_3);
4106 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4107 __pyx_t_4 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 409, __pyx_L1_error)
4108 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4109 __pyx_v_c->ngrams_lockf_len = __pyx_t_4;
4110
4111 /* "gensim/models/fasttext_inner.pyx":411
4112 * c.ngrams_lockf_len = len(model.wv.vectors_ngrams_lockf)
4113 *
4114 * c.alpha = alpha # <<<<<<<<<<<<<<
4115 * c.size = model.wv.vector_size
4116 *
4117 */
4118 __pyx_t_5 = __pyx_PyFloat_AsFloat(__pyx_v_alpha); if (unlikely((__pyx_t_5 == ((npy_float32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 411, __pyx_L1_error)
4119 __pyx_v_c->alpha = __pyx_t_5;
4120
4121 /* "gensim/models/fasttext_inner.pyx":412
4122 *
4123 * c.alpha = alpha
4124 * c.size = model.wv.vector_size # <<<<<<<<<<<<<<
4125 *
4126 * if c.hs:
4127 */
4128 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_wv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 412, __pyx_L1_error)
4129 __Pyx_GOTREF(__pyx_t_3);
4130 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_vector_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error)
4131 __Pyx_GOTREF(__pyx_t_1);
4132 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4133 __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 412, __pyx_L1_error)
4134 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4135 __pyx_v_c->size = __pyx_t_2;
4136
4137 /* "gensim/models/fasttext_inner.pyx":414
4138 * c.size = model.wv.vector_size
4139 *
4140 * if c.hs: # <<<<<<<<<<<<<<
4141 * c.syn1 = <REAL_t *>(np.PyArray_DATA(model.syn1))
4142 *
4143 */
4144 __pyx_t_6 = (__pyx_v_c->hs != 0);
4145 if (__pyx_t_6) {
4146
4147 /* "gensim/models/fasttext_inner.pyx":415
4148 *
4149 * if c.hs:
4150 * c.syn1 = <REAL_t *>(np.PyArray_DATA(model.syn1)) # <<<<<<<<<<<<<<
4151 *
4152 * if c.negative:
4153 */
4154 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_syn1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 415, __pyx_L1_error)
4155 __Pyx_GOTREF(__pyx_t_1);
4156 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 415, __pyx_L1_error)
4157 __pyx_v_c->syn1 = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t *)PyArray_DATA(((PyArrayObject *)__pyx_t_1)));
4158 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4159
4160 /* "gensim/models/fasttext_inner.pyx":414
4161 * c.size = model.wv.vector_size
4162 *
4163 * if c.hs: # <<<<<<<<<<<<<<
4164 * c.syn1 = <REAL_t *>(np.PyArray_DATA(model.syn1))
4165 *
4166 */
4167 }
4168
4169 /* "gensim/models/fasttext_inner.pyx":417
4170 * c.syn1 = <REAL_t *>(np.PyArray_DATA(model.syn1))
4171 *
4172 * if c.negative: # <<<<<<<<<<<<<<
4173 * c.syn1neg = <REAL_t *>(np.PyArray_DATA(model.syn1neg))
4174 * c.cum_table = <np.uint32_t *>(np.PyArray_DATA(model.cum_table))
4175 */
4176 __pyx_t_6 = (__pyx_v_c->negative != 0);
4177 if (__pyx_t_6) {
4178
4179 /* "gensim/models/fasttext_inner.pyx":418
4180 *
4181 * if c.negative:
4182 * c.syn1neg = <REAL_t *>(np.PyArray_DATA(model.syn1neg)) # <<<<<<<<<<<<<<
4183 * c.cum_table = <np.uint32_t *>(np.PyArray_DATA(model.cum_table))
4184 * c.cum_table_len = len(model.cum_table)
4185 */
4186 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_syn1neg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error)
4187 __Pyx_GOTREF(__pyx_t_1);
4188 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 418, __pyx_L1_error)
4189 __pyx_v_c->syn1neg = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t *)PyArray_DATA(((PyArrayObject *)__pyx_t_1)));
4190 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4191
4192 /* "gensim/models/fasttext_inner.pyx":419
4193 * if c.negative:
4194 * c.syn1neg = <REAL_t *>(np.PyArray_DATA(model.syn1neg))
4195 * c.cum_table = <np.uint32_t *>(np.PyArray_DATA(model.cum_table)) # <<<<<<<<<<<<<<
4196 * c.cum_table_len = len(model.cum_table)
4197 * if c.negative or c.sample:
4198 */
4199 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_cum_table); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 419, __pyx_L1_error)
4200 __Pyx_GOTREF(__pyx_t_1);
4201 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 419, __pyx_L1_error)
4202 __pyx_v_c->cum_table = ((__pyx_t_5numpy_uint32_t *)PyArray_DATA(((PyArrayObject *)__pyx_t_1)));
4203 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4204
4205 /* "gensim/models/fasttext_inner.pyx":420
4206 * c.syn1neg = <REAL_t *>(np.PyArray_DATA(model.syn1neg))
4207 * c.cum_table = <np.uint32_t *>(np.PyArray_DATA(model.cum_table))
4208 * c.cum_table_len = len(model.cum_table) # <<<<<<<<<<<<<<
4209 * if c.negative or c.sample:
4210 * c.next_random = (2**24) * model.random.randint(0, 2**24) + model.random.randint(0, 2**24)
4211 */
4212 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_cum_table); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error)
4213 __Pyx_GOTREF(__pyx_t_1);
4214 __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 420, __pyx_L1_error)
4215 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4216 __pyx_v_c->cum_table_len = __pyx_t_4;
4217
4218 /* "gensim/models/fasttext_inner.pyx":417
4219 * c.syn1 = <REAL_t *>(np.PyArray_DATA(model.syn1))
4220 *
4221 * if c.negative: # <<<<<<<<<<<<<<
4222 * c.syn1neg = <REAL_t *>(np.PyArray_DATA(model.syn1neg))
4223 * c.cum_table = <np.uint32_t *>(np.PyArray_DATA(model.cum_table))
4224 */
4225 }
4226
4227 /* "gensim/models/fasttext_inner.pyx":421
4228 * c.cum_table = <np.uint32_t *>(np.PyArray_DATA(model.cum_table))
4229 * c.cum_table_len = len(model.cum_table)
4230 * if c.negative or c.sample: # <<<<<<<<<<<<<<
4231 * c.next_random = (2**24) * model.random.randint(0, 2**24) + model.random.randint(0, 2**24)
4232 *
4233 */
4234 __pyx_t_7 = (__pyx_v_c->negative != 0);
4235 if (!__pyx_t_7) {
4236 } else {
4237 __pyx_t_6 = __pyx_t_7;
4238 goto __pyx_L6_bool_binop_done;
4239 }
4240 __pyx_t_7 = (__pyx_v_c->sample != 0);
4241 __pyx_t_6 = __pyx_t_7;
4242 __pyx_L6_bool_binop_done:;
4243 if (__pyx_t_6) {
4244
4245 /* "gensim/models/fasttext_inner.pyx":422
4246 * c.cum_table_len = len(model.cum_table)
4247 * if c.negative or c.sample:
4248 * c.next_random = (2**24) * model.random.randint(0, 2**24) + model.random.randint(0, 2**24) # <<<<<<<<<<<<<<
4249 *
4250 * # convert Python structures to primitive types, so we can release the GIL
4251 */
4252 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error)
4253 __Pyx_GOTREF(__pyx_t_1);
4254 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_randint); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error)
4255 __Pyx_GOTREF(__pyx_t_3);
4256 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4257 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error)
4258 __Pyx_GOTREF(__pyx_t_1);
4259 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4260 __pyx_t_3 = PyNumber_Multiply(__pyx_int_16777216, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error)
4261 __Pyx_GOTREF(__pyx_t_3);
4262 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4263 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error)
4264 __Pyx_GOTREF(__pyx_t_1);
4265 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_randint); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 422, __pyx_L1_error)
4266 __Pyx_GOTREF(__pyx_t_8);
4267 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4268 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error)
4269 __Pyx_GOTREF(__pyx_t_1);
4270 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4271 __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 422, __pyx_L1_error)
4272 __Pyx_GOTREF(__pyx_t_8);
4273 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4274 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4275 __pyx_t_9 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_8); if (unlikely((__pyx_t_9 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 422, __pyx_L1_error)
4276 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4277 __pyx_v_c->next_random = __pyx_t_9;
4278
4279 /* "gensim/models/fasttext_inner.pyx":421
4280 * c.cum_table = <np.uint32_t *>(np.PyArray_DATA(model.cum_table))
4281 * c.cum_table_len = len(model.cum_table)
4282 * if c.negative or c.sample: # <<<<<<<<<<<<<<
4283 * c.next_random = (2**24) * model.random.randint(0, 2**24) + model.random.randint(0, 2**24)
4284 *
4285 */
4286 }
4287
4288 /* "gensim/models/fasttext_inner.pyx":425
4289 *
4290 * # convert Python structures to primitive types, so we can release the GIL
4291 * c.work = <REAL_t *>np.PyArray_DATA(_work) # <<<<<<<<<<<<<<
4292 * c.neu1 = <REAL_t *>np.PyArray_DATA(_neu1)
4293 *
4294 */
4295 if (!(likely(((__pyx_v__work) == Py_None) || likely(__Pyx_TypeTest(__pyx_v__work, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 425, __pyx_L1_error)
4296 __pyx_v_c->work = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t *)PyArray_DATA(((PyArrayObject *)__pyx_v__work)));
4297
4298 /* "gensim/models/fasttext_inner.pyx":426
4299 * # convert Python structures to primitive types, so we can release the GIL
4300 * c.work = <REAL_t *>np.PyArray_DATA(_work)
4301 * c.neu1 = <REAL_t *>np.PyArray_DATA(_neu1) # <<<<<<<<<<<<<<
4302 *
4303 *
4304 */
4305 if (!(likely(((__pyx_v__neu1) == Py_None) || likely(__Pyx_TypeTest(__pyx_v__neu1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 426, __pyx_L1_error)
4306 __pyx_v_c->neu1 = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t *)PyArray_DATA(((PyArrayObject *)__pyx_v__neu1)));
4307
4308 /* "gensim/models/fasttext_inner.pyx":375
4309 *
4310 *
4311 * cdef void init_ft_config(FastTextConfig *c, model, alpha, _work, _neu1): # <<<<<<<<<<<<<<
4312 * """Load model parameters into a FastTextConfig struct.
4313 *
4314 */
4315
4316 /* function exit code */
4317 goto __pyx_L0;
4318 __pyx_L1_error:;
4319 __Pyx_XDECREF(__pyx_t_1);
4320 __Pyx_XDECREF(__pyx_t_3);
4321 __Pyx_XDECREF(__pyx_t_8);
4322 __Pyx_WriteUnraisable("gensim.models.fasttext_inner.init_ft_config", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
4323 __pyx_L0:;
4324 __Pyx_RefNannyFinishContext();
4325 }
4326
4327 /* "gensim/models/fasttext_inner.pyx":429
4328 *
4329 *
4330 * cdef object populate_ft_config(FastTextConfig *c, wv, buckets_word, sentences): # <<<<<<<<<<<<<<
4331 * """Prepare C structures so we can go "full C" and release the Python GIL.
4332 *
4333 */
4334
__pyx_f_6gensim_6models_14fasttext_inner_populate_ft_config(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig * __pyx_v_c,PyObject * __pyx_v_wv,PyObject * __pyx_v_buckets_word,PyObject * __pyx_v_sentences)4335 static PyObject *__pyx_f_6gensim_6models_14fasttext_inner_populate_ft_config(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *__pyx_v_c, PyObject *__pyx_v_wv, PyObject *__pyx_v_buckets_word, PyObject *__pyx_v_sentences) {
4336 int __pyx_v_effective_words;
4337 int __pyx_v_effective_sentences;
4338 __pyx_t_5numpy_uint32_t *__pyx_v_vocab_sample_ints;
4339 PyObject *__pyx_v_vocab_codes = NULL;
4340 PyObject *__pyx_v_vocab_points = NULL;
4341 PyObject *__pyx_v_sent = NULL;
4342 PyObject *__pyx_v_token = NULL;
4343 PyObject *__pyx_v_word_index = NULL;
4344 PyObject *__pyx_r = NULL;
4345 __Pyx_RefNannyDeclarations
4346 int __pyx_t_1;
4347 PyObject *__pyx_t_2 = NULL;
4348 PyObject *__pyx_t_3 = NULL;
4349 Py_ssize_t __pyx_t_4;
4350 PyObject *(*__pyx_t_5)(PyObject *);
4351 int __pyx_t_6;
4352 Py_ssize_t __pyx_t_7;
4353 PyObject *(*__pyx_t_8)(PyObject *);
4354 PyObject *__pyx_t_9 = NULL;
4355 PyObject *__pyx_t_10 = NULL;
4356 PyObject *__pyx_t_11 = NULL;
4357 int __pyx_t_12;
4358 PyObject *__pyx_t_13 = NULL;
4359 Py_ssize_t __pyx_t_14;
4360 __pyx_t_5numpy_uint32_t __pyx_t_15;
4361 int __pyx_lineno = 0;
4362 const char *__pyx_filename = NULL;
4363 int __pyx_clineno = 0;
4364 __Pyx_RefNannySetupContext("populate_ft_config", 0);
4365
4366 /* "gensim/models/fasttext_inner.pyx":465
4367 *
4368 * """
4369 * cdef int effective_words = 0 # <<<<<<<<<<<<<<
4370 * cdef int effective_sentences = 0
4371 * cdef np.uint32_t *vocab_sample_ints
4372 */
4373 __pyx_v_effective_words = 0;
4374
4375 /* "gensim/models/fasttext_inner.pyx":466
4376 * """
4377 * cdef int effective_words = 0
4378 * cdef int effective_sentences = 0 # <<<<<<<<<<<<<<
4379 * cdef np.uint32_t *vocab_sample_ints
4380 * c.sentence_idx[0] = 0 # indices of the first sentence always start at 0
4381 */
4382 __pyx_v_effective_sentences = 0;
4383
4384 /* "gensim/models/fasttext_inner.pyx":468
4385 * cdef int effective_sentences = 0
4386 * cdef np.uint32_t *vocab_sample_ints
4387 * c.sentence_idx[0] = 0 # indices of the first sentence always start at 0 # <<<<<<<<<<<<<<
4388 *
4389 * if c.sample:
4390 */
4391 (__pyx_v_c->sentence_idx[0]) = 0;
4392
4393 /* "gensim/models/fasttext_inner.pyx":470
4394 * c.sentence_idx[0] = 0 # indices of the first sentence always start at 0
4395 *
4396 * if c.sample: # <<<<<<<<<<<<<<
4397 * vocab_sample_ints = <np.uint32_t *>np.PyArray_DATA(wv.expandos['sample_int'])
4398 * if c.hs:
4399 */
4400 __pyx_t_1 = (__pyx_v_c->sample != 0);
4401 if (__pyx_t_1) {
4402
4403 /* "gensim/models/fasttext_inner.pyx":471
4404 *
4405 * if c.sample:
4406 * vocab_sample_ints = <np.uint32_t *>np.PyArray_DATA(wv.expandos['sample_int']) # <<<<<<<<<<<<<<
4407 * if c.hs:
4408 * vocab_codes = wv.expandos['code']
4409 */
4410 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_wv, __pyx_n_s_expandos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error)
4411 __Pyx_GOTREF(__pyx_t_2);
4412 __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_2, __pyx_n_s_sample_int); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 471, __pyx_L1_error)
4413 __Pyx_GOTREF(__pyx_t_3);
4414 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4415 if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 471, __pyx_L1_error)
4416 __pyx_v_vocab_sample_ints = ((__pyx_t_5numpy_uint32_t *)PyArray_DATA(((PyArrayObject *)__pyx_t_3)));
4417 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4418
4419 /* "gensim/models/fasttext_inner.pyx":470
4420 * c.sentence_idx[0] = 0 # indices of the first sentence always start at 0
4421 *
4422 * if c.sample: # <<<<<<<<<<<<<<
4423 * vocab_sample_ints = <np.uint32_t *>np.PyArray_DATA(wv.expandos['sample_int'])
4424 * if c.hs:
4425 */
4426 }
4427
4428 /* "gensim/models/fasttext_inner.pyx":472
4429 * if c.sample:
4430 * vocab_sample_ints = <np.uint32_t *>np.PyArray_DATA(wv.expandos['sample_int'])
4431 * if c.hs: # <<<<<<<<<<<<<<
4432 * vocab_codes = wv.expandos['code']
4433 * vocab_points = wv.expandos['point']
4434 */
4435 __pyx_t_1 = (__pyx_v_c->hs != 0);
4436 if (__pyx_t_1) {
4437
4438 /* "gensim/models/fasttext_inner.pyx":473
4439 * vocab_sample_ints = <np.uint32_t *>np.PyArray_DATA(wv.expandos['sample_int'])
4440 * if c.hs:
4441 * vocab_codes = wv.expandos['code'] # <<<<<<<<<<<<<<
4442 * vocab_points = wv.expandos['point']
4443 * for sent in sentences:
4444 */
4445 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_wv, __pyx_n_s_expandos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 473, __pyx_L1_error)
4446 __Pyx_GOTREF(__pyx_t_3);
4447 __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_3, __pyx_n_s_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 473, __pyx_L1_error)
4448 __Pyx_GOTREF(__pyx_t_2);
4449 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4450 __pyx_v_vocab_codes = __pyx_t_2;
4451 __pyx_t_2 = 0;
4452
4453 /* "gensim/models/fasttext_inner.pyx":474
4454 * if c.hs:
4455 * vocab_codes = wv.expandos['code']
4456 * vocab_points = wv.expandos['point'] # <<<<<<<<<<<<<<
4457 * for sent in sentences:
4458 * if not sent:
4459 */
4460 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_wv, __pyx_n_s_expandos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 474, __pyx_L1_error)
4461 __Pyx_GOTREF(__pyx_t_2);
4462 __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_2, __pyx_n_s_point); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 474, __pyx_L1_error)
4463 __Pyx_GOTREF(__pyx_t_3);
4464 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4465 __pyx_v_vocab_points = __pyx_t_3;
4466 __pyx_t_3 = 0;
4467
4468 /* "gensim/models/fasttext_inner.pyx":472
4469 * if c.sample:
4470 * vocab_sample_ints = <np.uint32_t *>np.PyArray_DATA(wv.expandos['sample_int'])
4471 * if c.hs: # <<<<<<<<<<<<<<
4472 * vocab_codes = wv.expandos['code']
4473 * vocab_points = wv.expandos['point']
4474 */
4475 }
4476
4477 /* "gensim/models/fasttext_inner.pyx":475
4478 * vocab_codes = wv.expandos['code']
4479 * vocab_points = wv.expandos['point']
4480 * for sent in sentences: # <<<<<<<<<<<<<<
4481 * if not sent:
4482 * continue # ignore empty sentences; leave effective_sentences unchanged
4483 */
4484 if (likely(PyList_CheckExact(__pyx_v_sentences)) || PyTuple_CheckExact(__pyx_v_sentences)) {
4485 __pyx_t_3 = __pyx_v_sentences; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
4486 __pyx_t_5 = NULL;
4487 } else {
4488 __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_sentences); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 475, __pyx_L1_error)
4489 __Pyx_GOTREF(__pyx_t_3);
4490 __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 475, __pyx_L1_error)
4491 }
4492 for (;;) {
4493 if (likely(!__pyx_t_5)) {
4494 if (likely(PyList_CheckExact(__pyx_t_3))) {
4495 if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
4496 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4497 __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 475, __pyx_L1_error)
4498 #else
4499 __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 475, __pyx_L1_error)
4500 __Pyx_GOTREF(__pyx_t_2);
4501 #endif
4502 } else {
4503 if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
4504 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4505 __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 475, __pyx_L1_error)
4506 #else
4507 __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 475, __pyx_L1_error)
4508 __Pyx_GOTREF(__pyx_t_2);
4509 #endif
4510 }
4511 } else {
4512 __pyx_t_2 = __pyx_t_5(__pyx_t_3);
4513 if (unlikely(!__pyx_t_2)) {
4514 PyObject* exc_type = PyErr_Occurred();
4515 if (exc_type) {
4516 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
4517 else __PYX_ERR(0, 475, __pyx_L1_error)
4518 }
4519 break;
4520 }
4521 __Pyx_GOTREF(__pyx_t_2);
4522 }
4523 __Pyx_XDECREF_SET(__pyx_v_sent, __pyx_t_2);
4524 __pyx_t_2 = 0;
4525
4526 /* "gensim/models/fasttext_inner.pyx":476
4527 * vocab_points = wv.expandos['point']
4528 * for sent in sentences:
4529 * if not sent: # <<<<<<<<<<<<<<
4530 * continue # ignore empty sentences; leave effective_sentences unchanged
4531 * for token in sent:
4532 */
4533 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_sent); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 476, __pyx_L1_error)
4534 __pyx_t_6 = ((!__pyx_t_1) != 0);
4535 if (__pyx_t_6) {
4536
4537 /* "gensim/models/fasttext_inner.pyx":477
4538 * for sent in sentences:
4539 * if not sent:
4540 * continue # ignore empty sentences; leave effective_sentences unchanged # <<<<<<<<<<<<<<
4541 * for token in sent:
4542 * word_index = wv.key_to_index.get(token, None)
4543 */
4544 goto __pyx_L5_continue;
4545
4546 /* "gensim/models/fasttext_inner.pyx":476
4547 * vocab_points = wv.expandos['point']
4548 * for sent in sentences:
4549 * if not sent: # <<<<<<<<<<<<<<
4550 * continue # ignore empty sentences; leave effective_sentences unchanged
4551 * for token in sent:
4552 */
4553 }
4554
4555 /* "gensim/models/fasttext_inner.pyx":478
4556 * if not sent:
4557 * continue # ignore empty sentences; leave effective_sentences unchanged
4558 * for token in sent: # <<<<<<<<<<<<<<
4559 * word_index = wv.key_to_index.get(token, None)
4560 * if word_index is None:
4561 */
4562 if (likely(PyList_CheckExact(__pyx_v_sent)) || PyTuple_CheckExact(__pyx_v_sent)) {
4563 __pyx_t_2 = __pyx_v_sent; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
4564 __pyx_t_8 = NULL;
4565 } else {
4566 __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_sent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 478, __pyx_L1_error)
4567 __Pyx_GOTREF(__pyx_t_2);
4568 __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 478, __pyx_L1_error)
4569 }
4570 for (;;) {
4571 if (likely(!__pyx_t_8)) {
4572 if (likely(PyList_CheckExact(__pyx_t_2))) {
4573 if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
4574 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4575 __pyx_t_9 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 478, __pyx_L1_error)
4576 #else
4577 __pyx_t_9 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 478, __pyx_L1_error)
4578 __Pyx_GOTREF(__pyx_t_9);
4579 #endif
4580 } else {
4581 if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
4582 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4583 __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 478, __pyx_L1_error)
4584 #else
4585 __pyx_t_9 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 478, __pyx_L1_error)
4586 __Pyx_GOTREF(__pyx_t_9);
4587 #endif
4588 }
4589 } else {
4590 __pyx_t_9 = __pyx_t_8(__pyx_t_2);
4591 if (unlikely(!__pyx_t_9)) {
4592 PyObject* exc_type = PyErr_Occurred();
4593 if (exc_type) {
4594 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
4595 else __PYX_ERR(0, 478, __pyx_L1_error)
4596 }
4597 break;
4598 }
4599 __Pyx_GOTREF(__pyx_t_9);
4600 }
4601 __Pyx_XDECREF_SET(__pyx_v_token, __pyx_t_9);
4602 __pyx_t_9 = 0;
4603
4604 /* "gensim/models/fasttext_inner.pyx":479
4605 * continue # ignore empty sentences; leave effective_sentences unchanged
4606 * for token in sent:
4607 * word_index = wv.key_to_index.get(token, None) # <<<<<<<<<<<<<<
4608 * if word_index is None:
4609 * continue # leaving `effective_words` unchanged = shortening the sentence = expanding the window
4610 */
4611 __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_wv, __pyx_n_s_key_to_index); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 479, __pyx_L1_error)
4612 __Pyx_GOTREF(__pyx_t_10);
4613 __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_get); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 479, __pyx_L1_error)
4614 __Pyx_GOTREF(__pyx_t_11);
4615 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
4616 __pyx_t_10 = NULL;
4617 __pyx_t_12 = 0;
4618 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
4619 __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
4620 if (likely(__pyx_t_10)) {
4621 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
4622 __Pyx_INCREF(__pyx_t_10);
4623 __Pyx_INCREF(function);
4624 __Pyx_DECREF_SET(__pyx_t_11, function);
4625 __pyx_t_12 = 1;
4626 }
4627 }
4628 #if CYTHON_FAST_PYCALL
4629 if (PyFunction_Check(__pyx_t_11)) {
4630 PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_token, Py_None};
4631 __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 479, __pyx_L1_error)
4632 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
4633 __Pyx_GOTREF(__pyx_t_9);
4634 } else
4635 #endif
4636 #if CYTHON_FAST_PYCCALL
4637 if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
4638 PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_token, Py_None};
4639 __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 479, __pyx_L1_error)
4640 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
4641 __Pyx_GOTREF(__pyx_t_9);
4642 } else
4643 #endif
4644 {
4645 __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 479, __pyx_L1_error)
4646 __Pyx_GOTREF(__pyx_t_13);
4647 if (__pyx_t_10) {
4648 __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10); __pyx_t_10 = NULL;
4649 }
4650 __Pyx_INCREF(__pyx_v_token);
4651 __Pyx_GIVEREF(__pyx_v_token);
4652 PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_v_token);
4653 __Pyx_INCREF(Py_None);
4654 __Pyx_GIVEREF(Py_None);
4655 PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, Py_None);
4656 __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 479, __pyx_L1_error)
4657 __Pyx_GOTREF(__pyx_t_9);
4658 __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
4659 }
4660 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
4661 __Pyx_XDECREF_SET(__pyx_v_word_index, __pyx_t_9);
4662 __pyx_t_9 = 0;
4663
4664 /* "gensim/models/fasttext_inner.pyx":480
4665 * for token in sent:
4666 * word_index = wv.key_to_index.get(token, None)
4667 * if word_index is None: # <<<<<<<<<<<<<<
4668 * continue # leaving `effective_words` unchanged = shortening the sentence = expanding the window
4669 * if c.sample and vocab_sample_ints[word_index] < random_int32(&c.next_random):
4670 */
4671 __pyx_t_6 = (__pyx_v_word_index == Py_None);
4672 __pyx_t_1 = (__pyx_t_6 != 0);
4673 if (__pyx_t_1) {
4674
4675 /* "gensim/models/fasttext_inner.pyx":481
4676 * word_index = wv.key_to_index.get(token, None)
4677 * if word_index is None:
4678 * continue # leaving `effective_words` unchanged = shortening the sentence = expanding the window # <<<<<<<<<<<<<<
4679 * if c.sample and vocab_sample_ints[word_index] < random_int32(&c.next_random):
4680 * continue
4681 */
4682 goto __pyx_L8_continue;
4683
4684 /* "gensim/models/fasttext_inner.pyx":480
4685 * for token in sent:
4686 * word_index = wv.key_to_index.get(token, None)
4687 * if word_index is None: # <<<<<<<<<<<<<<
4688 * continue # leaving `effective_words` unchanged = shortening the sentence = expanding the window
4689 * if c.sample and vocab_sample_ints[word_index] < random_int32(&c.next_random):
4690 */
4691 }
4692
4693 /* "gensim/models/fasttext_inner.pyx":482
4694 * if word_index is None:
4695 * continue # leaving `effective_words` unchanged = shortening the sentence = expanding the window
4696 * if c.sample and vocab_sample_ints[word_index] < random_int32(&c.next_random): # <<<<<<<<<<<<<<
4697 * continue
4698 * c.indexes[effective_words] = word_index
4699 */
4700 __pyx_t_6 = (__pyx_v_c->sample != 0);
4701 if (__pyx_t_6) {
4702 } else {
4703 __pyx_t_1 = __pyx_t_6;
4704 goto __pyx_L12_bool_binop_done;
4705 }
4706 __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_v_word_index); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 482, __pyx_L1_error)
4707 __pyx_t_6 = (((__pyx_v_vocab_sample_ints[__pyx_t_14]) < __pyx_f_6gensim_6models_14word2vec_inner_random_int32((&__pyx_v_c->next_random))) != 0);
4708 __pyx_t_1 = __pyx_t_6;
4709 __pyx_L12_bool_binop_done:;
4710 if (__pyx_t_1) {
4711
4712 /* "gensim/models/fasttext_inner.pyx":483
4713 * continue # leaving `effective_words` unchanged = shortening the sentence = expanding the window
4714 * if c.sample and vocab_sample_ints[word_index] < random_int32(&c.next_random):
4715 * continue # <<<<<<<<<<<<<<
4716 * c.indexes[effective_words] = word_index
4717 *
4718 */
4719 goto __pyx_L8_continue;
4720
4721 /* "gensim/models/fasttext_inner.pyx":482
4722 * if word_index is None:
4723 * continue # leaving `effective_words` unchanged = shortening the sentence = expanding the window
4724 * if c.sample and vocab_sample_ints[word_index] < random_int32(&c.next_random): # <<<<<<<<<<<<<<
4725 * continue
4726 * c.indexes[effective_words] = word_index
4727 */
4728 }
4729
4730 /* "gensim/models/fasttext_inner.pyx":484
4731 * if c.sample and vocab_sample_ints[word_index] < random_int32(&c.next_random):
4732 * continue
4733 * c.indexes[effective_words] = word_index # <<<<<<<<<<<<<<
4734 *
4735 * if wv.bucket:
4736 */
4737 __pyx_t_15 = __Pyx_PyInt_As_npy_uint32(__pyx_v_word_index); if (unlikely((__pyx_t_15 == ((npy_uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 484, __pyx_L1_error)
4738 (__pyx_v_c->indexes[__pyx_v_effective_words]) = __pyx_t_15;
4739
4740 /* "gensim/models/fasttext_inner.pyx":486
4741 * c.indexes[effective_words] = word_index
4742 *
4743 * if wv.bucket: # <<<<<<<<<<<<<<
4744 * c.subwords_idx_len[effective_words] = <int>(len(buckets_word[word_index]))
4745 * c.subwords_idx[effective_words] = <np.uint32_t *>np.PyArray_DATA(buckets_word[word_index])
4746 */
4747 __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_wv, __pyx_n_s_bucket); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 486, __pyx_L1_error)
4748 __Pyx_GOTREF(__pyx_t_9);
4749 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
4750 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
4751 if (__pyx_t_1) {
4752
4753 /* "gensim/models/fasttext_inner.pyx":487
4754 *
4755 * if wv.bucket:
4756 * c.subwords_idx_len[effective_words] = <int>(len(buckets_word[word_index])) # <<<<<<<<<<<<<<
4757 * c.subwords_idx[effective_words] = <np.uint32_t *>np.PyArray_DATA(buckets_word[word_index])
4758 * else:
4759 */
4760 __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_v_buckets_word, __pyx_v_word_index); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 487, __pyx_L1_error)
4761 __Pyx_GOTREF(__pyx_t_9);
4762 __pyx_t_14 = PyObject_Length(__pyx_t_9); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 487, __pyx_L1_error)
4763 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
4764 (__pyx_v_c->subwords_idx_len[__pyx_v_effective_words]) = ((int)__pyx_t_14);
4765
4766 /* "gensim/models/fasttext_inner.pyx":488
4767 * if wv.bucket:
4768 * c.subwords_idx_len[effective_words] = <int>(len(buckets_word[word_index]))
4769 * c.subwords_idx[effective_words] = <np.uint32_t *>np.PyArray_DATA(buckets_word[word_index]) # <<<<<<<<<<<<<<
4770 * else:
4771 * c.subwords_idx_len[effective_words] = 0
4772 */
4773 __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_v_buckets_word, __pyx_v_word_index); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 488, __pyx_L1_error)
4774 __Pyx_GOTREF(__pyx_t_9);
4775 if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 488, __pyx_L1_error)
4776 (__pyx_v_c->subwords_idx[__pyx_v_effective_words]) = ((__pyx_t_5numpy_uint32_t *)PyArray_DATA(((PyArrayObject *)__pyx_t_9)));
4777 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
4778
4779 /* "gensim/models/fasttext_inner.pyx":486
4780 * c.indexes[effective_words] = word_index
4781 *
4782 * if wv.bucket: # <<<<<<<<<<<<<<
4783 * c.subwords_idx_len[effective_words] = <int>(len(buckets_word[word_index]))
4784 * c.subwords_idx[effective_words] = <np.uint32_t *>np.PyArray_DATA(buckets_word[word_index])
4785 */
4786 goto __pyx_L14;
4787 }
4788
4789 /* "gensim/models/fasttext_inner.pyx":490
4790 * c.subwords_idx[effective_words] = <np.uint32_t *>np.PyArray_DATA(buckets_word[word_index])
4791 * else:
4792 * c.subwords_idx_len[effective_words] = 0 # <<<<<<<<<<<<<<
4793 *
4794 * if c.hs:
4795 */
4796 /*else*/ {
4797 (__pyx_v_c->subwords_idx_len[__pyx_v_effective_words]) = 0;
4798 }
4799 __pyx_L14:;
4800
4801 /* "gensim/models/fasttext_inner.pyx":492
4802 * c.subwords_idx_len[effective_words] = 0
4803 *
4804 * if c.hs: # <<<<<<<<<<<<<<
4805 * c.codelens[effective_words] = <int>len(vocab_codes[word_index])
4806 * c.codes[effective_words] = <np.uint8_t *>np.PyArray_DATA(vocab_codes[word_index])
4807 */
4808 __pyx_t_1 = (__pyx_v_c->hs != 0);
4809 if (__pyx_t_1) {
4810
4811 /* "gensim/models/fasttext_inner.pyx":493
4812 *
4813 * if c.hs:
4814 * c.codelens[effective_words] = <int>len(vocab_codes[word_index]) # <<<<<<<<<<<<<<
4815 * c.codes[effective_words] = <np.uint8_t *>np.PyArray_DATA(vocab_codes[word_index])
4816 * c.points[effective_words] = <np.uint32_t *>np.PyArray_DATA(vocab_points[word_index])
4817 */
4818 if (unlikely(!__pyx_v_vocab_codes)) { __Pyx_RaiseUnboundLocalError("vocab_codes"); __PYX_ERR(0, 493, __pyx_L1_error) }
4819 __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_v_vocab_codes, __pyx_v_word_index); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 493, __pyx_L1_error)
4820 __Pyx_GOTREF(__pyx_t_9);
4821 __pyx_t_14 = PyObject_Length(__pyx_t_9); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 493, __pyx_L1_error)
4822 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
4823 (__pyx_v_c->codelens[__pyx_v_effective_words]) = ((int)__pyx_t_14);
4824
4825 /* "gensim/models/fasttext_inner.pyx":494
4826 * if c.hs:
4827 * c.codelens[effective_words] = <int>len(vocab_codes[word_index])
4828 * c.codes[effective_words] = <np.uint8_t *>np.PyArray_DATA(vocab_codes[word_index]) # <<<<<<<<<<<<<<
4829 * c.points[effective_words] = <np.uint32_t *>np.PyArray_DATA(vocab_points[word_index])
4830 *
4831 */
4832 if (unlikely(!__pyx_v_vocab_codes)) { __Pyx_RaiseUnboundLocalError("vocab_codes"); __PYX_ERR(0, 494, __pyx_L1_error) }
4833 __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_v_vocab_codes, __pyx_v_word_index); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 494, __pyx_L1_error)
4834 __Pyx_GOTREF(__pyx_t_9);
4835 if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 494, __pyx_L1_error)
4836 (__pyx_v_c->codes[__pyx_v_effective_words]) = ((__pyx_t_5numpy_uint8_t *)PyArray_DATA(((PyArrayObject *)__pyx_t_9)));
4837 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
4838
4839 /* "gensim/models/fasttext_inner.pyx":495
4840 * c.codelens[effective_words] = <int>len(vocab_codes[word_index])
4841 * c.codes[effective_words] = <np.uint8_t *>np.PyArray_DATA(vocab_codes[word_index])
4842 * c.points[effective_words] = <np.uint32_t *>np.PyArray_DATA(vocab_points[word_index]) # <<<<<<<<<<<<<<
4843 *
4844 * effective_words += 1
4845 */
4846 if (unlikely(!__pyx_v_vocab_points)) { __Pyx_RaiseUnboundLocalError("vocab_points"); __PYX_ERR(0, 495, __pyx_L1_error) }
4847 __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_v_vocab_points, __pyx_v_word_index); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 495, __pyx_L1_error)
4848 __Pyx_GOTREF(__pyx_t_9);
4849 if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 495, __pyx_L1_error)
4850 (__pyx_v_c->points[__pyx_v_effective_words]) = ((__pyx_t_5numpy_uint32_t *)PyArray_DATA(((PyArrayObject *)__pyx_t_9)));
4851 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
4852
4853 /* "gensim/models/fasttext_inner.pyx":492
4854 * c.subwords_idx_len[effective_words] = 0
4855 *
4856 * if c.hs: # <<<<<<<<<<<<<<
4857 * c.codelens[effective_words] = <int>len(vocab_codes[word_index])
4858 * c.codes[effective_words] = <np.uint8_t *>np.PyArray_DATA(vocab_codes[word_index])
4859 */
4860 }
4861
4862 /* "gensim/models/fasttext_inner.pyx":497
4863 * c.points[effective_words] = <np.uint32_t *>np.PyArray_DATA(vocab_points[word_index])
4864 *
4865 * effective_words += 1 # <<<<<<<<<<<<<<
4866 * if effective_words == MAX_SENTENCE_LEN:
4867 * break
4868 */
4869 __pyx_v_effective_words = (__pyx_v_effective_words + 1);
4870
4871 /* "gensim/models/fasttext_inner.pyx":498
4872 *
4873 * effective_words += 1
4874 * if effective_words == MAX_SENTENCE_LEN: # <<<<<<<<<<<<<<
4875 * break
4876 *
4877 */
4878 __pyx_t_1 = ((__pyx_v_effective_words == 0x2710) != 0);
4879 if (__pyx_t_1) {
4880
4881 /* "gensim/models/fasttext_inner.pyx":499
4882 * effective_words += 1
4883 * if effective_words == MAX_SENTENCE_LEN:
4884 * break # <<<<<<<<<<<<<<
4885 *
4886 * # keep track of which words go into which sentence, so we don't train
4887 */
4888 goto __pyx_L9_break;
4889
4890 /* "gensim/models/fasttext_inner.pyx":498
4891 *
4892 * effective_words += 1
4893 * if effective_words == MAX_SENTENCE_LEN: # <<<<<<<<<<<<<<
4894 * break
4895 *
4896 */
4897 }
4898
4899 /* "gensim/models/fasttext_inner.pyx":478
4900 * if not sent:
4901 * continue # ignore empty sentences; leave effective_sentences unchanged
4902 * for token in sent: # <<<<<<<<<<<<<<
4903 * word_index = wv.key_to_index.get(token, None)
4904 * if word_index is None:
4905 */
4906 __pyx_L8_continue:;
4907 }
4908 __pyx_L9_break:;
4909 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4910
4911 /* "gensim/models/fasttext_inner.pyx":503
4912 * # keep track of which words go into which sentence, so we don't train
4913 * # across sentence boundaries.
4914 * effective_sentences += 1 # <<<<<<<<<<<<<<
4915 * c.sentence_idx[effective_sentences] = effective_words
4916 *
4917 */
4918 __pyx_v_effective_sentences = (__pyx_v_effective_sentences + 1);
4919
4920 /* "gensim/models/fasttext_inner.pyx":504
4921 * # across sentence boundaries.
4922 * effective_sentences += 1
4923 * c.sentence_idx[effective_sentences] = effective_words # <<<<<<<<<<<<<<
4924 *
4925 * if effective_words == MAX_SENTENCE_LEN:
4926 */
4927 (__pyx_v_c->sentence_idx[__pyx_v_effective_sentences]) = __pyx_v_effective_words;
4928
4929 /* "gensim/models/fasttext_inner.pyx":506
4930 * c.sentence_idx[effective_sentences] = effective_words
4931 *
4932 * if effective_words == MAX_SENTENCE_LEN: # <<<<<<<<<<<<<<
4933 * break
4934 *
4935 */
4936 __pyx_t_1 = ((__pyx_v_effective_words == 0x2710) != 0);
4937 if (__pyx_t_1) {
4938
4939 /* "gensim/models/fasttext_inner.pyx":507
4940 *
4941 * if effective_words == MAX_SENTENCE_LEN:
4942 * break # <<<<<<<<<<<<<<
4943 *
4944 * return effective_words, effective_sentences
4945 */
4946 goto __pyx_L6_break;
4947
4948 /* "gensim/models/fasttext_inner.pyx":506
4949 * c.sentence_idx[effective_sentences] = effective_words
4950 *
4951 * if effective_words == MAX_SENTENCE_LEN: # <<<<<<<<<<<<<<
4952 * break
4953 *
4954 */
4955 }
4956
4957 /* "gensim/models/fasttext_inner.pyx":475
4958 * vocab_codes = wv.expandos['code']
4959 * vocab_points = wv.expandos['point']
4960 * for sent in sentences: # <<<<<<<<<<<<<<
4961 * if not sent:
4962 * continue # ignore empty sentences; leave effective_sentences unchanged
4963 */
4964 __pyx_L5_continue:;
4965 }
4966 __pyx_L6_break:;
4967 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4968
4969 /* "gensim/models/fasttext_inner.pyx":509
4970 * break
4971 *
4972 * return effective_words, effective_sentences # <<<<<<<<<<<<<<
4973 *
4974 *
4975 */
4976 __Pyx_XDECREF(__pyx_r);
4977 __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_effective_words); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 509, __pyx_L1_error)
4978 __Pyx_GOTREF(__pyx_t_3);
4979 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_effective_sentences); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error)
4980 __Pyx_GOTREF(__pyx_t_2);
4981 __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 509, __pyx_L1_error)
4982 __Pyx_GOTREF(__pyx_t_9);
4983 __Pyx_GIVEREF(__pyx_t_3);
4984 PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3);
4985 __Pyx_GIVEREF(__pyx_t_2);
4986 PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2);
4987 __pyx_t_3 = 0;
4988 __pyx_t_2 = 0;
4989 __pyx_r = __pyx_t_9;
4990 __pyx_t_9 = 0;
4991 goto __pyx_L0;
4992
4993 /* "gensim/models/fasttext_inner.pyx":429
4994 *
4995 *
4996 * cdef object populate_ft_config(FastTextConfig *c, wv, buckets_word, sentences): # <<<<<<<<<<<<<<
4997 * """Prepare C structures so we can go "full C" and release the Python GIL.
4998 *
4999 */
5000
5001 /* function exit code */
5002 __pyx_L1_error:;
5003 __Pyx_XDECREF(__pyx_t_2);
5004 __Pyx_XDECREF(__pyx_t_3);
5005 __Pyx_XDECREF(__pyx_t_9);
5006 __Pyx_XDECREF(__pyx_t_10);
5007 __Pyx_XDECREF(__pyx_t_11);
5008 __Pyx_XDECREF(__pyx_t_13);
5009 __Pyx_AddTraceback("gensim.models.fasttext_inner.populate_ft_config", __pyx_clineno, __pyx_lineno, __pyx_filename);
5010 __pyx_r = 0;
5011 __pyx_L0:;
5012 __Pyx_XDECREF(__pyx_v_vocab_codes);
5013 __Pyx_XDECREF(__pyx_v_vocab_points);
5014 __Pyx_XDECREF(__pyx_v_sent);
5015 __Pyx_XDECREF(__pyx_v_token);
5016 __Pyx_XDECREF(__pyx_v_word_index);
5017 __Pyx_XGIVEREF(__pyx_r);
5018 __Pyx_RefNannyFinishContext();
5019 return __pyx_r;
5020 }
5021
5022 /* "gensim/models/fasttext_inner.pyx":512
5023 *
5024 *
5025 * cdef void fasttext_train_any(FastTextConfig *c, int num_sentences) nogil: # <<<<<<<<<<<<<<
5026 * """Performs training on a fully initialized and populated configuration.
5027 *
5028 */
5029
__pyx_f_6gensim_6models_14fasttext_inner_fasttext_train_any(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig * __pyx_v_c,int __pyx_v_num_sentences)5030 static void __pyx_f_6gensim_6models_14fasttext_inner_fasttext_train_any(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *__pyx_v_c, int __pyx_v_num_sentences) {
5031 int __pyx_v_sent_idx;
5032 int __pyx_v_sentence_start;
5033 int __pyx_v_sentence_end;
5034 int __pyx_v_i;
5035 int __pyx_v_window_start;
5036 int __pyx_v_window_end;
5037 int __pyx_v_j;
5038 int __pyx_t_1;
5039 int __pyx_t_2;
5040 int __pyx_t_3;
5041 int __pyx_t_4;
5042 int __pyx_t_5;
5043 int __pyx_t_6;
5044 int __pyx_t_7;
5045 int __pyx_t_8;
5046 int __pyx_t_9;
5047 int __pyx_t_10;
5048
5049 /* "gensim/models/fasttext_inner.pyx":532
5050 * int j
5051 *
5052 * for sent_idx in range(num_sentences): # <<<<<<<<<<<<<<
5053 * sentence_start = c.sentence_idx[sent_idx]
5054 * sentence_end = c.sentence_idx[sent_idx + 1]
5055 */
5056 __pyx_t_1 = __pyx_v_num_sentences;
5057 __pyx_t_2 = __pyx_t_1;
5058 for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
5059 __pyx_v_sent_idx = __pyx_t_3;
5060
5061 /* "gensim/models/fasttext_inner.pyx":533
5062 *
5063 * for sent_idx in range(num_sentences):
5064 * sentence_start = c.sentence_idx[sent_idx] # <<<<<<<<<<<<<<
5065 * sentence_end = c.sentence_idx[sent_idx + 1]
5066 * for i in range(sentence_start, sentence_end):
5067 */
5068 __pyx_v_sentence_start = (__pyx_v_c->sentence_idx[__pyx_v_sent_idx]);
5069
5070 /* "gensim/models/fasttext_inner.pyx":534
5071 * for sent_idx in range(num_sentences):
5072 * sentence_start = c.sentence_idx[sent_idx]
5073 * sentence_end = c.sentence_idx[sent_idx + 1] # <<<<<<<<<<<<<<
5074 * for i in range(sentence_start, sentence_end):
5075 * #
5076 */
5077 __pyx_v_sentence_end = (__pyx_v_c->sentence_idx[(__pyx_v_sent_idx + 1)]);
5078
5079 /* "gensim/models/fasttext_inner.pyx":535
5080 * sentence_start = c.sentence_idx[sent_idx]
5081 * sentence_end = c.sentence_idx[sent_idx + 1]
5082 * for i in range(sentence_start, sentence_end): # <<<<<<<<<<<<<<
5083 * #
5084 * # Determine window boundaries, making sure we don't leak into
5085 */
5086 __pyx_t_4 = __pyx_v_sentence_end;
5087 __pyx_t_5 = __pyx_t_4;
5088 for (__pyx_t_6 = __pyx_v_sentence_start; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
5089 __pyx_v_i = __pyx_t_6;
5090
5091 /* "gensim/models/fasttext_inner.pyx":540
5092 * # adjacent sentences.
5093 * #
5094 * window_start = i - c.window + c.reduced_windows[i] # <<<<<<<<<<<<<<
5095 * if window_start < sentence_start:
5096 * window_start = sentence_start
5097 */
5098 __pyx_v_window_start = ((__pyx_v_i - __pyx_v_c->window) + (__pyx_v_c->reduced_windows[__pyx_v_i]));
5099
5100 /* "gensim/models/fasttext_inner.pyx":541
5101 * #
5102 * window_start = i - c.window + c.reduced_windows[i]
5103 * if window_start < sentence_start: # <<<<<<<<<<<<<<
5104 * window_start = sentence_start
5105 * window_end = i + c.window + 1 - c.reduced_windows[i]
5106 */
5107 __pyx_t_7 = ((__pyx_v_window_start < __pyx_v_sentence_start) != 0);
5108 if (__pyx_t_7) {
5109
5110 /* "gensim/models/fasttext_inner.pyx":542
5111 * window_start = i - c.window + c.reduced_windows[i]
5112 * if window_start < sentence_start:
5113 * window_start = sentence_start # <<<<<<<<<<<<<<
5114 * window_end = i + c.window + 1 - c.reduced_windows[i]
5115 * if window_end > sentence_end:
5116 */
5117 __pyx_v_window_start = __pyx_v_sentence_start;
5118
5119 /* "gensim/models/fasttext_inner.pyx":541
5120 * #
5121 * window_start = i - c.window + c.reduced_windows[i]
5122 * if window_start < sentence_start: # <<<<<<<<<<<<<<
5123 * window_start = sentence_start
5124 * window_end = i + c.window + 1 - c.reduced_windows[i]
5125 */
5126 }
5127
5128 /* "gensim/models/fasttext_inner.pyx":543
5129 * if window_start < sentence_start:
5130 * window_start = sentence_start
5131 * window_end = i + c.window + 1 - c.reduced_windows[i] # <<<<<<<<<<<<<<
5132 * if window_end > sentence_end:
5133 * window_end = sentence_end
5134 */
5135 __pyx_v_window_end = (((__pyx_v_i + __pyx_v_c->window) + 1) - (__pyx_v_c->reduced_windows[__pyx_v_i]));
5136
5137 /* "gensim/models/fasttext_inner.pyx":544
5138 * window_start = sentence_start
5139 * window_end = i + c.window + 1 - c.reduced_windows[i]
5140 * if window_end > sentence_end: # <<<<<<<<<<<<<<
5141 * window_end = sentence_end
5142 *
5143 */
5144 __pyx_t_7 = ((__pyx_v_window_end > __pyx_v_sentence_end) != 0);
5145 if (__pyx_t_7) {
5146
5147 /* "gensim/models/fasttext_inner.pyx":545
5148 * window_end = i + c.window + 1 - c.reduced_windows[i]
5149 * if window_end > sentence_end:
5150 * window_end = sentence_end # <<<<<<<<<<<<<<
5151 *
5152 * #
5153 */
5154 __pyx_v_window_end = __pyx_v_sentence_end;
5155
5156 /* "gensim/models/fasttext_inner.pyx":544
5157 * window_start = sentence_start
5158 * window_end = i + c.window + 1 - c.reduced_windows[i]
5159 * if window_end > sentence_end: # <<<<<<<<<<<<<<
5160 * window_end = sentence_end
5161 *
5162 */
5163 }
5164
5165 /* "gensim/models/fasttext_inner.pyx":553
5166 * # window_end = min(sentence_end, i + c.window + 1 - c.reduced_windows[i])
5167 * #
5168 * if c.sg == 0: # <<<<<<<<<<<<<<
5169 * if c.hs:
5170 * fasttext_fast_sentence_cbow_hs(c, i, window_start, window_end)
5171 */
5172 __pyx_t_7 = ((__pyx_v_c->sg == 0) != 0);
5173 if (__pyx_t_7) {
5174
5175 /* "gensim/models/fasttext_inner.pyx":554
5176 * #
5177 * if c.sg == 0:
5178 * if c.hs: # <<<<<<<<<<<<<<
5179 * fasttext_fast_sentence_cbow_hs(c, i, window_start, window_end)
5180 * if c.negative:
5181 */
5182 __pyx_t_7 = (__pyx_v_c->hs != 0);
5183 if (__pyx_t_7) {
5184
5185 /* "gensim/models/fasttext_inner.pyx":555
5186 * if c.sg == 0:
5187 * if c.hs:
5188 * fasttext_fast_sentence_cbow_hs(c, i, window_start, window_end) # <<<<<<<<<<<<<<
5189 * if c.negative:
5190 * fasttext_fast_sentence_cbow_neg(c, i, window_start, window_end)
5191 */
5192 __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_cbow_hs(__pyx_v_c, __pyx_v_i, __pyx_v_window_start, __pyx_v_window_end);
5193
5194 /* "gensim/models/fasttext_inner.pyx":554
5195 * #
5196 * if c.sg == 0:
5197 * if c.hs: # <<<<<<<<<<<<<<
5198 * fasttext_fast_sentence_cbow_hs(c, i, window_start, window_end)
5199 * if c.negative:
5200 */
5201 }
5202
5203 /* "gensim/models/fasttext_inner.pyx":556
5204 * if c.hs:
5205 * fasttext_fast_sentence_cbow_hs(c, i, window_start, window_end)
5206 * if c.negative: # <<<<<<<<<<<<<<
5207 * fasttext_fast_sentence_cbow_neg(c, i, window_start, window_end)
5208 * else:
5209 */
5210 __pyx_t_7 = (__pyx_v_c->negative != 0);
5211 if (__pyx_t_7) {
5212
5213 /* "gensim/models/fasttext_inner.pyx":557
5214 * fasttext_fast_sentence_cbow_hs(c, i, window_start, window_end)
5215 * if c.negative:
5216 * fasttext_fast_sentence_cbow_neg(c, i, window_start, window_end) # <<<<<<<<<<<<<<
5217 * else:
5218 * for j in range(window_start, window_end):
5219 */
5220 __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_cbow_neg(__pyx_v_c, __pyx_v_i, __pyx_v_window_start, __pyx_v_window_end);
5221
5222 /* "gensim/models/fasttext_inner.pyx":556
5223 * if c.hs:
5224 * fasttext_fast_sentence_cbow_hs(c, i, window_start, window_end)
5225 * if c.negative: # <<<<<<<<<<<<<<
5226 * fasttext_fast_sentence_cbow_neg(c, i, window_start, window_end)
5227 * else:
5228 */
5229 }
5230
5231 /* "gensim/models/fasttext_inner.pyx":553
5232 * # window_end = min(sentence_end, i + c.window + 1 - c.reduced_windows[i])
5233 * #
5234 * if c.sg == 0: # <<<<<<<<<<<<<<
5235 * if c.hs:
5236 * fasttext_fast_sentence_cbow_hs(c, i, window_start, window_end)
5237 */
5238 goto __pyx_L9;
5239 }
5240
5241 /* "gensim/models/fasttext_inner.pyx":559
5242 * fasttext_fast_sentence_cbow_neg(c, i, window_start, window_end)
5243 * else:
5244 * for j in range(window_start, window_end): # <<<<<<<<<<<<<<
5245 * if j == i:
5246 * # no reason to train a center word as predicting itself
5247 */
5248 /*else*/ {
5249 __pyx_t_8 = __pyx_v_window_end;
5250 __pyx_t_9 = __pyx_t_8;
5251 for (__pyx_t_10 = __pyx_v_window_start; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
5252 __pyx_v_j = __pyx_t_10;
5253
5254 /* "gensim/models/fasttext_inner.pyx":560
5255 * else:
5256 * for j in range(window_start, window_end):
5257 * if j == i: # <<<<<<<<<<<<<<
5258 * # no reason to train a center word as predicting itself
5259 * continue
5260 */
5261 __pyx_t_7 = ((__pyx_v_j == __pyx_v_i) != 0);
5262 if (__pyx_t_7) {
5263
5264 /* "gensim/models/fasttext_inner.pyx":562
5265 * if j == i:
5266 * # no reason to train a center word as predicting itself
5267 * continue # <<<<<<<<<<<<<<
5268 * if c.hs:
5269 * fasttext_fast_sentence_sg_hs(c, i, j)
5270 */
5271 goto __pyx_L12_continue;
5272
5273 /* "gensim/models/fasttext_inner.pyx":560
5274 * else:
5275 * for j in range(window_start, window_end):
5276 * if j == i: # <<<<<<<<<<<<<<
5277 * # no reason to train a center word as predicting itself
5278 * continue
5279 */
5280 }
5281
5282 /* "gensim/models/fasttext_inner.pyx":563
5283 * # no reason to train a center word as predicting itself
5284 * continue
5285 * if c.hs: # <<<<<<<<<<<<<<
5286 * fasttext_fast_sentence_sg_hs(c, i, j)
5287 * if c.negative:
5288 */
5289 __pyx_t_7 = (__pyx_v_c->hs != 0);
5290 if (__pyx_t_7) {
5291
5292 /* "gensim/models/fasttext_inner.pyx":564
5293 * continue
5294 * if c.hs:
5295 * fasttext_fast_sentence_sg_hs(c, i, j) # <<<<<<<<<<<<<<
5296 * if c.negative:
5297 * fasttext_fast_sentence_sg_neg(c, i, j)
5298 */
5299 __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_sg_hs(__pyx_v_c, __pyx_v_i, __pyx_v_j);
5300
5301 /* "gensim/models/fasttext_inner.pyx":563
5302 * # no reason to train a center word as predicting itself
5303 * continue
5304 * if c.hs: # <<<<<<<<<<<<<<
5305 * fasttext_fast_sentence_sg_hs(c, i, j)
5306 * if c.negative:
5307 */
5308 }
5309
5310 /* "gensim/models/fasttext_inner.pyx":565
5311 * if c.hs:
5312 * fasttext_fast_sentence_sg_hs(c, i, j)
5313 * if c.negative: # <<<<<<<<<<<<<<
5314 * fasttext_fast_sentence_sg_neg(c, i, j)
5315 *
5316 */
5317 __pyx_t_7 = (__pyx_v_c->negative != 0);
5318 if (__pyx_t_7) {
5319
5320 /* "gensim/models/fasttext_inner.pyx":566
5321 * fasttext_fast_sentence_sg_hs(c, i, j)
5322 * if c.negative:
5323 * fasttext_fast_sentence_sg_neg(c, i, j) # <<<<<<<<<<<<<<
5324 *
5325 *
5326 */
5327 __pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_sg_neg(__pyx_v_c, __pyx_v_i, __pyx_v_j);
5328
5329 /* "gensim/models/fasttext_inner.pyx":565
5330 * if c.hs:
5331 * fasttext_fast_sentence_sg_hs(c, i, j)
5332 * if c.negative: # <<<<<<<<<<<<<<
5333 * fasttext_fast_sentence_sg_neg(c, i, j)
5334 *
5335 */
5336 }
5337 __pyx_L12_continue:;
5338 }
5339 }
5340 __pyx_L9:;
5341 }
5342 }
5343
5344 /* "gensim/models/fasttext_inner.pyx":512
5345 *
5346 *
5347 * cdef void fasttext_train_any(FastTextConfig *c, int num_sentences) nogil: # <<<<<<<<<<<<<<
5348 * """Performs training on a fully initialized and populated configuration.
5349 *
5350 */
5351
5352 /* function exit code */
5353 }
5354
5355 /* "gensim/models/fasttext_inner.pyx":569
5356 *
5357 *
5358 * def train_batch_any(model, sentences, alpha, _work, _neu1): # <<<<<<<<<<<<<<
5359 * """Update the model by training on a sequence of sentences.
5360 *
5361 */
5362
5363 /* Python wrapper */
5364 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_1train_batch_any(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5365 static char __pyx_doc_6gensim_6models_14fasttext_inner_train_batch_any[] = "train_batch_any(model, sentences, alpha, _work, _neu1)\nUpdate the model by training on a sequence of sentences.\n\n Each sentence is a list of string tokens, which are looked up in the model's\n vocab dictionary. Called internally from :meth:`~gensim.models.fasttext.FastText.train`.\n\n Parameters\n ----------\n model : :class:`~gensim.models.fasttext.FastText`\n Model to be trained.\n sentences : iterable of list of str\n A single batch: part of the corpus streamed directly from disk/network.\n alpha : float\n Learning rate.\n _work : np.ndarray\n Private working memory for each worker.\n _neu1 : np.ndarray\n Private working memory for each worker.\n\n Returns\n -------\n int\n Effective number of words trained.\n\n ";
5366 static PyMethodDef __pyx_mdef_6gensim_6models_14fasttext_inner_1train_batch_any = {"train_batch_any", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gensim_6models_14fasttext_inner_1train_batch_any, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gensim_6models_14fasttext_inner_train_batch_any};
__pyx_pw_6gensim_6models_14fasttext_inner_1train_batch_any(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)5367 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_1train_batch_any(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5368 PyObject *__pyx_v_model = 0;
5369 PyObject *__pyx_v_sentences = 0;
5370 PyObject *__pyx_v_alpha = 0;
5371 PyObject *__pyx_v__work = 0;
5372 PyObject *__pyx_v__neu1 = 0;
5373 int __pyx_lineno = 0;
5374 const char *__pyx_filename = NULL;
5375 int __pyx_clineno = 0;
5376 PyObject *__pyx_r = 0;
5377 __Pyx_RefNannyDeclarations
5378 __Pyx_RefNannySetupContext("train_batch_any (wrapper)", 0);
5379 {
5380 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_model,&__pyx_n_s_sentences,&__pyx_n_s_alpha,&__pyx_n_s_work,&__pyx_n_s_neu1,0};
5381 PyObject* values[5] = {0,0,0,0,0};
5382 if (unlikely(__pyx_kwds)) {
5383 Py_ssize_t kw_args;
5384 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5385 switch (pos_args) {
5386 case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
5387 CYTHON_FALLTHROUGH;
5388 case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5389 CYTHON_FALLTHROUGH;
5390 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5391 CYTHON_FALLTHROUGH;
5392 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5393 CYTHON_FALLTHROUGH;
5394 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5395 CYTHON_FALLTHROUGH;
5396 case 0: break;
5397 default: goto __pyx_L5_argtuple_error;
5398 }
5399 kw_args = PyDict_Size(__pyx_kwds);
5400 switch (pos_args) {
5401 case 0:
5402 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_model)) != 0)) kw_args--;
5403 else goto __pyx_L5_argtuple_error;
5404 CYTHON_FALLTHROUGH;
5405 case 1:
5406 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentences)) != 0)) kw_args--;
5407 else {
5408 __Pyx_RaiseArgtupleInvalid("train_batch_any", 1, 5, 5, 1); __PYX_ERR(0, 569, __pyx_L3_error)
5409 }
5410 CYTHON_FALLTHROUGH;
5411 case 2:
5412 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
5413 else {
5414 __Pyx_RaiseArgtupleInvalid("train_batch_any", 1, 5, 5, 2); __PYX_ERR(0, 569, __pyx_L3_error)
5415 }
5416 CYTHON_FALLTHROUGH;
5417 case 3:
5418 if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_work)) != 0)) kw_args--;
5419 else {
5420 __Pyx_RaiseArgtupleInvalid("train_batch_any", 1, 5, 5, 3); __PYX_ERR(0, 569, __pyx_L3_error)
5421 }
5422 CYTHON_FALLTHROUGH;
5423 case 4:
5424 if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_neu1)) != 0)) kw_args--;
5425 else {
5426 __Pyx_RaiseArgtupleInvalid("train_batch_any", 1, 5, 5, 4); __PYX_ERR(0, 569, __pyx_L3_error)
5427 }
5428 }
5429 if (unlikely(kw_args > 0)) {
5430 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "train_batch_any") < 0)) __PYX_ERR(0, 569, __pyx_L3_error)
5431 }
5432 } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
5433 goto __pyx_L5_argtuple_error;
5434 } else {
5435 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5436 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5437 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5438 values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5439 values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
5440 }
5441 __pyx_v_model = values[0];
5442 __pyx_v_sentences = values[1];
5443 __pyx_v_alpha = values[2];
5444 __pyx_v__work = values[3];
5445 __pyx_v__neu1 = values[4];
5446 }
5447 goto __pyx_L4_argument_unpacking_done;
5448 __pyx_L5_argtuple_error:;
5449 __Pyx_RaiseArgtupleInvalid("train_batch_any", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 569, __pyx_L3_error)
5450 __pyx_L3_error:;
5451 __Pyx_AddTraceback("gensim.models.fasttext_inner.train_batch_any", __pyx_clineno, __pyx_lineno, __pyx_filename);
5452 __Pyx_RefNannyFinishContext();
5453 return NULL;
5454 __pyx_L4_argument_unpacking_done:;
5455 __pyx_r = __pyx_pf_6gensim_6models_14fasttext_inner_train_batch_any(__pyx_self, __pyx_v_model, __pyx_v_sentences, __pyx_v_alpha, __pyx_v__work, __pyx_v__neu1);
5456
5457 /* function exit code */
5458 __Pyx_RefNannyFinishContext();
5459 return __pyx_r;
5460 }
5461
__pyx_pf_6gensim_6models_14fasttext_inner_train_batch_any(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_model,PyObject * __pyx_v_sentences,PyObject * __pyx_v_alpha,PyObject * __pyx_v__work,PyObject * __pyx_v__neu1)5462 static PyObject *__pyx_pf_6gensim_6models_14fasttext_inner_train_batch_any(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_model, PyObject *__pyx_v_sentences, PyObject *__pyx_v_alpha, PyObject *__pyx_v__work, PyObject *__pyx_v__neu1) {
5463 struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig __pyx_v_c;
5464 int __pyx_v_num_words;
5465 int __pyx_v_num_sentences;
5466 PyObject *__pyx_v_i = NULL;
5467 PyObject *__pyx_v_randint = NULL;
5468 PyObject *__pyx_r = NULL;
5469 __Pyx_RefNannyDeclarations
5470 PyObject *__pyx_t_1 = NULL;
5471 PyObject *__pyx_t_2 = NULL;
5472 PyObject *__pyx_t_3 = NULL;
5473 PyObject *__pyx_t_4 = NULL;
5474 PyObject *(*__pyx_t_5)(PyObject *);
5475 int __pyx_t_6;
5476 int __pyx_t_7;
5477 PyObject *__pyx_t_8 = NULL;
5478 PyObject *__pyx_t_9 = NULL;
5479 PyObject *__pyx_t_10 = NULL;
5480 Py_ssize_t __pyx_t_11;
5481 PyObject *(*__pyx_t_12)(PyObject *);
5482 __pyx_t_5numpy_uint32_t __pyx_t_13;
5483 Py_ssize_t __pyx_t_14;
5484 int __pyx_lineno = 0;
5485 const char *__pyx_filename = NULL;
5486 int __pyx_clineno = 0;
5487 __Pyx_RefNannySetupContext("train_batch_any", 0);
5488
5489 /* "gensim/models/fasttext_inner.pyx":596
5490 * cdef:
5491 * FastTextConfig c
5492 * int num_words = 0 # <<<<<<<<<<<<<<
5493 * int num_sentences = 0
5494 *
5495 */
5496 __pyx_v_num_words = 0;
5497
5498 /* "gensim/models/fasttext_inner.pyx":597
5499 * FastTextConfig c
5500 * int num_words = 0
5501 * int num_sentences = 0 # <<<<<<<<<<<<<<
5502 *
5503 * init_ft_config(&c, model, alpha, _work, _neu1)
5504 */
5505 __pyx_v_num_sentences = 0;
5506
5507 /* "gensim/models/fasttext_inner.pyx":599
5508 * int num_sentences = 0
5509 *
5510 * init_ft_config(&c, model, alpha, _work, _neu1) # <<<<<<<<<<<<<<
5511 *
5512 * num_words, num_sentences = populate_ft_config(&c, model.wv, model.wv.buckets_word, sentences)
5513 */
5514 __pyx_f_6gensim_6models_14fasttext_inner_init_ft_config((&__pyx_v_c), __pyx_v_model, __pyx_v_alpha, __pyx_v__work, __pyx_v__neu1);
5515
5516 /* "gensim/models/fasttext_inner.pyx":601
5517 * init_ft_config(&c, model, alpha, _work, _neu1)
5518 *
5519 * num_words, num_sentences = populate_ft_config(&c, model.wv, model.wv.buckets_word, sentences) # <<<<<<<<<<<<<<
5520 *
5521 * # precompute "reduced window" offsets in a single randint() call
5522 */
5523 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_wv); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 601, __pyx_L1_error)
5524 __Pyx_GOTREF(__pyx_t_1);
5525 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_wv); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 601, __pyx_L1_error)
5526 __Pyx_GOTREF(__pyx_t_2);
5527 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_buckets_word); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 601, __pyx_L1_error)
5528 __Pyx_GOTREF(__pyx_t_3);
5529 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5530 __pyx_t_2 = __pyx_f_6gensim_6models_14fasttext_inner_populate_ft_config((&__pyx_v_c), __pyx_t_1, __pyx_t_3, __pyx_v_sentences); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 601, __pyx_L1_error)
5531 __Pyx_GOTREF(__pyx_t_2);
5532 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5533 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5534 if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
5535 PyObject* sequence = __pyx_t_2;
5536 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
5537 if (unlikely(size != 2)) {
5538 if (size > 2) __Pyx_RaiseTooManyValuesError(2);
5539 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
5540 __PYX_ERR(0, 601, __pyx_L1_error)
5541 }
5542 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5543 if (likely(PyTuple_CheckExact(sequence))) {
5544 __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
5545 __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1);
5546 } else {
5547 __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
5548 __pyx_t_1 = PyList_GET_ITEM(sequence, 1);
5549 }
5550 __Pyx_INCREF(__pyx_t_3);
5551 __Pyx_INCREF(__pyx_t_1);
5552 #else
5553 __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 601, __pyx_L1_error)
5554 __Pyx_GOTREF(__pyx_t_3);
5555 __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 601, __pyx_L1_error)
5556 __Pyx_GOTREF(__pyx_t_1);
5557 #endif
5558 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5559 } else {
5560 Py_ssize_t index = -1;
5561 __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 601, __pyx_L1_error)
5562 __Pyx_GOTREF(__pyx_t_4);
5563 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5564 __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
5565 index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
5566 __Pyx_GOTREF(__pyx_t_3);
5567 index = 1; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
5568 __Pyx_GOTREF(__pyx_t_1);
5569 if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 601, __pyx_L1_error)
5570 __pyx_t_5 = NULL;
5571 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5572 goto __pyx_L4_unpacking_done;
5573 __pyx_L3_unpacking_failed:;
5574 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5575 __pyx_t_5 = NULL;
5576 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
5577 __PYX_ERR(0, 601, __pyx_L1_error)
5578 __pyx_L4_unpacking_done:;
5579 }
5580 __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 601, __pyx_L1_error)
5581 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5582 __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 601, __pyx_L1_error)
5583 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5584 __pyx_v_num_words = __pyx_t_6;
5585 __pyx_v_num_sentences = __pyx_t_7;
5586
5587 /* "gensim/models/fasttext_inner.pyx":604
5588 *
5589 * # precompute "reduced window" offsets in a single randint() call
5590 * for i, randint in enumerate(model.random.randint(0, c.window, num_words)): # <<<<<<<<<<<<<<
5591 * c.reduced_windows[i] = randint
5592 *
5593 */
5594 __Pyx_INCREF(__pyx_int_0);
5595 __pyx_t_2 = __pyx_int_0;
5596 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_model, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 604, __pyx_L1_error)
5597 __Pyx_GOTREF(__pyx_t_3);
5598 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_randint); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 604, __pyx_L1_error)
5599 __Pyx_GOTREF(__pyx_t_4);
5600 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5601 __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_c.window); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 604, __pyx_L1_error)
5602 __Pyx_GOTREF(__pyx_t_3);
5603 __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_num_words); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 604, __pyx_L1_error)
5604 __Pyx_GOTREF(__pyx_t_8);
5605 __pyx_t_9 = NULL;
5606 __pyx_t_7 = 0;
5607 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
5608 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
5609 if (likely(__pyx_t_9)) {
5610 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
5611 __Pyx_INCREF(__pyx_t_9);
5612 __Pyx_INCREF(function);
5613 __Pyx_DECREF_SET(__pyx_t_4, function);
5614 __pyx_t_7 = 1;
5615 }
5616 }
5617 #if CYTHON_FAST_PYCALL
5618 if (PyFunction_Check(__pyx_t_4)) {
5619 PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_int_0, __pyx_t_3, __pyx_t_8};
5620 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
5621 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
5622 __Pyx_GOTREF(__pyx_t_1);
5623 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5624 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5625 } else
5626 #endif
5627 #if CYTHON_FAST_PYCCALL
5628 if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
5629 PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_int_0, __pyx_t_3, __pyx_t_8};
5630 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
5631 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
5632 __Pyx_GOTREF(__pyx_t_1);
5633 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5634 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5635 } else
5636 #endif
5637 {
5638 __pyx_t_10 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 604, __pyx_L1_error)
5639 __Pyx_GOTREF(__pyx_t_10);
5640 if (__pyx_t_9) {
5641 __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
5642 }
5643 __Pyx_INCREF(__pyx_int_0);
5644 __Pyx_GIVEREF(__pyx_int_0);
5645 PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_7, __pyx_int_0);
5646 __Pyx_GIVEREF(__pyx_t_3);
5647 PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_7, __pyx_t_3);
5648 __Pyx_GIVEREF(__pyx_t_8);
5649 PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_7, __pyx_t_8);
5650 __pyx_t_3 = 0;
5651 __pyx_t_8 = 0;
5652 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
5653 __Pyx_GOTREF(__pyx_t_1);
5654 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5655 }
5656 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5657 if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
5658 __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_11 = 0;
5659 __pyx_t_12 = NULL;
5660 } else {
5661 __pyx_t_11 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 604, __pyx_L1_error)
5662 __Pyx_GOTREF(__pyx_t_4);
5663 __pyx_t_12 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 604, __pyx_L1_error)
5664 }
5665 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5666 for (;;) {
5667 if (likely(!__pyx_t_12)) {
5668 if (likely(PyList_CheckExact(__pyx_t_4))) {
5669 if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_4)) break;
5670 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5671 __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 604, __pyx_L1_error)
5672 #else
5673 __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
5674 __Pyx_GOTREF(__pyx_t_1);
5675 #endif
5676 } else {
5677 if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
5678 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5679 __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 604, __pyx_L1_error)
5680 #else
5681 __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
5682 __Pyx_GOTREF(__pyx_t_1);
5683 #endif
5684 }
5685 } else {
5686 __pyx_t_1 = __pyx_t_12(__pyx_t_4);
5687 if (unlikely(!__pyx_t_1)) {
5688 PyObject* exc_type = PyErr_Occurred();
5689 if (exc_type) {
5690 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
5691 else __PYX_ERR(0, 604, __pyx_L1_error)
5692 }
5693 break;
5694 }
5695 __Pyx_GOTREF(__pyx_t_1);
5696 }
5697 __Pyx_XDECREF_SET(__pyx_v_randint, __pyx_t_1);
5698 __pyx_t_1 = 0;
5699 __Pyx_INCREF(__pyx_t_2);
5700 __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
5701 __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
5702 __Pyx_GOTREF(__pyx_t_1);
5703 __Pyx_DECREF(__pyx_t_2);
5704 __pyx_t_2 = __pyx_t_1;
5705 __pyx_t_1 = 0;
5706
5707 /* "gensim/models/fasttext_inner.pyx":605
5708 * # precompute "reduced window" offsets in a single randint() call
5709 * for i, randint in enumerate(model.random.randint(0, c.window, num_words)):
5710 * c.reduced_windows[i] = randint # <<<<<<<<<<<<<<
5711 *
5712 * # release GIL & train on all sentences in the batch
5713 */
5714 __pyx_t_13 = __Pyx_PyInt_As_npy_uint32(__pyx_v_randint); if (unlikely((__pyx_t_13 == ((npy_uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 605, __pyx_L1_error)
5715 __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 605, __pyx_L1_error)
5716 (__pyx_v_c.reduced_windows[__pyx_t_14]) = __pyx_t_13;
5717
5718 /* "gensim/models/fasttext_inner.pyx":604
5719 *
5720 * # precompute "reduced window" offsets in a single randint() call
5721 * for i, randint in enumerate(model.random.randint(0, c.window, num_words)): # <<<<<<<<<<<<<<
5722 * c.reduced_windows[i] = randint
5723 *
5724 */
5725 }
5726 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5727 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5728
5729 /* "gensim/models/fasttext_inner.pyx":608
5730 *
5731 * # release GIL & train on all sentences in the batch
5732 * with nogil: # <<<<<<<<<<<<<<
5733 * fasttext_train_any(&c, num_sentences)
5734 *
5735 */
5736 {
5737 #ifdef WITH_THREAD
5738 PyThreadState *_save;
5739 Py_UNBLOCK_THREADS
5740 __Pyx_FastGIL_Remember();
5741 #endif
5742 /*try:*/ {
5743
5744 /* "gensim/models/fasttext_inner.pyx":609
5745 * # release GIL & train on all sentences in the batch
5746 * with nogil:
5747 * fasttext_train_any(&c, num_sentences) # <<<<<<<<<<<<<<
5748 *
5749 * return num_words
5750 */
5751 __pyx_f_6gensim_6models_14fasttext_inner_fasttext_train_any((&__pyx_v_c), __pyx_v_num_sentences);
5752 }
5753
5754 /* "gensim/models/fasttext_inner.pyx":608
5755 *
5756 * # release GIL & train on all sentences in the batch
5757 * with nogil: # <<<<<<<<<<<<<<
5758 * fasttext_train_any(&c, num_sentences)
5759 *
5760 */
5761 /*finally:*/ {
5762 /*normal exit:*/{
5763 #ifdef WITH_THREAD
5764 __Pyx_FastGIL_Forget();
5765 Py_BLOCK_THREADS
5766 #endif
5767 goto __pyx_L9;
5768 }
5769 __pyx_L9:;
5770 }
5771 }
5772
5773 /* "gensim/models/fasttext_inner.pyx":611
5774 * fasttext_train_any(&c, num_sentences)
5775 *
5776 * return num_words # <<<<<<<<<<<<<<
5777 *
5778 *
5779 */
5780 __Pyx_XDECREF(__pyx_r);
5781 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_num_words); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error)
5782 __Pyx_GOTREF(__pyx_t_2);
5783 __pyx_r = __pyx_t_2;
5784 __pyx_t_2 = 0;
5785 goto __pyx_L0;
5786
5787 /* "gensim/models/fasttext_inner.pyx":569
5788 *
5789 *
5790 * def train_batch_any(model, sentences, alpha, _work, _neu1): # <<<<<<<<<<<<<<
5791 * """Update the model by training on a sequence of sentences.
5792 *
5793 */
5794
5795 /* function exit code */
5796 __pyx_L1_error:;
5797 __Pyx_XDECREF(__pyx_t_1);
5798 __Pyx_XDECREF(__pyx_t_2);
5799 __Pyx_XDECREF(__pyx_t_3);
5800 __Pyx_XDECREF(__pyx_t_4);
5801 __Pyx_XDECREF(__pyx_t_8);
5802 __Pyx_XDECREF(__pyx_t_9);
5803 __Pyx_XDECREF(__pyx_t_10);
5804 __Pyx_AddTraceback("gensim.models.fasttext_inner.train_batch_any", __pyx_clineno, __pyx_lineno, __pyx_filename);
5805 __pyx_r = NULL;
5806 __pyx_L0:;
5807 __Pyx_XDECREF(__pyx_v_i);
5808 __Pyx_XDECREF(__pyx_v_randint);
5809 __Pyx_XGIVEREF(__pyx_r);
5810 __Pyx_RefNannyFinishContext();
5811 return __pyx_r;
5812 }
5813
5814 /* "gensim/models/fasttext_inner.pyx":614
5815 *
5816 *
5817 * cpdef ft_hash_bytes(bytes bytez): # <<<<<<<<<<<<<<
5818 * """Calculate hash based on `bytez`.
5819 * Reproduce `hash method from Facebook fastText implementation
5820 */
5821
5822 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_3ft_hash_bytes(PyObject *__pyx_self, PyObject *__pyx_v_bytez); /*proto*/
__pyx_f_6gensim_6models_14fasttext_inner_ft_hash_bytes(PyObject * __pyx_v_bytez,CYTHON_UNUSED int __pyx_skip_dispatch)5823 static PyObject *__pyx_f_6gensim_6models_14fasttext_inner_ft_hash_bytes(PyObject *__pyx_v_bytez, CYTHON_UNUSED int __pyx_skip_dispatch) {
5824 __pyx_t_5numpy_uint32_t __pyx_v_h;
5825 char __pyx_v_b;
5826 PyObject *__pyx_r = NULL;
5827 __Pyx_RefNannyDeclarations
5828 PyObject *__pyx_t_1 = NULL;
5829 char *__pyx_t_2;
5830 char *__pyx_t_3;
5831 char *__pyx_t_4;
5832 char *__pyx_t_5;
5833 PyObject *__pyx_t_6 = NULL;
5834 int __pyx_lineno = 0;
5835 const char *__pyx_filename = NULL;
5836 int __pyx_clineno = 0;
5837 __Pyx_RefNannySetupContext("ft_hash_bytes", 0);
5838
5839 /* "gensim/models/fasttext_inner.pyx":630
5840 *
5841 * """
5842 * cdef np.uint32_t h = 2166136261 # <<<<<<<<<<<<<<
5843 * cdef char b
5844 *
5845 */
5846 __pyx_v_h = 0x811C9DC5;
5847
5848 /* "gensim/models/fasttext_inner.pyx":633
5849 * cdef char b
5850 *
5851 * for b in bytez: # <<<<<<<<<<<<<<
5852 * h = h ^ <np.uint32_t>(<np.int8_t>b)
5853 * h = h * 16777619
5854 */
5855 if (unlikely(__pyx_v_bytez == Py_None)) {
5856 PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
5857 __PYX_ERR(0, 633, __pyx_L1_error)
5858 }
5859 __Pyx_INCREF(__pyx_v_bytez);
5860 __pyx_t_1 = __pyx_v_bytez;
5861 __pyx_t_3 = PyBytes_AS_STRING(__pyx_t_1);
5862 __pyx_t_4 = (__pyx_t_3 + PyBytes_GET_SIZE(__pyx_t_1));
5863 for (__pyx_t_5 = __pyx_t_3; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
5864 __pyx_t_2 = __pyx_t_5;
5865 __pyx_v_b = (__pyx_t_2[0]);
5866
5867 /* "gensim/models/fasttext_inner.pyx":634
5868 *
5869 * for b in bytez:
5870 * h = h ^ <np.uint32_t>(<np.int8_t>b) # <<<<<<<<<<<<<<
5871 * h = h * 16777619
5872 * return h
5873 */
5874 __pyx_v_h = (__pyx_v_h ^ ((__pyx_t_5numpy_uint32_t)((__pyx_t_5numpy_int8_t)__pyx_v_b)));
5875
5876 /* "gensim/models/fasttext_inner.pyx":635
5877 * for b in bytez:
5878 * h = h ^ <np.uint32_t>(<np.int8_t>b)
5879 * h = h * 16777619 # <<<<<<<<<<<<<<
5880 * return h
5881 *
5882 */
5883 __pyx_v_h = (__pyx_v_h * 0x1000193);
5884 }
5885 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5886
5887 /* "gensim/models/fasttext_inner.pyx":636
5888 * h = h ^ <np.uint32_t>(<np.int8_t>b)
5889 * h = h * 16777619
5890 * return h # <<<<<<<<<<<<<<
5891 *
5892 *
5893 */
5894 __Pyx_XDECREF(__pyx_r);
5895 __pyx_t_6 = __Pyx_PyInt_From_npy_uint32(__pyx_v_h); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 636, __pyx_L1_error)
5896 __Pyx_GOTREF(__pyx_t_6);
5897 __pyx_r = __pyx_t_6;
5898 __pyx_t_6 = 0;
5899 goto __pyx_L0;
5900
5901 /* "gensim/models/fasttext_inner.pyx":614
5902 *
5903 *
5904 * cpdef ft_hash_bytes(bytes bytez): # <<<<<<<<<<<<<<
5905 * """Calculate hash based on `bytez`.
5906 * Reproduce `hash method from Facebook fastText implementation
5907 */
5908
5909 /* function exit code */
5910 __pyx_L1_error:;
5911 __Pyx_XDECREF(__pyx_t_1);
5912 __Pyx_XDECREF(__pyx_t_6);
5913 __Pyx_AddTraceback("gensim.models.fasttext_inner.ft_hash_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
5914 __pyx_r = 0;
5915 __pyx_L0:;
5916 __Pyx_XGIVEREF(__pyx_r);
5917 __Pyx_RefNannyFinishContext();
5918 return __pyx_r;
5919 }
5920
5921 /* Python wrapper */
5922 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_3ft_hash_bytes(PyObject *__pyx_self, PyObject *__pyx_v_bytez); /*proto*/
5923 static char __pyx_doc_6gensim_6models_14fasttext_inner_2ft_hash_bytes[] = "ft_hash_bytes(bytes bytez)\nCalculate hash based on `bytez`.\n Reproduce `hash method from Facebook fastText implementation\n <https://github.com/facebookresearch/fastText/blob/master/src/dictionary.cc>`_.\n\n Parameters\n ----------\n bytez : bytes\n The string whose hash needs to be calculated, encoded as UTF-8.\n\n Returns\n -------\n unsigned int\n The hash of the string.\n\n ";
__pyx_pw_6gensim_6models_14fasttext_inner_3ft_hash_bytes(PyObject * __pyx_self,PyObject * __pyx_v_bytez)5924 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_3ft_hash_bytes(PyObject *__pyx_self, PyObject *__pyx_v_bytez) {
5925 int __pyx_lineno = 0;
5926 const char *__pyx_filename = NULL;
5927 int __pyx_clineno = 0;
5928 PyObject *__pyx_r = 0;
5929 __Pyx_RefNannyDeclarations
5930 __Pyx_RefNannySetupContext("ft_hash_bytes (wrapper)", 0);
5931 if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bytez), (&PyBytes_Type), 1, "bytez", 1))) __PYX_ERR(0, 614, __pyx_L1_error)
5932 __pyx_r = __pyx_pf_6gensim_6models_14fasttext_inner_2ft_hash_bytes(__pyx_self, ((PyObject*)__pyx_v_bytez));
5933
5934 /* function exit code */
5935 goto __pyx_L0;
5936 __pyx_L1_error:;
5937 __pyx_r = NULL;
5938 __pyx_L0:;
5939 __Pyx_RefNannyFinishContext();
5940 return __pyx_r;
5941 }
5942
__pyx_pf_6gensim_6models_14fasttext_inner_2ft_hash_bytes(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_bytez)5943 static PyObject *__pyx_pf_6gensim_6models_14fasttext_inner_2ft_hash_bytes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_bytez) {
5944 PyObject *__pyx_r = NULL;
5945 __Pyx_RefNannyDeclarations
5946 PyObject *__pyx_t_1 = NULL;
5947 int __pyx_lineno = 0;
5948 const char *__pyx_filename = NULL;
5949 int __pyx_clineno = 0;
5950 __Pyx_RefNannySetupContext("ft_hash_bytes", 0);
5951 __Pyx_XDECREF(__pyx_r);
5952 __pyx_t_1 = __pyx_f_6gensim_6models_14fasttext_inner_ft_hash_bytes(__pyx_v_bytez, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 614, __pyx_L1_error)
5953 __Pyx_GOTREF(__pyx_t_1);
5954 __pyx_r = __pyx_t_1;
5955 __pyx_t_1 = 0;
5956 goto __pyx_L0;
5957
5958 /* function exit code */
5959 __pyx_L1_error:;
5960 __Pyx_XDECREF(__pyx_t_1);
5961 __Pyx_AddTraceback("gensim.models.fasttext_inner.ft_hash_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
5962 __pyx_r = NULL;
5963 __pyx_L0:;
5964 __Pyx_XGIVEREF(__pyx_r);
5965 __Pyx_RefNannyFinishContext();
5966 return __pyx_r;
5967 }
5968
5969 /* "gensim/models/fasttext_inner.pyx":639
5970 *
5971 *
5972 * cpdef compute_ngrams(word, unsigned int min_n, unsigned int max_n): # <<<<<<<<<<<<<<
5973 * """Get the list of all possible ngrams for a given word.
5974 *
5975 */
5976
5977 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_5compute_ngrams(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_6gensim_6models_14fasttext_inner_compute_ngrams(PyObject * __pyx_v_word,unsigned int __pyx_v_min_n,unsigned int __pyx_v_max_n,CYTHON_UNUSED int __pyx_skip_dispatch)5978 static PyObject *__pyx_f_6gensim_6models_14fasttext_inner_compute_ngrams(PyObject *__pyx_v_word, unsigned int __pyx_v_min_n, unsigned int __pyx_v_max_n, CYTHON_UNUSED int __pyx_skip_dispatch) {
5979 PyObject *__pyx_v_extended_word = 0;
5980 PyObject *__pyx_v_ngrams = NULL;
5981 PyObject *__pyx_v_ngram_length = NULL;
5982 PyObject *__pyx_v_i = NULL;
5983 PyObject *__pyx_r = NULL;
5984 __Pyx_RefNannyDeclarations
5985 PyObject *__pyx_t_1 = NULL;
5986 Py_ssize_t __pyx_t_2;
5987 Py_UCS4 __pyx_t_3;
5988 PyObject *__pyx_t_4 = NULL;
5989 unsigned int __pyx_t_5;
5990 Py_ssize_t __pyx_t_6;
5991 PyObject *__pyx_t_7 = NULL;
5992 PyObject *(*__pyx_t_8)(PyObject *);
5993 PyObject *(*__pyx_t_9)(PyObject *);
5994 Py_ssize_t __pyx_t_10;
5995 int __pyx_t_11;
5996 Py_ssize_t __pyx_t_12;
5997 Py_ssize_t __pyx_t_13;
5998 int __pyx_t_14;
5999 int __pyx_lineno = 0;
6000 const char *__pyx_filename = NULL;
6001 int __pyx_clineno = 0;
6002 __Pyx_RefNannySetupContext("compute_ngrams", 0);
6003
6004 /* "gensim/models/fasttext_inner.pyx":657
6005 *
6006 * """
6007 * cdef unicode extended_word = f'<{word}>' # <<<<<<<<<<<<<<
6008 * ngrams = []
6009 * for ngram_length in range(min_n, min(len(extended_word), max_n) + 1):
6010 */
6011 __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 657, __pyx_L1_error)
6012 __Pyx_GOTREF(__pyx_t_1);
6013 __pyx_t_2 = 0;
6014 __pyx_t_3 = 127;
6015 __Pyx_INCREF(__pyx_kp_u__2);
6016 __pyx_t_2 += 1;
6017 __Pyx_GIVEREF(__pyx_kp_u__2);
6018 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__2);
6019 __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_v_word, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 657, __pyx_L1_error)
6020 __Pyx_GOTREF(__pyx_t_4);
6021 __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3;
6022 __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
6023 __Pyx_GIVEREF(__pyx_t_4);
6024 PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
6025 __pyx_t_4 = 0;
6026 __Pyx_INCREF(__pyx_kp_u__3);
6027 __pyx_t_2 += 1;
6028 __Pyx_GIVEREF(__pyx_kp_u__3);
6029 PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__3);
6030 __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 657, __pyx_L1_error)
6031 __Pyx_GOTREF(__pyx_t_4);
6032 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6033 __pyx_v_extended_word = ((PyObject*)__pyx_t_4);
6034 __pyx_t_4 = 0;
6035
6036 /* "gensim/models/fasttext_inner.pyx":658
6037 * """
6038 * cdef unicode extended_word = f'<{word}>'
6039 * ngrams = [] # <<<<<<<<<<<<<<
6040 * for ngram_length in range(min_n, min(len(extended_word), max_n) + 1):
6041 * for i in range(0, len(extended_word) - ngram_length + 1):
6042 */
6043 __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 658, __pyx_L1_error)
6044 __Pyx_GOTREF(__pyx_t_4);
6045 __pyx_v_ngrams = ((PyObject*)__pyx_t_4);
6046 __pyx_t_4 = 0;
6047
6048 /* "gensim/models/fasttext_inner.pyx":659
6049 * cdef unicode extended_word = f'<{word}>'
6050 * ngrams = []
6051 * for ngram_length in range(min_n, min(len(extended_word), max_n) + 1): # <<<<<<<<<<<<<<
6052 * for i in range(0, len(extended_word) - ngram_length + 1):
6053 * ngrams.append(extended_word[i:i + ngram_length])
6054 */
6055 __pyx_t_4 = __Pyx_PyInt_From_unsigned_int(__pyx_v_min_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 659, __pyx_L1_error)
6056 __Pyx_GOTREF(__pyx_t_4);
6057 __pyx_t_5 = __pyx_v_max_n;
6058 __pyx_t_2 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_extended_word); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 659, __pyx_L1_error)
6059 if (((__pyx_t_5 < __pyx_t_2) != 0)) {
6060 __pyx_t_6 = __pyx_t_5;
6061 } else {
6062 __pyx_t_6 = __pyx_t_2;
6063 }
6064 __pyx_t_1 = PyInt_FromSsize_t((__pyx_t_6 + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error)
6065 __Pyx_GOTREF(__pyx_t_1);
6066 __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 659, __pyx_L1_error)
6067 __Pyx_GOTREF(__pyx_t_7);
6068 __Pyx_GIVEREF(__pyx_t_4);
6069 PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
6070 __Pyx_GIVEREF(__pyx_t_1);
6071 PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1);
6072 __pyx_t_4 = 0;
6073 __pyx_t_1 = 0;
6074 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error)
6075 __Pyx_GOTREF(__pyx_t_1);
6076 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
6077 if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
6078 __pyx_t_7 = __pyx_t_1; __Pyx_INCREF(__pyx_t_7); __pyx_t_6 = 0;
6079 __pyx_t_8 = NULL;
6080 } else {
6081 __pyx_t_6 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 659, __pyx_L1_error)
6082 __Pyx_GOTREF(__pyx_t_7);
6083 __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 659, __pyx_L1_error)
6084 }
6085 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6086 for (;;) {
6087 if (likely(!__pyx_t_8)) {
6088 if (likely(PyList_CheckExact(__pyx_t_7))) {
6089 if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_7)) break;
6090 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6091 __pyx_t_1 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 659, __pyx_L1_error)
6092 #else
6093 __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error)
6094 __Pyx_GOTREF(__pyx_t_1);
6095 #endif
6096 } else {
6097 if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
6098 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6099 __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 659, __pyx_L1_error)
6100 #else
6101 __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error)
6102 __Pyx_GOTREF(__pyx_t_1);
6103 #endif
6104 }
6105 } else {
6106 __pyx_t_1 = __pyx_t_8(__pyx_t_7);
6107 if (unlikely(!__pyx_t_1)) {
6108 PyObject* exc_type = PyErr_Occurred();
6109 if (exc_type) {
6110 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
6111 else __PYX_ERR(0, 659, __pyx_L1_error)
6112 }
6113 break;
6114 }
6115 __Pyx_GOTREF(__pyx_t_1);
6116 }
6117 __Pyx_XDECREF_SET(__pyx_v_ngram_length, __pyx_t_1);
6118 __pyx_t_1 = 0;
6119
6120 /* "gensim/models/fasttext_inner.pyx":660
6121 * ngrams = []
6122 * for ngram_length in range(min_n, min(len(extended_word), max_n) + 1):
6123 * for i in range(0, len(extended_word) - ngram_length + 1): # <<<<<<<<<<<<<<
6124 * ngrams.append(extended_word[i:i + ngram_length])
6125 * return ngrams
6126 */
6127 __pyx_t_2 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_extended_word); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 660, __pyx_L1_error)
6128 __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error)
6129 __Pyx_GOTREF(__pyx_t_1);
6130 __pyx_t_4 = PyNumber_Subtract(__pyx_t_1, __pyx_v_ngram_length); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L1_error)
6131 __Pyx_GOTREF(__pyx_t_4);
6132 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6133 __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error)
6134 __Pyx_GOTREF(__pyx_t_1);
6135 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6136 __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L1_error)
6137 __Pyx_GOTREF(__pyx_t_4);
6138 __Pyx_INCREF(__pyx_int_0);
6139 __Pyx_GIVEREF(__pyx_int_0);
6140 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_0);
6141 __Pyx_GIVEREF(__pyx_t_1);
6142 PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
6143 __pyx_t_1 = 0;
6144 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error)
6145 __Pyx_GOTREF(__pyx_t_1);
6146 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6147 if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
6148 __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0;
6149 __pyx_t_9 = NULL;
6150 } else {
6151 __pyx_t_2 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L1_error)
6152 __Pyx_GOTREF(__pyx_t_4);
6153 __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 660, __pyx_L1_error)
6154 }
6155 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6156 for (;;) {
6157 if (likely(!__pyx_t_9)) {
6158 if (likely(PyList_CheckExact(__pyx_t_4))) {
6159 if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_4)) break;
6160 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6161 __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 660, __pyx_L1_error)
6162 #else
6163 __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error)
6164 __Pyx_GOTREF(__pyx_t_1);
6165 #endif
6166 } else {
6167 if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
6168 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6169 __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 660, __pyx_L1_error)
6170 #else
6171 __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error)
6172 __Pyx_GOTREF(__pyx_t_1);
6173 #endif
6174 }
6175 } else {
6176 __pyx_t_1 = __pyx_t_9(__pyx_t_4);
6177 if (unlikely(!__pyx_t_1)) {
6178 PyObject* exc_type = PyErr_Occurred();
6179 if (exc_type) {
6180 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
6181 else __PYX_ERR(0, 660, __pyx_L1_error)
6182 }
6183 break;
6184 }
6185 __Pyx_GOTREF(__pyx_t_1);
6186 }
6187 __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
6188 __pyx_t_1 = 0;
6189
6190 /* "gensim/models/fasttext_inner.pyx":661
6191 * for ngram_length in range(min_n, min(len(extended_word), max_n) + 1):
6192 * for i in range(0, len(extended_word) - ngram_length + 1):
6193 * ngrams.append(extended_word[i:i + ngram_length]) # <<<<<<<<<<<<<<
6194 * return ngrams
6195 *
6196 */
6197 __Pyx_INCREF(__pyx_v_i);
6198 __pyx_t_1 = __pyx_v_i;
6199 __pyx_t_11 = (__pyx_t_1 == Py_None);
6200 if (__pyx_t_11) {
6201 __pyx_t_10 = 0;
6202 } else {
6203 __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 661, __pyx_L1_error)
6204 __pyx_t_10 = __pyx_t_12;
6205 }
6206 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6207 __pyx_t_1 = PyNumber_Add(__pyx_v_i, __pyx_v_ngram_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error)
6208 __Pyx_GOTREF(__pyx_t_1);
6209 __pyx_t_11 = (__pyx_t_1 == Py_None);
6210 if (__pyx_t_11) {
6211 __pyx_t_12 = PY_SSIZE_T_MAX;
6212 } else {
6213 __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 661, __pyx_L1_error)
6214 __pyx_t_12 = __pyx_t_13;
6215 }
6216 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6217 __pyx_t_1 = __Pyx_PyUnicode_Substring(__pyx_v_extended_word, __pyx_t_10, __pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error)
6218 __Pyx_GOTREF(__pyx_t_1);
6219 __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_ngrams, __pyx_t_1); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 661, __pyx_L1_error)
6220 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6221
6222 /* "gensim/models/fasttext_inner.pyx":660
6223 * ngrams = []
6224 * for ngram_length in range(min_n, min(len(extended_word), max_n) + 1):
6225 * for i in range(0, len(extended_word) - ngram_length + 1): # <<<<<<<<<<<<<<
6226 * ngrams.append(extended_word[i:i + ngram_length])
6227 * return ngrams
6228 */
6229 }
6230 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6231
6232 /* "gensim/models/fasttext_inner.pyx":659
6233 * cdef unicode extended_word = f'<{word}>'
6234 * ngrams = []
6235 * for ngram_length in range(min_n, min(len(extended_word), max_n) + 1): # <<<<<<<<<<<<<<
6236 * for i in range(0, len(extended_word) - ngram_length + 1):
6237 * ngrams.append(extended_word[i:i + ngram_length])
6238 */
6239 }
6240 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
6241
6242 /* "gensim/models/fasttext_inner.pyx":662
6243 * for i in range(0, len(extended_word) - ngram_length + 1):
6244 * ngrams.append(extended_word[i:i + ngram_length])
6245 * return ngrams # <<<<<<<<<<<<<<
6246 *
6247 * #
6248 */
6249 __Pyx_XDECREF(__pyx_r);
6250 __Pyx_INCREF(__pyx_v_ngrams);
6251 __pyx_r = __pyx_v_ngrams;
6252 goto __pyx_L0;
6253
6254 /* "gensim/models/fasttext_inner.pyx":639
6255 *
6256 *
6257 * cpdef compute_ngrams(word, unsigned int min_n, unsigned int max_n): # <<<<<<<<<<<<<<
6258 * """Get the list of all possible ngrams for a given word.
6259 *
6260 */
6261
6262 /* function exit code */
6263 __pyx_L1_error:;
6264 __Pyx_XDECREF(__pyx_t_1);
6265 __Pyx_XDECREF(__pyx_t_4);
6266 __Pyx_XDECREF(__pyx_t_7);
6267 __Pyx_AddTraceback("gensim.models.fasttext_inner.compute_ngrams", __pyx_clineno, __pyx_lineno, __pyx_filename);
6268 __pyx_r = 0;
6269 __pyx_L0:;
6270 __Pyx_XDECREF(__pyx_v_extended_word);
6271 __Pyx_XDECREF(__pyx_v_ngrams);
6272 __Pyx_XDECREF(__pyx_v_ngram_length);
6273 __Pyx_XDECREF(__pyx_v_i);
6274 __Pyx_XGIVEREF(__pyx_r);
6275 __Pyx_RefNannyFinishContext();
6276 return __pyx_r;
6277 }
6278
6279 /* Python wrapper */
6280 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_5compute_ngrams(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6281 static char __pyx_doc_6gensim_6models_14fasttext_inner_4compute_ngrams[] = "compute_ngrams(word, unsigned int min_n, unsigned int max_n)\nGet the list of all possible ngrams for a given word.\n\n Parameters\n ----------\n word : str\n The word whose ngrams need to be computed.\n min_n : unsigned int\n Minimum character length of the ngrams.\n max_n : unsigned int\n Maximum character length of the ngrams.\n\n Returns\n -------\n list of str\n Sequence of character ngrams.\n\n ";
__pyx_pw_6gensim_6models_14fasttext_inner_5compute_ngrams(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6282 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_5compute_ngrams(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6283 PyObject *__pyx_v_word = 0;
6284 unsigned int __pyx_v_min_n;
6285 unsigned int __pyx_v_max_n;
6286 int __pyx_lineno = 0;
6287 const char *__pyx_filename = NULL;
6288 int __pyx_clineno = 0;
6289 PyObject *__pyx_r = 0;
6290 __Pyx_RefNannyDeclarations
6291 __Pyx_RefNannySetupContext("compute_ngrams (wrapper)", 0);
6292 {
6293 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_word,&__pyx_n_s_min_n,&__pyx_n_s_max_n,0};
6294 PyObject* values[3] = {0,0,0};
6295 if (unlikely(__pyx_kwds)) {
6296 Py_ssize_t kw_args;
6297 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6298 switch (pos_args) {
6299 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6300 CYTHON_FALLTHROUGH;
6301 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6302 CYTHON_FALLTHROUGH;
6303 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6304 CYTHON_FALLTHROUGH;
6305 case 0: break;
6306 default: goto __pyx_L5_argtuple_error;
6307 }
6308 kw_args = PyDict_Size(__pyx_kwds);
6309 switch (pos_args) {
6310 case 0:
6311 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_word)) != 0)) kw_args--;
6312 else goto __pyx_L5_argtuple_error;
6313 CYTHON_FALLTHROUGH;
6314 case 1:
6315 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_min_n)) != 0)) kw_args--;
6316 else {
6317 __Pyx_RaiseArgtupleInvalid("compute_ngrams", 1, 3, 3, 1); __PYX_ERR(0, 639, __pyx_L3_error)
6318 }
6319 CYTHON_FALLTHROUGH;
6320 case 2:
6321 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_n)) != 0)) kw_args--;
6322 else {
6323 __Pyx_RaiseArgtupleInvalid("compute_ngrams", 1, 3, 3, 2); __PYX_ERR(0, 639, __pyx_L3_error)
6324 }
6325 }
6326 if (unlikely(kw_args > 0)) {
6327 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compute_ngrams") < 0)) __PYX_ERR(0, 639, __pyx_L3_error)
6328 }
6329 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
6330 goto __pyx_L5_argtuple_error;
6331 } else {
6332 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6333 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6334 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6335 }
6336 __pyx_v_word = values[0];
6337 __pyx_v_min_n = __Pyx_PyInt_As_unsigned_int(values[1]); if (unlikely((__pyx_v_min_n == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 639, __pyx_L3_error)
6338 __pyx_v_max_n = __Pyx_PyInt_As_unsigned_int(values[2]); if (unlikely((__pyx_v_max_n == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 639, __pyx_L3_error)
6339 }
6340 goto __pyx_L4_argument_unpacking_done;
6341 __pyx_L5_argtuple_error:;
6342 __Pyx_RaiseArgtupleInvalid("compute_ngrams", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 639, __pyx_L3_error)
6343 __pyx_L3_error:;
6344 __Pyx_AddTraceback("gensim.models.fasttext_inner.compute_ngrams", __pyx_clineno, __pyx_lineno, __pyx_filename);
6345 __Pyx_RefNannyFinishContext();
6346 return NULL;
6347 __pyx_L4_argument_unpacking_done:;
6348 __pyx_r = __pyx_pf_6gensim_6models_14fasttext_inner_4compute_ngrams(__pyx_self, __pyx_v_word, __pyx_v_min_n, __pyx_v_max_n);
6349
6350 /* function exit code */
6351 __Pyx_RefNannyFinishContext();
6352 return __pyx_r;
6353 }
6354
__pyx_pf_6gensim_6models_14fasttext_inner_4compute_ngrams(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_word,unsigned int __pyx_v_min_n,unsigned int __pyx_v_max_n)6355 static PyObject *__pyx_pf_6gensim_6models_14fasttext_inner_4compute_ngrams(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_word, unsigned int __pyx_v_min_n, unsigned int __pyx_v_max_n) {
6356 PyObject *__pyx_r = NULL;
6357 __Pyx_RefNannyDeclarations
6358 PyObject *__pyx_t_1 = NULL;
6359 int __pyx_lineno = 0;
6360 const char *__pyx_filename = NULL;
6361 int __pyx_clineno = 0;
6362 __Pyx_RefNannySetupContext("compute_ngrams", 0);
6363 __Pyx_XDECREF(__pyx_r);
6364 __pyx_t_1 = __pyx_f_6gensim_6models_14fasttext_inner_compute_ngrams(__pyx_v_word, __pyx_v_min_n, __pyx_v_max_n, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 639, __pyx_L1_error)
6365 __Pyx_GOTREF(__pyx_t_1);
6366 __pyx_r = __pyx_t_1;
6367 __pyx_t_1 = 0;
6368 goto __pyx_L0;
6369
6370 /* function exit code */
6371 __pyx_L1_error:;
6372 __Pyx_XDECREF(__pyx_t_1);
6373 __Pyx_AddTraceback("gensim.models.fasttext_inner.compute_ngrams", __pyx_clineno, __pyx_lineno, __pyx_filename);
6374 __pyx_r = NULL;
6375 __pyx_L0:;
6376 __Pyx_XGIVEREF(__pyx_r);
6377 __Pyx_RefNannyFinishContext();
6378 return __pyx_r;
6379 }
6380
6381 /* "gensim/models/fasttext_inner.pyx":672
6382 *
6383 *
6384 * cpdef compute_ngrams_bytes(word, unsigned int min_n, unsigned int max_n): # <<<<<<<<<<<<<<
6385 * """Computes ngrams for a word.
6386 *
6387 */
6388
6389 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_7compute_ngrams_bytes(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_6gensim_6models_14fasttext_inner_compute_ngrams_bytes(PyObject * __pyx_v_word,unsigned int __pyx_v_min_n,unsigned int __pyx_v_max_n,CYTHON_UNUSED int __pyx_skip_dispatch)6390 static PyObject *__pyx_f_6gensim_6models_14fasttext_inner_compute_ngrams_bytes(PyObject *__pyx_v_word, unsigned int __pyx_v_min_n, unsigned int __pyx_v_max_n, CYTHON_UNUSED int __pyx_skip_dispatch) {
6391 PyObject *__pyx_v_utf8_word = 0;
6392 unsigned char const *__pyx_v_bytez;
6393 size_t __pyx_v_num_bytes;
6394 size_t __pyx_v_j;
6395 size_t __pyx_v_i;
6396 size_t __pyx_v_n;
6397 PyObject *__pyx_v_ngrams = NULL;
6398 PyObject *__pyx_v_ngram = NULL;
6399 PyObject *__pyx_r = NULL;
6400 __Pyx_RefNannyDeclarations
6401 PyObject *__pyx_t_1 = NULL;
6402 PyObject *__pyx_t_2 = NULL;
6403 PyObject *__pyx_t_3 = NULL;
6404 unsigned char const *__pyx_t_4;
6405 Py_ssize_t __pyx_t_5;
6406 size_t __pyx_t_6;
6407 size_t __pyx_t_7;
6408 size_t __pyx_t_8;
6409 int __pyx_t_9;
6410 size_t __pyx_t_10;
6411 size_t __pyx_t_11;
6412 int __pyx_t_12;
6413 int __pyx_t_13;
6414 int __pyx_t_14;
6415 int __pyx_lineno = 0;
6416 const char *__pyx_filename = NULL;
6417 int __pyx_clineno = 0;
6418 __Pyx_RefNannySetupContext("compute_ngrams_bytes", 0);
6419
6420 /* "gensim/models/fasttext_inner.pyx":696
6421 *
6422 * """
6423 * cdef bytes utf8_word = ('<%s>' % word).encode("utf-8") # <<<<<<<<<<<<<<
6424 * cdef const unsigned char *bytez = utf8_word
6425 * cdef size_t num_bytes = len(utf8_word)
6426 */
6427 __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_s, __pyx_v_word); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 696, __pyx_L1_error)
6428 __Pyx_GOTREF(__pyx_t_2);
6429 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 696, __pyx_L1_error)
6430 __Pyx_GOTREF(__pyx_t_3);
6431 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6432 __pyx_t_2 = NULL;
6433 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
6434 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
6435 if (likely(__pyx_t_2)) {
6436 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
6437 __Pyx_INCREF(__pyx_t_2);
6438 __Pyx_INCREF(function);
6439 __Pyx_DECREF_SET(__pyx_t_3, function);
6440 }
6441 }
6442 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_kp_s_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_utf_8);
6443 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
6444 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __pyx_L1_error)
6445 __Pyx_GOTREF(__pyx_t_1);
6446 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6447 if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 696, __pyx_L1_error)
6448 __pyx_v_utf8_word = ((PyObject*)__pyx_t_1);
6449 __pyx_t_1 = 0;
6450
6451 /* "gensim/models/fasttext_inner.pyx":697
6452 * """
6453 * cdef bytes utf8_word = ('<%s>' % word).encode("utf-8")
6454 * cdef const unsigned char *bytez = utf8_word # <<<<<<<<<<<<<<
6455 * cdef size_t num_bytes = len(utf8_word)
6456 * cdef size_t j, i, n
6457 */
6458 if (unlikely(__pyx_v_utf8_word == Py_None)) {
6459 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
6460 __PYX_ERR(0, 697, __pyx_L1_error)
6461 }
6462 __pyx_t_4 = __Pyx_PyBytes_AsUString(__pyx_v_utf8_word); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 697, __pyx_L1_error)
6463 __pyx_v_bytez = __pyx_t_4;
6464
6465 /* "gensim/models/fasttext_inner.pyx":698
6466 * cdef bytes utf8_word = ('<%s>' % word).encode("utf-8")
6467 * cdef const unsigned char *bytez = utf8_word
6468 * cdef size_t num_bytes = len(utf8_word) # <<<<<<<<<<<<<<
6469 * cdef size_t j, i, n
6470 *
6471 */
6472 if (unlikely(__pyx_v_utf8_word == Py_None)) {
6473 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
6474 __PYX_ERR(0, 698, __pyx_L1_error)
6475 }
6476 __pyx_t_5 = PyBytes_GET_SIZE(__pyx_v_utf8_word); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 698, __pyx_L1_error)
6477 __pyx_v_num_bytes = __pyx_t_5;
6478
6479 /* "gensim/models/fasttext_inner.pyx":701
6480 * cdef size_t j, i, n
6481 *
6482 * ngrams = [] # <<<<<<<<<<<<<<
6483 * for i in range(num_bytes):
6484 * if bytez[i] & _MB_MASK == _MB_START:
6485 */
6486 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 701, __pyx_L1_error)
6487 __Pyx_GOTREF(__pyx_t_1);
6488 __pyx_v_ngrams = ((PyObject*)__pyx_t_1);
6489 __pyx_t_1 = 0;
6490
6491 /* "gensim/models/fasttext_inner.pyx":702
6492 *
6493 * ngrams = []
6494 * for i in range(num_bytes): # <<<<<<<<<<<<<<
6495 * if bytez[i] & _MB_MASK == _MB_START:
6496 * continue
6497 */
6498 __pyx_t_6 = __pyx_v_num_bytes;
6499 __pyx_t_7 = __pyx_t_6;
6500 for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
6501 __pyx_v_i = __pyx_t_8;
6502
6503 /* "gensim/models/fasttext_inner.pyx":703
6504 * ngrams = []
6505 * for i in range(num_bytes):
6506 * if bytez[i] & _MB_MASK == _MB_START: # <<<<<<<<<<<<<<
6507 * continue
6508 *
6509 */
6510 __pyx_t_9 = ((((__pyx_v_bytez[__pyx_v_i]) & __pyx_v_6gensim_6models_14fasttext_inner__MB_MASK) == __pyx_v_6gensim_6models_14fasttext_inner__MB_START) != 0);
6511 if (__pyx_t_9) {
6512
6513 /* "gensim/models/fasttext_inner.pyx":704
6514 * for i in range(num_bytes):
6515 * if bytez[i] & _MB_MASK == _MB_START:
6516 * continue # <<<<<<<<<<<<<<
6517 *
6518 * j, n = i, 1
6519 */
6520 goto __pyx_L3_continue;
6521
6522 /* "gensim/models/fasttext_inner.pyx":703
6523 * ngrams = []
6524 * for i in range(num_bytes):
6525 * if bytez[i] & _MB_MASK == _MB_START: # <<<<<<<<<<<<<<
6526 * continue
6527 *
6528 */
6529 }
6530
6531 /* "gensim/models/fasttext_inner.pyx":706
6532 * continue
6533 *
6534 * j, n = i, 1 # <<<<<<<<<<<<<<
6535 * while j < num_bytes and n <= max_n:
6536 * j += 1
6537 */
6538 __pyx_t_10 = __pyx_v_i;
6539 __pyx_t_11 = 1;
6540 __pyx_v_j = __pyx_t_10;
6541 __pyx_v_n = __pyx_t_11;
6542
6543 /* "gensim/models/fasttext_inner.pyx":707
6544 *
6545 * j, n = i, 1
6546 * while j < num_bytes and n <= max_n: # <<<<<<<<<<<<<<
6547 * j += 1
6548 * while j < num_bytes and (bytez[j] & _MB_MASK) == _MB_START:
6549 */
6550 while (1) {
6551 __pyx_t_12 = ((__pyx_v_j < __pyx_v_num_bytes) != 0);
6552 if (__pyx_t_12) {
6553 } else {
6554 __pyx_t_9 = __pyx_t_12;
6555 goto __pyx_L8_bool_binop_done;
6556 }
6557 __pyx_t_12 = ((__pyx_v_n <= __pyx_v_max_n) != 0);
6558 __pyx_t_9 = __pyx_t_12;
6559 __pyx_L8_bool_binop_done:;
6560 if (!__pyx_t_9) break;
6561
6562 /* "gensim/models/fasttext_inner.pyx":708
6563 * j, n = i, 1
6564 * while j < num_bytes and n <= max_n:
6565 * j += 1 # <<<<<<<<<<<<<<
6566 * while j < num_bytes and (bytez[j] & _MB_MASK) == _MB_START:
6567 * j += 1
6568 */
6569 __pyx_v_j = (__pyx_v_j + 1);
6570
6571 /* "gensim/models/fasttext_inner.pyx":709
6572 * while j < num_bytes and n <= max_n:
6573 * j += 1
6574 * while j < num_bytes and (bytez[j] & _MB_MASK) == _MB_START: # <<<<<<<<<<<<<<
6575 * j += 1
6576 * if n >= min_n and not (n == 1 and (i == 0 or j == num_bytes)):
6577 */
6578 while (1) {
6579 __pyx_t_12 = ((__pyx_v_j < __pyx_v_num_bytes) != 0);
6580 if (__pyx_t_12) {
6581 } else {
6582 __pyx_t_9 = __pyx_t_12;
6583 goto __pyx_L12_bool_binop_done;
6584 }
6585 __pyx_t_12 = ((((__pyx_v_bytez[__pyx_v_j]) & __pyx_v_6gensim_6models_14fasttext_inner__MB_MASK) == __pyx_v_6gensim_6models_14fasttext_inner__MB_START) != 0);
6586 __pyx_t_9 = __pyx_t_12;
6587 __pyx_L12_bool_binop_done:;
6588 if (!__pyx_t_9) break;
6589
6590 /* "gensim/models/fasttext_inner.pyx":710
6591 * j += 1
6592 * while j < num_bytes and (bytez[j] & _MB_MASK) == _MB_START:
6593 * j += 1 # <<<<<<<<<<<<<<
6594 * if n >= min_n and not (n == 1 and (i == 0 or j == num_bytes)):
6595 * ngram = bytes(bytez[i:j])
6596 */
6597 __pyx_v_j = (__pyx_v_j + 1);
6598 }
6599
6600 /* "gensim/models/fasttext_inner.pyx":711
6601 * while j < num_bytes and (bytez[j] & _MB_MASK) == _MB_START:
6602 * j += 1
6603 * if n >= min_n and not (n == 1 and (i == 0 or j == num_bytes)): # <<<<<<<<<<<<<<
6604 * ngram = bytes(bytez[i:j])
6605 * ngrams.append(ngram)
6606 */
6607 __pyx_t_12 = ((__pyx_v_n >= __pyx_v_min_n) != 0);
6608 if (__pyx_t_12) {
6609 } else {
6610 __pyx_t_9 = __pyx_t_12;
6611 goto __pyx_L15_bool_binop_done;
6612 }
6613 __pyx_t_13 = ((__pyx_v_n == 1) != 0);
6614 if (__pyx_t_13) {
6615 } else {
6616 __pyx_t_12 = __pyx_t_13;
6617 goto __pyx_L17_bool_binop_done;
6618 }
6619 __pyx_t_13 = ((__pyx_v_i == 0) != 0);
6620 if (!__pyx_t_13) {
6621 } else {
6622 __pyx_t_12 = __pyx_t_13;
6623 goto __pyx_L17_bool_binop_done;
6624 }
6625 __pyx_t_13 = ((__pyx_v_j == __pyx_v_num_bytes) != 0);
6626 __pyx_t_12 = __pyx_t_13;
6627 __pyx_L17_bool_binop_done:;
6628 __pyx_t_13 = ((!__pyx_t_12) != 0);
6629 __pyx_t_9 = __pyx_t_13;
6630 __pyx_L15_bool_binop_done:;
6631 if (__pyx_t_9) {
6632
6633 /* "gensim/models/fasttext_inner.pyx":712
6634 * j += 1
6635 * if n >= min_n and not (n == 1 and (i == 0 or j == num_bytes)):
6636 * ngram = bytes(bytez[i:j]) # <<<<<<<<<<<<<<
6637 * ngrams.append(ngram)
6638 * n += 1
6639 */
6640 __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_bytez) + __pyx_v_i, __pyx_v_j - __pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L1_error)
6641 __Pyx_GOTREF(__pyx_t_1);
6642 __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 712, __pyx_L1_error)
6643 __Pyx_GOTREF(__pyx_t_3);
6644 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6645 __Pyx_XDECREF_SET(__pyx_v_ngram, ((PyObject*)__pyx_t_3));
6646 __pyx_t_3 = 0;
6647
6648 /* "gensim/models/fasttext_inner.pyx":713
6649 * if n >= min_n and not (n == 1 and (i == 0 or j == num_bytes)):
6650 * ngram = bytes(bytez[i:j])
6651 * ngrams.append(ngram) # <<<<<<<<<<<<<<
6652 * n += 1
6653 * return ngrams
6654 */
6655 __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_ngrams, __pyx_v_ngram); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 713, __pyx_L1_error)
6656
6657 /* "gensim/models/fasttext_inner.pyx":711
6658 * while j < num_bytes and (bytez[j] & _MB_MASK) == _MB_START:
6659 * j += 1
6660 * if n >= min_n and not (n == 1 and (i == 0 or j == num_bytes)): # <<<<<<<<<<<<<<
6661 * ngram = bytes(bytez[i:j])
6662 * ngrams.append(ngram)
6663 */
6664 }
6665
6666 /* "gensim/models/fasttext_inner.pyx":714
6667 * ngram = bytes(bytez[i:j])
6668 * ngrams.append(ngram)
6669 * n += 1 # <<<<<<<<<<<<<<
6670 * return ngrams
6671 *
6672 */
6673 __pyx_v_n = (__pyx_v_n + 1);
6674 }
6675 __pyx_L3_continue:;
6676 }
6677
6678 /* "gensim/models/fasttext_inner.pyx":715
6679 * ngrams.append(ngram)
6680 * n += 1
6681 * return ngrams # <<<<<<<<<<<<<<
6682 *
6683 *
6684 */
6685 __Pyx_XDECREF(__pyx_r);
6686 __Pyx_INCREF(__pyx_v_ngrams);
6687 __pyx_r = __pyx_v_ngrams;
6688 goto __pyx_L0;
6689
6690 /* "gensim/models/fasttext_inner.pyx":672
6691 *
6692 *
6693 * cpdef compute_ngrams_bytes(word, unsigned int min_n, unsigned int max_n): # <<<<<<<<<<<<<<
6694 * """Computes ngrams for a word.
6695 *
6696 */
6697
6698 /* function exit code */
6699 __pyx_L1_error:;
6700 __Pyx_XDECREF(__pyx_t_1);
6701 __Pyx_XDECREF(__pyx_t_2);
6702 __Pyx_XDECREF(__pyx_t_3);
6703 __Pyx_AddTraceback("gensim.models.fasttext_inner.compute_ngrams_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
6704 __pyx_r = 0;
6705 __pyx_L0:;
6706 __Pyx_XDECREF(__pyx_v_utf8_word);
6707 __Pyx_XDECREF(__pyx_v_ngrams);
6708 __Pyx_XDECREF(__pyx_v_ngram);
6709 __Pyx_XGIVEREF(__pyx_r);
6710 __Pyx_RefNannyFinishContext();
6711 return __pyx_r;
6712 }
6713
6714 /* Python wrapper */
6715 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_7compute_ngrams_bytes(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6716 static char __pyx_doc_6gensim_6models_14fasttext_inner_6compute_ngrams_bytes[] = "compute_ngrams_bytes(word, unsigned int min_n, unsigned int max_n)\nComputes ngrams for a word.\n\n Ported from the original FB implementation.\n\n Parameters\n ----------\n word : str\n A unicode string.\n min_n : unsigned int\n The minimum ngram length.\n max_n : unsigned int\n The maximum ngram length.\n\n Returns:\n --------\n list of str\n A list of ngrams, where each ngram is a list of **bytes**.\n\n See Also\n --------\n `Original implementation <https://github.com/facebookresearch/fastText/blob/7842495a4d64c7a3bb4339d45d6e64321d002ed8/src/dictionary.cc#L172>`__\n\n ";
__pyx_pw_6gensim_6models_14fasttext_inner_7compute_ngrams_bytes(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6717 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_7compute_ngrams_bytes(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6718 PyObject *__pyx_v_word = 0;
6719 unsigned int __pyx_v_min_n;
6720 unsigned int __pyx_v_max_n;
6721 int __pyx_lineno = 0;
6722 const char *__pyx_filename = NULL;
6723 int __pyx_clineno = 0;
6724 PyObject *__pyx_r = 0;
6725 __Pyx_RefNannyDeclarations
6726 __Pyx_RefNannySetupContext("compute_ngrams_bytes (wrapper)", 0);
6727 {
6728 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_word,&__pyx_n_s_min_n,&__pyx_n_s_max_n,0};
6729 PyObject* values[3] = {0,0,0};
6730 if (unlikely(__pyx_kwds)) {
6731 Py_ssize_t kw_args;
6732 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6733 switch (pos_args) {
6734 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6735 CYTHON_FALLTHROUGH;
6736 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6737 CYTHON_FALLTHROUGH;
6738 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6739 CYTHON_FALLTHROUGH;
6740 case 0: break;
6741 default: goto __pyx_L5_argtuple_error;
6742 }
6743 kw_args = PyDict_Size(__pyx_kwds);
6744 switch (pos_args) {
6745 case 0:
6746 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_word)) != 0)) kw_args--;
6747 else goto __pyx_L5_argtuple_error;
6748 CYTHON_FALLTHROUGH;
6749 case 1:
6750 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_min_n)) != 0)) kw_args--;
6751 else {
6752 __Pyx_RaiseArgtupleInvalid("compute_ngrams_bytes", 1, 3, 3, 1); __PYX_ERR(0, 672, __pyx_L3_error)
6753 }
6754 CYTHON_FALLTHROUGH;
6755 case 2:
6756 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_n)) != 0)) kw_args--;
6757 else {
6758 __Pyx_RaiseArgtupleInvalid("compute_ngrams_bytes", 1, 3, 3, 2); __PYX_ERR(0, 672, __pyx_L3_error)
6759 }
6760 }
6761 if (unlikely(kw_args > 0)) {
6762 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compute_ngrams_bytes") < 0)) __PYX_ERR(0, 672, __pyx_L3_error)
6763 }
6764 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
6765 goto __pyx_L5_argtuple_error;
6766 } else {
6767 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6768 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6769 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6770 }
6771 __pyx_v_word = values[0];
6772 __pyx_v_min_n = __Pyx_PyInt_As_unsigned_int(values[1]); if (unlikely((__pyx_v_min_n == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 672, __pyx_L3_error)
6773 __pyx_v_max_n = __Pyx_PyInt_As_unsigned_int(values[2]); if (unlikely((__pyx_v_max_n == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 672, __pyx_L3_error)
6774 }
6775 goto __pyx_L4_argument_unpacking_done;
6776 __pyx_L5_argtuple_error:;
6777 __Pyx_RaiseArgtupleInvalid("compute_ngrams_bytes", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 672, __pyx_L3_error)
6778 __pyx_L3_error:;
6779 __Pyx_AddTraceback("gensim.models.fasttext_inner.compute_ngrams_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
6780 __Pyx_RefNannyFinishContext();
6781 return NULL;
6782 __pyx_L4_argument_unpacking_done:;
6783 __pyx_r = __pyx_pf_6gensim_6models_14fasttext_inner_6compute_ngrams_bytes(__pyx_self, __pyx_v_word, __pyx_v_min_n, __pyx_v_max_n);
6784
6785 /* function exit code */
6786 __Pyx_RefNannyFinishContext();
6787 return __pyx_r;
6788 }
6789
__pyx_pf_6gensim_6models_14fasttext_inner_6compute_ngrams_bytes(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_word,unsigned int __pyx_v_min_n,unsigned int __pyx_v_max_n)6790 static PyObject *__pyx_pf_6gensim_6models_14fasttext_inner_6compute_ngrams_bytes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_word, unsigned int __pyx_v_min_n, unsigned int __pyx_v_max_n) {
6791 PyObject *__pyx_r = NULL;
6792 __Pyx_RefNannyDeclarations
6793 PyObject *__pyx_t_1 = NULL;
6794 int __pyx_lineno = 0;
6795 const char *__pyx_filename = NULL;
6796 int __pyx_clineno = 0;
6797 __Pyx_RefNannySetupContext("compute_ngrams_bytes", 0);
6798 __Pyx_XDECREF(__pyx_r);
6799 __pyx_t_1 = __pyx_f_6gensim_6models_14fasttext_inner_compute_ngrams_bytes(__pyx_v_word, __pyx_v_min_n, __pyx_v_max_n, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error)
6800 __Pyx_GOTREF(__pyx_t_1);
6801 __pyx_r = __pyx_t_1;
6802 __pyx_t_1 = 0;
6803 goto __pyx_L0;
6804
6805 /* function exit code */
6806 __pyx_L1_error:;
6807 __Pyx_XDECREF(__pyx_t_1);
6808 __Pyx_AddTraceback("gensim.models.fasttext_inner.compute_ngrams_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
6809 __pyx_r = NULL;
6810 __pyx_L0:;
6811 __Pyx_XGIVEREF(__pyx_r);
6812 __Pyx_RefNannyFinishContext();
6813 return __pyx_r;
6814 }
6815
6816 /* "gensim/models/fasttext_inner.pyx":718
6817 *
6818 *
6819 * def init(): # <<<<<<<<<<<<<<
6820 * """Precompute function `sigmoid(x) = 1 / (1 + exp(-x))`, for x values discretized into table EXP_TABLE.
6821 * Also calculate log(sigmoid(x)) into LOG_TABLE.
6822 */
6823
6824 /* Python wrapper */
6825 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_9init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
6826 static char __pyx_doc_6gensim_6models_14fasttext_inner_8init[] = "init()\nPrecompute function `sigmoid(x) = 1 / (1 + exp(-x))`, for x values discretized into table EXP_TABLE.\n Also calculate log(sigmoid(x)) into LOG_TABLE.\n\n We recalc, rather than re-use the table from word2vec_inner, because Facebook's FastText\n code uses a 512-slot table rather than the 1000 precedent of word2vec.c.\n ";
6827 static PyMethodDef __pyx_mdef_6gensim_6models_14fasttext_inner_9init = {"init", (PyCFunction)__pyx_pw_6gensim_6models_14fasttext_inner_9init, METH_NOARGS, __pyx_doc_6gensim_6models_14fasttext_inner_8init};
__pyx_pw_6gensim_6models_14fasttext_inner_9init(PyObject * __pyx_self,CYTHON_UNUSED PyObject * unused)6828 static PyObject *__pyx_pw_6gensim_6models_14fasttext_inner_9init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
6829 PyObject *__pyx_r = 0;
6830 __Pyx_RefNannyDeclarations
6831 __Pyx_RefNannySetupContext("init (wrapper)", 0);
6832 __pyx_r = __pyx_pf_6gensim_6models_14fasttext_inner_8init(__pyx_self);
6833
6834 /* function exit code */
6835 __Pyx_RefNannyFinishContext();
6836 return __pyx_r;
6837 }
6838
__pyx_pf_6gensim_6models_14fasttext_inner_8init(CYTHON_UNUSED PyObject * __pyx_self)6839 static PyObject *__pyx_pf_6gensim_6models_14fasttext_inner_8init(CYTHON_UNUSED PyObject *__pyx_self) {
6840 int __pyx_v_i;
6841 PyObject *__pyx_r = NULL;
6842 __Pyx_RefNannyDeclarations
6843 int __pyx_t_1;
6844 __Pyx_RefNannySetupContext("init", 0);
6845
6846 /* "gensim/models/fasttext_inner.pyx":728
6847 *
6848 * # build the sigmoid table
6849 * for i in range(EXP_TABLE_SIZE): # <<<<<<<<<<<<<<
6850 * EXP_TABLE[i] = <REAL_t>exp((i / <REAL_t>EXP_TABLE_SIZE * 2 - 1) * MAX_EXP)
6851 * EXP_TABLE[i] = <REAL_t>(EXP_TABLE[i] / (EXP_TABLE[i] + 1))
6852 */
6853 for (__pyx_t_1 = 0; __pyx_t_1 < 0x200; __pyx_t_1+=1) {
6854 __pyx_v_i = __pyx_t_1;
6855
6856 /* "gensim/models/fasttext_inner.pyx":729
6857 * # build the sigmoid table
6858 * for i in range(EXP_TABLE_SIZE):
6859 * EXP_TABLE[i] = <REAL_t>exp((i / <REAL_t>EXP_TABLE_SIZE * 2 - 1) * MAX_EXP) # <<<<<<<<<<<<<<
6860 * EXP_TABLE[i] = <REAL_t>(EXP_TABLE[i] / (EXP_TABLE[i] + 1))
6861 * LOG_TABLE[i] = <REAL_t>log( EXP_TABLE[i] )
6862 */
6863 (__pyx_v_6gensim_6models_14fasttext_inner_EXP_TABLE[__pyx_v_i]) = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)exp(((((__pyx_v_i / ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)0x200)) * 2.0) - 1.0) * 8.0)));
6864
6865 /* "gensim/models/fasttext_inner.pyx":730
6866 * for i in range(EXP_TABLE_SIZE):
6867 * EXP_TABLE[i] = <REAL_t>exp((i / <REAL_t>EXP_TABLE_SIZE * 2 - 1) * MAX_EXP)
6868 * EXP_TABLE[i] = <REAL_t>(EXP_TABLE[i] / (EXP_TABLE[i] + 1)) # <<<<<<<<<<<<<<
6869 * LOG_TABLE[i] = <REAL_t>log( EXP_TABLE[i] )
6870 *
6871 */
6872 (__pyx_v_6gensim_6models_14fasttext_inner_EXP_TABLE[__pyx_v_i]) = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)((__pyx_v_6gensim_6models_14fasttext_inner_EXP_TABLE[__pyx_v_i]) / ((__pyx_v_6gensim_6models_14fasttext_inner_EXP_TABLE[__pyx_v_i]) + 1.0)));
6873
6874 /* "gensim/models/fasttext_inner.pyx":731
6875 * EXP_TABLE[i] = <REAL_t>exp((i / <REAL_t>EXP_TABLE_SIZE * 2 - 1) * MAX_EXP)
6876 * EXP_TABLE[i] = <REAL_t>(EXP_TABLE[i] / (EXP_TABLE[i] + 1))
6877 * LOG_TABLE[i] = <REAL_t>log( EXP_TABLE[i] ) # <<<<<<<<<<<<<<
6878 *
6879 *
6880 */
6881 (__pyx_v_6gensim_6models_14fasttext_inner_LOG_TABLE[__pyx_v_i]) = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)log((__pyx_v_6gensim_6models_14fasttext_inner_EXP_TABLE[__pyx_v_i])));
6882 }
6883
6884 /* "gensim/models/fasttext_inner.pyx":718
6885 *
6886 *
6887 * def init(): # <<<<<<<<<<<<<<
6888 * """Precompute function `sigmoid(x) = 1 / (1 + exp(-x))`, for x values discretized into table EXP_TABLE.
6889 * Also calculate log(sigmoid(x)) into LOG_TABLE.
6890 */
6891
6892 /* function exit code */
6893 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6894 __Pyx_XGIVEREF(__pyx_r);
6895 __Pyx_RefNannyFinishContext();
6896 return __pyx_r;
6897 }
6898
6899 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":734
6900 * ctypedef npy_cdouble complex_t
6901 *
6902 * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<<
6903 * return PyArray_MultiIterNew(1, <void*>a)
6904 *
6905 */
6906
__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject * __pyx_v_a)6907 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
6908 PyObject *__pyx_r = NULL;
6909 __Pyx_RefNannyDeclarations
6910 PyObject *__pyx_t_1 = NULL;
6911 int __pyx_lineno = 0;
6912 const char *__pyx_filename = NULL;
6913 int __pyx_clineno = 0;
6914 __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
6915
6916 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":735
6917 *
6918 * cdef inline object PyArray_MultiIterNew1(a):
6919 * return PyArray_MultiIterNew(1, <void*>a) # <<<<<<<<<<<<<<
6920 *
6921 * cdef inline object PyArray_MultiIterNew2(a, b):
6922 */
6923 __Pyx_XDECREF(__pyx_r);
6924 __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 735, __pyx_L1_error)
6925 __Pyx_GOTREF(__pyx_t_1);
6926 __pyx_r = __pyx_t_1;
6927 __pyx_t_1 = 0;
6928 goto __pyx_L0;
6929
6930 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":734
6931 * ctypedef npy_cdouble complex_t
6932 *
6933 * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<<
6934 * return PyArray_MultiIterNew(1, <void*>a)
6935 *
6936 */
6937
6938 /* function exit code */
6939 __pyx_L1_error:;
6940 __Pyx_XDECREF(__pyx_t_1);
6941 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
6942 __pyx_r = 0;
6943 __pyx_L0:;
6944 __Pyx_XGIVEREF(__pyx_r);
6945 __Pyx_RefNannyFinishContext();
6946 return __pyx_r;
6947 }
6948
6949 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":737
6950 * return PyArray_MultiIterNew(1, <void*>a)
6951 *
6952 * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<<
6953 * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
6954 *
6955 */
6956
__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject * __pyx_v_a,PyObject * __pyx_v_b)6957 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
6958 PyObject *__pyx_r = NULL;
6959 __Pyx_RefNannyDeclarations
6960 PyObject *__pyx_t_1 = NULL;
6961 int __pyx_lineno = 0;
6962 const char *__pyx_filename = NULL;
6963 int __pyx_clineno = 0;
6964 __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
6965
6966 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":738
6967 *
6968 * cdef inline object PyArray_MultiIterNew2(a, b):
6969 * return PyArray_MultiIterNew(2, <void*>a, <void*>b) # <<<<<<<<<<<<<<
6970 *
6971 * cdef inline object PyArray_MultiIterNew3(a, b, c):
6972 */
6973 __Pyx_XDECREF(__pyx_r);
6974 __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 738, __pyx_L1_error)
6975 __Pyx_GOTREF(__pyx_t_1);
6976 __pyx_r = __pyx_t_1;
6977 __pyx_t_1 = 0;
6978 goto __pyx_L0;
6979
6980 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":737
6981 * return PyArray_MultiIterNew(1, <void*>a)
6982 *
6983 * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<<
6984 * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
6985 *
6986 */
6987
6988 /* function exit code */
6989 __pyx_L1_error:;
6990 __Pyx_XDECREF(__pyx_t_1);
6991 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
6992 __pyx_r = 0;
6993 __pyx_L0:;
6994 __Pyx_XGIVEREF(__pyx_r);
6995 __Pyx_RefNannyFinishContext();
6996 return __pyx_r;
6997 }
6998
6999 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":740
7000 * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
7001 *
7002 * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<<
7003 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
7004 *
7005 */
7006
__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c)7007 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
7008 PyObject *__pyx_r = NULL;
7009 __Pyx_RefNannyDeclarations
7010 PyObject *__pyx_t_1 = NULL;
7011 int __pyx_lineno = 0;
7012 const char *__pyx_filename = NULL;
7013 int __pyx_clineno = 0;
7014 __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
7015
7016 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":741
7017 *
7018 * cdef inline object PyArray_MultiIterNew3(a, b, c):
7019 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c) # <<<<<<<<<<<<<<
7020 *
7021 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
7022 */
7023 __Pyx_XDECREF(__pyx_r);
7024 __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 741, __pyx_L1_error)
7025 __Pyx_GOTREF(__pyx_t_1);
7026 __pyx_r = __pyx_t_1;
7027 __pyx_t_1 = 0;
7028 goto __pyx_L0;
7029
7030 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":740
7031 * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
7032 *
7033 * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<<
7034 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
7035 *
7036 */
7037
7038 /* function exit code */
7039 __pyx_L1_error:;
7040 __Pyx_XDECREF(__pyx_t_1);
7041 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
7042 __pyx_r = 0;
7043 __pyx_L0:;
7044 __Pyx_XGIVEREF(__pyx_r);
7045 __Pyx_RefNannyFinishContext();
7046 return __pyx_r;
7047 }
7048
7049 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":743
7050 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
7051 *
7052 * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<<
7053 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
7054 *
7055 */
7056
__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c,PyObject * __pyx_v_d)7057 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
7058 PyObject *__pyx_r = NULL;
7059 __Pyx_RefNannyDeclarations
7060 PyObject *__pyx_t_1 = NULL;
7061 int __pyx_lineno = 0;
7062 const char *__pyx_filename = NULL;
7063 int __pyx_clineno = 0;
7064 __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
7065
7066 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":744
7067 *
7068 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
7069 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d) # <<<<<<<<<<<<<<
7070 *
7071 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
7072 */
7073 __Pyx_XDECREF(__pyx_r);
7074 __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 744, __pyx_L1_error)
7075 __Pyx_GOTREF(__pyx_t_1);
7076 __pyx_r = __pyx_t_1;
7077 __pyx_t_1 = 0;
7078 goto __pyx_L0;
7079
7080 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":743
7081 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
7082 *
7083 * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<<
7084 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
7085 *
7086 */
7087
7088 /* function exit code */
7089 __pyx_L1_error:;
7090 __Pyx_XDECREF(__pyx_t_1);
7091 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
7092 __pyx_r = 0;
7093 __pyx_L0:;
7094 __Pyx_XGIVEREF(__pyx_r);
7095 __Pyx_RefNannyFinishContext();
7096 return __pyx_r;
7097 }
7098
7099 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":746
7100 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
7101 *
7102 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<<
7103 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
7104 *
7105 */
7106
__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c,PyObject * __pyx_v_d,PyObject * __pyx_v_e)7107 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
7108 PyObject *__pyx_r = NULL;
7109 __Pyx_RefNannyDeclarations
7110 PyObject *__pyx_t_1 = NULL;
7111 int __pyx_lineno = 0;
7112 const char *__pyx_filename = NULL;
7113 int __pyx_clineno = 0;
7114 __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
7115
7116 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":747
7117 *
7118 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
7119 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e) # <<<<<<<<<<<<<<
7120 *
7121 * cdef inline tuple PyDataType_SHAPE(dtype d):
7122 */
7123 __Pyx_XDECREF(__pyx_r);
7124 __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 747, __pyx_L1_error)
7125 __Pyx_GOTREF(__pyx_t_1);
7126 __pyx_r = __pyx_t_1;
7127 __pyx_t_1 = 0;
7128 goto __pyx_L0;
7129
7130 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":746
7131 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
7132 *
7133 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<<
7134 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
7135 *
7136 */
7137
7138 /* function exit code */
7139 __pyx_L1_error:;
7140 __Pyx_XDECREF(__pyx_t_1);
7141 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
7142 __pyx_r = 0;
7143 __pyx_L0:;
7144 __Pyx_XGIVEREF(__pyx_r);
7145 __Pyx_RefNannyFinishContext();
7146 return __pyx_r;
7147 }
7148
7149 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":749
7150 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
7151 *
7152 * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<<
7153 * if PyDataType_HASSUBARRAY(d):
7154 * return <tuple>d.subarray.shape
7155 */
7156
__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr * __pyx_v_d)7157 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
7158 PyObject *__pyx_r = NULL;
7159 __Pyx_RefNannyDeclarations
7160 int __pyx_t_1;
7161 __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
7162
7163 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":750
7164 *
7165 * cdef inline tuple PyDataType_SHAPE(dtype d):
7166 * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<<
7167 * return <tuple>d.subarray.shape
7168 * else:
7169 */
7170 __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
7171 if (__pyx_t_1) {
7172
7173 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":751
7174 * cdef inline tuple PyDataType_SHAPE(dtype d):
7175 * if PyDataType_HASSUBARRAY(d):
7176 * return <tuple>d.subarray.shape # <<<<<<<<<<<<<<
7177 * else:
7178 * return ()
7179 */
7180 __Pyx_XDECREF(__pyx_r);
7181 __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
7182 __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
7183 goto __pyx_L0;
7184
7185 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":750
7186 *
7187 * cdef inline tuple PyDataType_SHAPE(dtype d):
7188 * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<<
7189 * return <tuple>d.subarray.shape
7190 * else:
7191 */
7192 }
7193
7194 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":753
7195 * return <tuple>d.subarray.shape
7196 * else:
7197 * return () # <<<<<<<<<<<<<<
7198 *
7199 *
7200 */
7201 /*else*/ {
7202 __Pyx_XDECREF(__pyx_r);
7203 __Pyx_INCREF(__pyx_empty_tuple);
7204 __pyx_r = __pyx_empty_tuple;
7205 goto __pyx_L0;
7206 }
7207
7208 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":749
7209 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
7210 *
7211 * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<<
7212 * if PyDataType_HASSUBARRAY(d):
7213 * return <tuple>d.subarray.shape
7214 */
7215
7216 /* function exit code */
7217 __pyx_L0:;
7218 __Pyx_XGIVEREF(__pyx_r);
7219 __Pyx_RefNannyFinishContext();
7220 return __pyx_r;
7221 }
7222
7223 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":868
7224 * int _import_umath() except -1
7225 *
7226 * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<<
7227 * Py_INCREF(base) # important to do this before stealing the reference below!
7228 * PyArray_SetBaseObject(arr, base)
7229 */
7230
__pyx_f_5numpy_set_array_base(PyArrayObject * __pyx_v_arr,PyObject * __pyx_v_base)7231 static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
7232 __Pyx_RefNannyDeclarations
7233 __Pyx_RefNannySetupContext("set_array_base", 0);
7234
7235 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":869
7236 *
7237 * cdef inline void set_array_base(ndarray arr, object base):
7238 * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<<
7239 * PyArray_SetBaseObject(arr, base)
7240 *
7241 */
7242 Py_INCREF(__pyx_v_base);
7243
7244 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":870
7245 * cdef inline void set_array_base(ndarray arr, object base):
7246 * Py_INCREF(base) # important to do this before stealing the reference below!
7247 * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<<
7248 *
7249 * cdef inline object get_array_base(ndarray arr):
7250 */
7251 (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));
7252
7253 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":868
7254 * int _import_umath() except -1
7255 *
7256 * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<<
7257 * Py_INCREF(base) # important to do this before stealing the reference below!
7258 * PyArray_SetBaseObject(arr, base)
7259 */
7260
7261 /* function exit code */
7262 __Pyx_RefNannyFinishContext();
7263 }
7264
7265 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":872
7266 * PyArray_SetBaseObject(arr, base)
7267 *
7268 * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<<
7269 * base = PyArray_BASE(arr)
7270 * if base is NULL:
7271 */
7272
__pyx_f_5numpy_get_array_base(PyArrayObject * __pyx_v_arr)7273 static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
7274 PyObject *__pyx_v_base;
7275 PyObject *__pyx_r = NULL;
7276 __Pyx_RefNannyDeclarations
7277 int __pyx_t_1;
7278 __Pyx_RefNannySetupContext("get_array_base", 0);
7279
7280 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":873
7281 *
7282 * cdef inline object get_array_base(ndarray arr):
7283 * base = PyArray_BASE(arr) # <<<<<<<<<<<<<<
7284 * if base is NULL:
7285 * return None
7286 */
7287 __pyx_v_base = PyArray_BASE(__pyx_v_arr);
7288
7289 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":874
7290 * cdef inline object get_array_base(ndarray arr):
7291 * base = PyArray_BASE(arr)
7292 * if base is NULL: # <<<<<<<<<<<<<<
7293 * return None
7294 * return <object>base
7295 */
7296 __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
7297 if (__pyx_t_1) {
7298
7299 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":875
7300 * base = PyArray_BASE(arr)
7301 * if base is NULL:
7302 * return None # <<<<<<<<<<<<<<
7303 * return <object>base
7304 *
7305 */
7306 __Pyx_XDECREF(__pyx_r);
7307 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7308 goto __pyx_L0;
7309
7310 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":874
7311 * cdef inline object get_array_base(ndarray arr):
7312 * base = PyArray_BASE(arr)
7313 * if base is NULL: # <<<<<<<<<<<<<<
7314 * return None
7315 * return <object>base
7316 */
7317 }
7318
7319 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":876
7320 * if base is NULL:
7321 * return None
7322 * return <object>base # <<<<<<<<<<<<<<
7323 *
7324 * # Versions of the import_* functions which are more suitable for
7325 */
7326 __Pyx_XDECREF(__pyx_r);
7327 __Pyx_INCREF(((PyObject *)__pyx_v_base));
7328 __pyx_r = ((PyObject *)__pyx_v_base);
7329 goto __pyx_L0;
7330
7331 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":872
7332 * PyArray_SetBaseObject(arr, base)
7333 *
7334 * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<<
7335 * base = PyArray_BASE(arr)
7336 * if base is NULL:
7337 */
7338
7339 /* function exit code */
7340 __pyx_L0:;
7341 __Pyx_XGIVEREF(__pyx_r);
7342 __Pyx_RefNannyFinishContext();
7343 return __pyx_r;
7344 }
7345
7346 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":880
7347 * # Versions of the import_* functions which are more suitable for
7348 * # Cython code.
7349 * cdef inline int import_array() except -1: # <<<<<<<<<<<<<<
7350 * try:
7351 * __pyx_import_array()
7352 */
7353
__pyx_f_5numpy_import_array(void)7354 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
7355 int __pyx_r;
7356 __Pyx_RefNannyDeclarations
7357 PyObject *__pyx_t_1 = NULL;
7358 PyObject *__pyx_t_2 = NULL;
7359 PyObject *__pyx_t_3 = NULL;
7360 int __pyx_t_4;
7361 PyObject *__pyx_t_5 = NULL;
7362 PyObject *__pyx_t_6 = NULL;
7363 PyObject *__pyx_t_7 = NULL;
7364 PyObject *__pyx_t_8 = NULL;
7365 int __pyx_lineno = 0;
7366 const char *__pyx_filename = NULL;
7367 int __pyx_clineno = 0;
7368 __Pyx_RefNannySetupContext("import_array", 0);
7369
7370 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":881
7371 * # Cython code.
7372 * cdef inline int import_array() except -1:
7373 * try: # <<<<<<<<<<<<<<
7374 * __pyx_import_array()
7375 * except Exception:
7376 */
7377 {
7378 __Pyx_PyThreadState_declare
7379 __Pyx_PyThreadState_assign
7380 __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
7381 __Pyx_XGOTREF(__pyx_t_1);
7382 __Pyx_XGOTREF(__pyx_t_2);
7383 __Pyx_XGOTREF(__pyx_t_3);
7384 /*try:*/ {
7385
7386 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":882
7387 * cdef inline int import_array() except -1:
7388 * try:
7389 * __pyx_import_array() # <<<<<<<<<<<<<<
7390 * except Exception:
7391 * raise ImportError("numpy.core.multiarray failed to import")
7392 */
7393 __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 882, __pyx_L3_error)
7394
7395 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":881
7396 * # Cython code.
7397 * cdef inline int import_array() except -1:
7398 * try: # <<<<<<<<<<<<<<
7399 * __pyx_import_array()
7400 * except Exception:
7401 */
7402 }
7403 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7404 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7405 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7406 goto __pyx_L8_try_end;
7407 __pyx_L3_error:;
7408
7409 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":883
7410 * try:
7411 * __pyx_import_array()
7412 * except Exception: # <<<<<<<<<<<<<<
7413 * raise ImportError("numpy.core.multiarray failed to import")
7414 *
7415 */
7416 __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
7417 if (__pyx_t_4) {
7418 __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
7419 if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 883, __pyx_L5_except_error)
7420 __Pyx_GOTREF(__pyx_t_5);
7421 __Pyx_GOTREF(__pyx_t_6);
7422 __Pyx_GOTREF(__pyx_t_7);
7423
7424 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":884
7425 * __pyx_import_array()
7426 * except Exception:
7427 * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<<
7428 *
7429 * cdef inline int import_umath() except -1:
7430 */
7431 __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 884, __pyx_L5_except_error)
7432 __Pyx_GOTREF(__pyx_t_8);
7433 __Pyx_Raise(__pyx_t_8, 0, 0, 0);
7434 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7435 __PYX_ERR(1, 884, __pyx_L5_except_error)
7436 }
7437 goto __pyx_L5_except_error;
7438 __pyx_L5_except_error:;
7439
7440 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":881
7441 * # Cython code.
7442 * cdef inline int import_array() except -1:
7443 * try: # <<<<<<<<<<<<<<
7444 * __pyx_import_array()
7445 * except Exception:
7446 */
7447 __Pyx_XGIVEREF(__pyx_t_1);
7448 __Pyx_XGIVEREF(__pyx_t_2);
7449 __Pyx_XGIVEREF(__pyx_t_3);
7450 __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
7451 goto __pyx_L1_error;
7452 __pyx_L8_try_end:;
7453 }
7454
7455 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":880
7456 * # Versions of the import_* functions which are more suitable for
7457 * # Cython code.
7458 * cdef inline int import_array() except -1: # <<<<<<<<<<<<<<
7459 * try:
7460 * __pyx_import_array()
7461 */
7462
7463 /* function exit code */
7464 __pyx_r = 0;
7465 goto __pyx_L0;
7466 __pyx_L1_error:;
7467 __Pyx_XDECREF(__pyx_t_5);
7468 __Pyx_XDECREF(__pyx_t_6);
7469 __Pyx_XDECREF(__pyx_t_7);
7470 __Pyx_XDECREF(__pyx_t_8);
7471 __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
7472 __pyx_r = -1;
7473 __pyx_L0:;
7474 __Pyx_RefNannyFinishContext();
7475 return __pyx_r;
7476 }
7477
7478 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":886
7479 * raise ImportError("numpy.core.multiarray failed to import")
7480 *
7481 * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<<
7482 * try:
7483 * _import_umath()
7484 */
7485
__pyx_f_5numpy_import_umath(void)7486 static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
7487 int __pyx_r;
7488 __Pyx_RefNannyDeclarations
7489 PyObject *__pyx_t_1 = NULL;
7490 PyObject *__pyx_t_2 = NULL;
7491 PyObject *__pyx_t_3 = NULL;
7492 int __pyx_t_4;
7493 PyObject *__pyx_t_5 = NULL;
7494 PyObject *__pyx_t_6 = NULL;
7495 PyObject *__pyx_t_7 = NULL;
7496 PyObject *__pyx_t_8 = NULL;
7497 int __pyx_lineno = 0;
7498 const char *__pyx_filename = NULL;
7499 int __pyx_clineno = 0;
7500 __Pyx_RefNannySetupContext("import_umath", 0);
7501
7502 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":887
7503 *
7504 * cdef inline int import_umath() except -1:
7505 * try: # <<<<<<<<<<<<<<
7506 * _import_umath()
7507 * except Exception:
7508 */
7509 {
7510 __Pyx_PyThreadState_declare
7511 __Pyx_PyThreadState_assign
7512 __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
7513 __Pyx_XGOTREF(__pyx_t_1);
7514 __Pyx_XGOTREF(__pyx_t_2);
7515 __Pyx_XGOTREF(__pyx_t_3);
7516 /*try:*/ {
7517
7518 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":888
7519 * cdef inline int import_umath() except -1:
7520 * try:
7521 * _import_umath() # <<<<<<<<<<<<<<
7522 * except Exception:
7523 * raise ImportError("numpy.core.umath failed to import")
7524 */
7525 __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 888, __pyx_L3_error)
7526
7527 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":887
7528 *
7529 * cdef inline int import_umath() except -1:
7530 * try: # <<<<<<<<<<<<<<
7531 * _import_umath()
7532 * except Exception:
7533 */
7534 }
7535 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7536 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7537 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7538 goto __pyx_L8_try_end;
7539 __pyx_L3_error:;
7540
7541 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":889
7542 * try:
7543 * _import_umath()
7544 * except Exception: # <<<<<<<<<<<<<<
7545 * raise ImportError("numpy.core.umath failed to import")
7546 *
7547 */
7548 __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
7549 if (__pyx_t_4) {
7550 __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
7551 if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 889, __pyx_L5_except_error)
7552 __Pyx_GOTREF(__pyx_t_5);
7553 __Pyx_GOTREF(__pyx_t_6);
7554 __Pyx_GOTREF(__pyx_t_7);
7555
7556 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":890
7557 * _import_umath()
7558 * except Exception:
7559 * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<<
7560 *
7561 * cdef inline int import_ufunc() except -1:
7562 */
7563 __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 890, __pyx_L5_except_error)
7564 __Pyx_GOTREF(__pyx_t_8);
7565 __Pyx_Raise(__pyx_t_8, 0, 0, 0);
7566 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7567 __PYX_ERR(1, 890, __pyx_L5_except_error)
7568 }
7569 goto __pyx_L5_except_error;
7570 __pyx_L5_except_error:;
7571
7572 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":887
7573 *
7574 * cdef inline int import_umath() except -1:
7575 * try: # <<<<<<<<<<<<<<
7576 * _import_umath()
7577 * except Exception:
7578 */
7579 __Pyx_XGIVEREF(__pyx_t_1);
7580 __Pyx_XGIVEREF(__pyx_t_2);
7581 __Pyx_XGIVEREF(__pyx_t_3);
7582 __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
7583 goto __pyx_L1_error;
7584 __pyx_L8_try_end:;
7585 }
7586
7587 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":886
7588 * raise ImportError("numpy.core.multiarray failed to import")
7589 *
7590 * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<<
7591 * try:
7592 * _import_umath()
7593 */
7594
7595 /* function exit code */
7596 __pyx_r = 0;
7597 goto __pyx_L0;
7598 __pyx_L1_error:;
7599 __Pyx_XDECREF(__pyx_t_5);
7600 __Pyx_XDECREF(__pyx_t_6);
7601 __Pyx_XDECREF(__pyx_t_7);
7602 __Pyx_XDECREF(__pyx_t_8);
7603 __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
7604 __pyx_r = -1;
7605 __pyx_L0:;
7606 __Pyx_RefNannyFinishContext();
7607 return __pyx_r;
7608 }
7609
7610 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":892
7611 * raise ImportError("numpy.core.umath failed to import")
7612 *
7613 * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<<
7614 * try:
7615 * _import_umath()
7616 */
7617
__pyx_f_5numpy_import_ufunc(void)7618 static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
7619 int __pyx_r;
7620 __Pyx_RefNannyDeclarations
7621 PyObject *__pyx_t_1 = NULL;
7622 PyObject *__pyx_t_2 = NULL;
7623 PyObject *__pyx_t_3 = NULL;
7624 int __pyx_t_4;
7625 PyObject *__pyx_t_5 = NULL;
7626 PyObject *__pyx_t_6 = NULL;
7627 PyObject *__pyx_t_7 = NULL;
7628 PyObject *__pyx_t_8 = NULL;
7629 int __pyx_lineno = 0;
7630 const char *__pyx_filename = NULL;
7631 int __pyx_clineno = 0;
7632 __Pyx_RefNannySetupContext("import_ufunc", 0);
7633
7634 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":893
7635 *
7636 * cdef inline int import_ufunc() except -1:
7637 * try: # <<<<<<<<<<<<<<
7638 * _import_umath()
7639 * except Exception:
7640 */
7641 {
7642 __Pyx_PyThreadState_declare
7643 __Pyx_PyThreadState_assign
7644 __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
7645 __Pyx_XGOTREF(__pyx_t_1);
7646 __Pyx_XGOTREF(__pyx_t_2);
7647 __Pyx_XGOTREF(__pyx_t_3);
7648 /*try:*/ {
7649
7650 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":894
7651 * cdef inline int import_ufunc() except -1:
7652 * try:
7653 * _import_umath() # <<<<<<<<<<<<<<
7654 * except Exception:
7655 * raise ImportError("numpy.core.umath failed to import")
7656 */
7657 __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 894, __pyx_L3_error)
7658
7659 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":893
7660 *
7661 * cdef inline int import_ufunc() except -1:
7662 * try: # <<<<<<<<<<<<<<
7663 * _import_umath()
7664 * except Exception:
7665 */
7666 }
7667 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7668 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7669 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7670 goto __pyx_L8_try_end;
7671 __pyx_L3_error:;
7672
7673 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":895
7674 * try:
7675 * _import_umath()
7676 * except Exception: # <<<<<<<<<<<<<<
7677 * raise ImportError("numpy.core.umath failed to import")
7678 *
7679 */
7680 __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
7681 if (__pyx_t_4) {
7682 __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
7683 if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 895, __pyx_L5_except_error)
7684 __Pyx_GOTREF(__pyx_t_5);
7685 __Pyx_GOTREF(__pyx_t_6);
7686 __Pyx_GOTREF(__pyx_t_7);
7687
7688 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":896
7689 * _import_umath()
7690 * except Exception:
7691 * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<<
7692 *
7693 * cdef extern from *:
7694 */
7695 __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 896, __pyx_L5_except_error)
7696 __Pyx_GOTREF(__pyx_t_8);
7697 __Pyx_Raise(__pyx_t_8, 0, 0, 0);
7698 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7699 __PYX_ERR(1, 896, __pyx_L5_except_error)
7700 }
7701 goto __pyx_L5_except_error;
7702 __pyx_L5_except_error:;
7703
7704 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":893
7705 *
7706 * cdef inline int import_ufunc() except -1:
7707 * try: # <<<<<<<<<<<<<<
7708 * _import_umath()
7709 * except Exception:
7710 */
7711 __Pyx_XGIVEREF(__pyx_t_1);
7712 __Pyx_XGIVEREF(__pyx_t_2);
7713 __Pyx_XGIVEREF(__pyx_t_3);
7714 __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
7715 goto __pyx_L1_error;
7716 __pyx_L8_try_end:;
7717 }
7718
7719 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":892
7720 * raise ImportError("numpy.core.umath failed to import")
7721 *
7722 * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<<
7723 * try:
7724 * _import_umath()
7725 */
7726
7727 /* function exit code */
7728 __pyx_r = 0;
7729 goto __pyx_L0;
7730 __pyx_L1_error:;
7731 __Pyx_XDECREF(__pyx_t_5);
7732 __Pyx_XDECREF(__pyx_t_6);
7733 __Pyx_XDECREF(__pyx_t_7);
7734 __Pyx_XDECREF(__pyx_t_8);
7735 __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
7736 __pyx_r = -1;
7737 __pyx_L0:;
7738 __Pyx_RefNannyFinishContext();
7739 return __pyx_r;
7740 }
7741
7742 static PyMethodDef __pyx_methods[] = {
7743 {"ft_hash_bytes", (PyCFunction)__pyx_pw_6gensim_6models_14fasttext_inner_3ft_hash_bytes, METH_O, __pyx_doc_6gensim_6models_14fasttext_inner_2ft_hash_bytes},
7744 {"compute_ngrams", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gensim_6models_14fasttext_inner_5compute_ngrams, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gensim_6models_14fasttext_inner_4compute_ngrams},
7745 {"compute_ngrams_bytes", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gensim_6models_14fasttext_inner_7compute_ngrams_bytes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gensim_6models_14fasttext_inner_6compute_ngrams_bytes},
7746 {0, 0, 0, 0}
7747 };
7748
7749 #if PY_MAJOR_VERSION >= 3
7750 #if CYTHON_PEP489_MULTI_PHASE_INIT
7751 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
7752 static int __pyx_pymod_exec_fasttext_inner(PyObject* module); /*proto*/
7753 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
7754 {Py_mod_create, (void*)__pyx_pymod_create},
7755 {Py_mod_exec, (void*)__pyx_pymod_exec_fasttext_inner},
7756 {0, NULL}
7757 };
7758 #endif
7759
7760 static struct PyModuleDef __pyx_moduledef = {
7761 PyModuleDef_HEAD_INIT,
7762 "fasttext_inner",
7763 __pyx_k_Optimized_Cython_functions_for_t, /* m_doc */
7764 #if CYTHON_PEP489_MULTI_PHASE_INIT
7765 0, /* m_size */
7766 #else
7767 -1, /* m_size */
7768 #endif
7769 __pyx_methods /* m_methods */,
7770 #if CYTHON_PEP489_MULTI_PHASE_INIT
7771 __pyx_moduledef_slots, /* m_slots */
7772 #else
7773 NULL, /* m_reload */
7774 #endif
7775 NULL, /* m_traverse */
7776 NULL, /* m_clear */
7777 NULL /* m_free */
7778 };
7779 #endif
7780 #ifndef CYTHON_SMALL_CODE
7781 #if defined(__clang__)
7782 #define CYTHON_SMALL_CODE
7783 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
7784 #define CYTHON_SMALL_CODE __attribute__((cold))
7785 #else
7786 #define CYTHON_SMALL_CODE
7787 #endif
7788 #endif
7789
7790 static __Pyx_StringTabEntry __pyx_string_tab[] = {
7791 {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
7792 {&__pyx_n_s_MAX_WORDS_IN_BATCH, __pyx_k_MAX_WORDS_IN_BATCH, sizeof(__pyx_k_MAX_WORDS_IN_BATCH), 0, 0, 1, 1},
7793 {&__pyx_kp_u__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 1, 0, 0},
7794 {&__pyx_kp_u__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 1, 0, 0},
7795 {&__pyx_n_s_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 0, 0, 1, 1},
7796 {&__pyx_n_s_bucket, __pyx_k_bucket, sizeof(__pyx_k_bucket), 0, 0, 1, 1},
7797 {&__pyx_n_s_buckets_word, __pyx_k_buckets_word, sizeof(__pyx_k_buckets_word), 0, 0, 1, 1},
7798 {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
7799 {&__pyx_n_s_cbow_mean, __pyx_k_cbow_mean, sizeof(__pyx_k_cbow_mean), 0, 0, 1, 1},
7800 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
7801 {&__pyx_n_s_code, __pyx_k_code, sizeof(__pyx_k_code), 0, 0, 1, 1},
7802 {&__pyx_n_s_cum_table, __pyx_k_cum_table, sizeof(__pyx_k_cum_table), 0, 0, 1, 1},
7803 {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
7804 {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
7805 {&__pyx_n_s_expandos, __pyx_k_expandos, sizeof(__pyx_k_expandos), 0, 0, 1, 1},
7806 {&__pyx_n_s_gensim_models_fasttext_inner, __pyx_k_gensim_models_fasttext_inner, sizeof(__pyx_k_gensim_models_fasttext_inner), 0, 0, 1, 1},
7807 {&__pyx_kp_s_gensim_models_fasttext_inner_pyx, __pyx_k_gensim_models_fasttext_inner_pyx, sizeof(__pyx_k_gensim_models_fasttext_inner_pyx), 0, 0, 1, 0},
7808 {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
7809 {&__pyx_n_s_hs, __pyx_k_hs, sizeof(__pyx_k_hs), 0, 0, 1, 1},
7810 {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
7811 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
7812 {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
7813 {&__pyx_n_s_key_to_index, __pyx_k_key_to_index, sizeof(__pyx_k_key_to_index), 0, 0, 1, 1},
7814 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
7815 {&__pyx_n_s_max_n, __pyx_k_max_n, sizeof(__pyx_k_max_n), 0, 0, 1, 1},
7816 {&__pyx_n_s_min_n, __pyx_k_min_n, sizeof(__pyx_k_min_n), 0, 0, 1, 1},
7817 {&__pyx_n_s_model, __pyx_k_model, sizeof(__pyx_k_model), 0, 0, 1, 1},
7818 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
7819 {&__pyx_n_s_negative, __pyx_k_negative, sizeof(__pyx_k_negative), 0, 0, 1, 1},
7820 {&__pyx_n_s_neu1, __pyx_k_neu1, sizeof(__pyx_k_neu1), 0, 0, 1, 1},
7821 {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
7822 {&__pyx_n_s_num_sentences, __pyx_k_num_sentences, sizeof(__pyx_k_num_sentences), 0, 0, 1, 1},
7823 {&__pyx_n_s_num_words, __pyx_k_num_words, sizeof(__pyx_k_num_words), 0, 0, 1, 1},
7824 {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
7825 {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0},
7826 {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0},
7827 {&__pyx_n_s_point, __pyx_k_point, sizeof(__pyx_k_point), 0, 0, 1, 1},
7828 {&__pyx_n_s_randint, __pyx_k_randint, sizeof(__pyx_k_randint), 0, 0, 1, 1},
7829 {&__pyx_n_s_random, __pyx_k_random, sizeof(__pyx_k_random), 0, 0, 1, 1},
7830 {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
7831 {&__pyx_kp_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 0},
7832 {&__pyx_n_s_sample, __pyx_k_sample, sizeof(__pyx_k_sample), 0, 0, 1, 1},
7833 {&__pyx_n_s_sample_int, __pyx_k_sample_int, sizeof(__pyx_k_sample_int), 0, 0, 1, 1},
7834 {&__pyx_n_s_sentences, __pyx_k_sentences, sizeof(__pyx_k_sentences), 0, 0, 1, 1},
7835 {&__pyx_n_s_sg, __pyx_k_sg, sizeof(__pyx_k_sg), 0, 0, 1, 1},
7836 {&__pyx_n_s_syn1, __pyx_k_syn1, sizeof(__pyx_k_syn1), 0, 0, 1, 1},
7837 {&__pyx_n_s_syn1neg, __pyx_k_syn1neg, sizeof(__pyx_k_syn1neg), 0, 0, 1, 1},
7838 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
7839 {&__pyx_n_s_train_batch_any, __pyx_k_train_batch_any, sizeof(__pyx_k_train_batch_any), 0, 0, 1, 1},
7840 {&__pyx_kp_s_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 0, 1, 0},
7841 {&__pyx_n_s_vector_size, __pyx_k_vector_size, sizeof(__pyx_k_vector_size), 0, 0, 1, 1},
7842 {&__pyx_n_s_vectors_ngrams, __pyx_k_vectors_ngrams, sizeof(__pyx_k_vectors_ngrams), 0, 0, 1, 1},
7843 {&__pyx_n_s_vectors_ngrams_lockf, __pyx_k_vectors_ngrams_lockf, sizeof(__pyx_k_vectors_ngrams_lockf), 0, 0, 1, 1},
7844 {&__pyx_n_s_vectors_vocab, __pyx_k_vectors_vocab, sizeof(__pyx_k_vectors_vocab), 0, 0, 1, 1},
7845 {&__pyx_n_s_vectors_vocab_lockf, __pyx_k_vectors_vocab_lockf, sizeof(__pyx_k_vectors_vocab_lockf), 0, 0, 1, 1},
7846 {&__pyx_n_s_window, __pyx_k_window, sizeof(__pyx_k_window), 0, 0, 1, 1},
7847 {&__pyx_n_s_word, __pyx_k_word, sizeof(__pyx_k_word), 0, 0, 1, 1},
7848 {&__pyx_n_s_work, __pyx_k_work, sizeof(__pyx_k_work), 0, 0, 1, 1},
7849 {&__pyx_n_s_workers, __pyx_k_workers, sizeof(__pyx_k_workers), 0, 0, 1, 1},
7850 {&__pyx_n_s_wv, __pyx_k_wv, sizeof(__pyx_k_wv), 0, 0, 1, 1},
7851 {0, 0, 0, 0, 0, 0, 0}
7852 };
__Pyx_InitCachedBuiltins(void)7853 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
7854 __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 116, __pyx_L1_error)
7855 __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 604, __pyx_L1_error)
7856 __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 884, __pyx_L1_error)
7857 return 0;
7858 __pyx_L1_error:;
7859 return -1;
7860 }
7861
__Pyx_InitCachedConstants(void)7862 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
7863 __Pyx_RefNannyDeclarations
7864 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
7865
7866 /* "gensim/models/fasttext_inner.pyx":422
7867 * c.cum_table_len = len(model.cum_table)
7868 * if c.negative or c.sample:
7869 * c.next_random = (2**24) * model.random.randint(0, 2**24) + model.random.randint(0, 2**24) # <<<<<<<<<<<<<<
7870 *
7871 * # convert Python structures to primitive types, so we can release the GIL
7872 */
7873 __pyx_tuple_ = PyTuple_Pack(2, __pyx_int_0, __pyx_int_16777216); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 422, __pyx_L1_error)
7874 __Pyx_GOTREF(__pyx_tuple_);
7875 __Pyx_GIVEREF(__pyx_tuple_);
7876
7877 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":884
7878 * __pyx_import_array()
7879 * except Exception:
7880 * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<<
7881 *
7882 * cdef inline int import_umath() except -1:
7883 */
7884 __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 884, __pyx_L1_error)
7885 __Pyx_GOTREF(__pyx_tuple__4);
7886 __Pyx_GIVEREF(__pyx_tuple__4);
7887
7888 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":890
7889 * _import_umath()
7890 * except Exception:
7891 * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<<
7892 *
7893 * cdef inline int import_ufunc() except -1:
7894 */
7895 __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 890, __pyx_L1_error)
7896 __Pyx_GOTREF(__pyx_tuple__5);
7897 __Pyx_GIVEREF(__pyx_tuple__5);
7898
7899 /* "gensim/models/fasttext_inner.pyx":569
7900 *
7901 *
7902 * def train_batch_any(model, sentences, alpha, _work, _neu1): # <<<<<<<<<<<<<<
7903 * """Update the model by training on a sequence of sentences.
7904 *
7905 */
7906 __pyx_tuple__6 = PyTuple_Pack(10, __pyx_n_s_model, __pyx_n_s_sentences, __pyx_n_s_alpha, __pyx_n_s_work, __pyx_n_s_neu1, __pyx_n_s_c, __pyx_n_s_num_words, __pyx_n_s_num_sentences, __pyx_n_s_i, __pyx_n_s_randint); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 569, __pyx_L1_error)
7907 __Pyx_GOTREF(__pyx_tuple__6);
7908 __Pyx_GIVEREF(__pyx_tuple__6);
7909 __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(5, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gensim_models_fasttext_inner_pyx, __pyx_n_s_train_batch_any, 569, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 569, __pyx_L1_error)
7910
7911 /* "gensim/models/fasttext_inner.pyx":718
7912 *
7913 *
7914 * def init(): # <<<<<<<<<<<<<<
7915 * """Precompute function `sigmoid(x) = 1 / (1 + exp(-x))`, for x values discretized into table EXP_TABLE.
7916 * Also calculate log(sigmoid(x)) into LOG_TABLE.
7917 */
7918 __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_i); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 718, __pyx_L1_error)
7919 __Pyx_GOTREF(__pyx_tuple__8);
7920 __Pyx_GIVEREF(__pyx_tuple__8);
7921 __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gensim_models_fasttext_inner_pyx, __pyx_n_s_init, 718, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 718, __pyx_L1_error)
7922 __Pyx_RefNannyFinishContext();
7923 return 0;
7924 __pyx_L1_error:;
7925 __Pyx_RefNannyFinishContext();
7926 return -1;
7927 }
7928
__Pyx_InitGlobals(void)7929 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
7930 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
7931 __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
7932 __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
7933 __pyx_int_10000 = PyInt_FromLong(10000L); if (unlikely(!__pyx_int_10000)) __PYX_ERR(0, 1, __pyx_L1_error)
7934 __pyx_int_16777216 = PyInt_FromLong(16777216L); if (unlikely(!__pyx_int_16777216)) __PYX_ERR(0, 1, __pyx_L1_error)
7935 return 0;
7936 __pyx_L1_error:;
7937 return -1;
7938 }
7939
7940 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
7941 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
7942 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
7943 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
7944 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
7945 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
7946 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
7947
__Pyx_modinit_global_init_code(void)7948 static int __Pyx_modinit_global_init_code(void) {
7949 __Pyx_RefNannyDeclarations
7950 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
7951 /*--- Global init code ---*/
7952 __Pyx_RefNannyFinishContext();
7953 return 0;
7954 }
7955
__Pyx_modinit_variable_export_code(void)7956 static int __Pyx_modinit_variable_export_code(void) {
7957 __Pyx_RefNannyDeclarations
7958 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
7959 /*--- Variable export code ---*/
7960 __Pyx_RefNannyFinishContext();
7961 return 0;
7962 }
7963
__Pyx_modinit_function_export_code(void)7964 static int __Pyx_modinit_function_export_code(void) {
7965 __Pyx_RefNannyDeclarations
7966 int __pyx_lineno = 0;
7967 const char *__pyx_filename = NULL;
7968 int __pyx_clineno = 0;
7969 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
7970 /*--- Function export code ---*/
7971 if (__Pyx_ExportFunction("init_ft_config", (void (*)(void))__pyx_f_6gensim_6models_14fasttext_inner_init_ft_config, "void (struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7972 if (__Pyx_ExportFunction("populate_ft_config", (void (*)(void))__pyx_f_6gensim_6models_14fasttext_inner_populate_ft_config, "PyObject *(struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7973 if (__Pyx_ExportFunction("fasttext_fast_sentence_sg_neg", (void (*)(void))__pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_sg_neg, "void (struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, int, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7974 if (__Pyx_ExportFunction("fasttext_fast_sentence_sg_hs", (void (*)(void))__pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_sg_hs, "void (struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, int, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7975 if (__Pyx_ExportFunction("fasttext_fast_sentence_cbow_neg", (void (*)(void))__pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_cbow_neg, "void (struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, int, int, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7976 if (__Pyx_ExportFunction("fasttext_fast_sentence_cbow_hs", (void (*)(void))__pyx_f_6gensim_6models_14fasttext_inner_fasttext_fast_sentence_cbow_hs, "void (struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, int, int, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7977 if (__Pyx_ExportFunction("fasttext_train_any", (void (*)(void))__pyx_f_6gensim_6models_14fasttext_inner_fasttext_train_any, "void (struct __pyx_t_6gensim_6models_14fasttext_inner_FastTextConfig *, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7978 __Pyx_RefNannyFinishContext();
7979 return 0;
7980 __pyx_L1_error:;
7981 __Pyx_RefNannyFinishContext();
7982 return -1;
7983 }
7984
__Pyx_modinit_type_init_code(void)7985 static int __Pyx_modinit_type_init_code(void) {
7986 __Pyx_RefNannyDeclarations
7987 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
7988 /*--- Type init code ---*/
7989 __Pyx_RefNannyFinishContext();
7990 return 0;
7991 }
7992
__Pyx_modinit_type_import_code(void)7993 static int __Pyx_modinit_type_import_code(void) {
7994 __Pyx_RefNannyDeclarations
7995 PyObject *__pyx_t_1 = NULL;
7996 int __pyx_lineno = 0;
7997 const char *__pyx_filename = NULL;
7998 int __pyx_clineno = 0;
7999 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
8000 /*--- Type import code ---*/
8001 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error)
8002 __Pyx_GOTREF(__pyx_t_1);
8003 __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
8004 #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
8005 sizeof(PyTypeObject),
8006 #else
8007 sizeof(PyHeapTypeObject),
8008 #endif
8009 __Pyx_ImportType_CheckSize_Warn);
8010 if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error)
8011 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8012 __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 199, __pyx_L1_error)
8013 __Pyx_GOTREF(__pyx_t_1);
8014 __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
8015 if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 199, __pyx_L1_error)
8016 __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore);
8017 if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 222, __pyx_L1_error)
8018 __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore);
8019 if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 226, __pyx_L1_error)
8020 __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
8021 if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 238, __pyx_L1_error)
8022 __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore);
8023 if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 764, __pyx_L1_error)
8024 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8025 __Pyx_RefNannyFinishContext();
8026 return 0;
8027 __pyx_L1_error:;
8028 __Pyx_XDECREF(__pyx_t_1);
8029 __Pyx_RefNannyFinishContext();
8030 return -1;
8031 }
8032
__Pyx_modinit_variable_import_code(void)8033 static int __Pyx_modinit_variable_import_code(void) {
8034 __Pyx_RefNannyDeclarations
8035 PyObject *__pyx_t_1 = NULL;
8036 int __pyx_lineno = 0;
8037 const char *__pyx_filename = NULL;
8038 int __pyx_clineno = 0;
8039 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
8040 /*--- Variable import code ---*/
8041 __pyx_t_1 = PyImport_ImportModule("gensim.models.word2vec_inner"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
8042 __Pyx_GOTREF(__pyx_t_1);
8043 if (__Pyx_ImportVoidPtr(__pyx_t_1, "scopy", (void **)&__pyx_vp_6gensim_6models_14word2vec_inner_scopy, "__pyx_t_6gensim_6models_14word2vec_inner_scopy_ptr") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8044 if (__Pyx_ImportVoidPtr(__pyx_t_1, "saxpy", (void **)&__pyx_vp_6gensim_6models_14word2vec_inner_saxpy, "__pyx_t_6gensim_6models_14word2vec_inner_saxpy_ptr") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8045 if (__Pyx_ImportVoidPtr(__pyx_t_1, "sdot", (void **)&__pyx_vp_6gensim_6models_14word2vec_inner_sdot, "__pyx_t_6gensim_6models_14word2vec_inner_sdot_ptr") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8046 if (__Pyx_ImportVoidPtr(__pyx_t_1, "dsdot", (void **)&__pyx_vp_6gensim_6models_14word2vec_inner_dsdot, "__pyx_t_6gensim_6models_14word2vec_inner_dsdot_ptr") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8047 if (__Pyx_ImportVoidPtr(__pyx_t_1, "snrm2", (void **)&__pyx_vp_6gensim_6models_14word2vec_inner_snrm2, "__pyx_t_6gensim_6models_14word2vec_inner_snrm2_ptr") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8048 if (__Pyx_ImportVoidPtr(__pyx_t_1, "sscal", (void **)&__pyx_vp_6gensim_6models_14word2vec_inner_sscal, "__pyx_t_6gensim_6models_14word2vec_inner_sscal_ptr") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8049 if (__Pyx_ImportVoidPtr(__pyx_t_1, "EXP_TABLE", (void **)&__pyx_vp_6gensim_6models_14word2vec_inner_EXP_TABLE, "__pyx_t_6gensim_6models_14word2vec_inner_REAL_t [0x3E8]") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8050 if (__Pyx_ImportVoidPtr(__pyx_t_1, "our_dot", (void **)&__pyx_vp_6gensim_6models_14word2vec_inner_our_dot, "__pyx_t_6gensim_6models_14word2vec_inner_our_dot_ptr") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8051 if (__Pyx_ImportVoidPtr(__pyx_t_1, "our_saxpy", (void **)&__pyx_vp_6gensim_6models_14word2vec_inner_our_saxpy, "__pyx_t_6gensim_6models_14word2vec_inner_our_saxpy_ptr") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8052 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8053 __Pyx_RefNannyFinishContext();
8054 return 0;
8055 __pyx_L1_error:;
8056 __Pyx_XDECREF(__pyx_t_1);
8057 __Pyx_RefNannyFinishContext();
8058 return -1;
8059 }
8060
__Pyx_modinit_function_import_code(void)8061 static int __Pyx_modinit_function_import_code(void) {
8062 __Pyx_RefNannyDeclarations
8063 PyObject *__pyx_t_1 = NULL;
8064 int __pyx_lineno = 0;
8065 const char *__pyx_filename = NULL;
8066 int __pyx_clineno = 0;
8067 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
8068 /*--- Function import code ---*/
8069 __pyx_t_1 = PyImport_ImportModule("gensim.models.word2vec_inner"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
8070 __Pyx_GOTREF(__pyx_t_1);
8071 if (__Pyx_ImportFunction(__pyx_t_1, "bisect_left", (void (**)(void))&__pyx_f_6gensim_6models_14word2vec_inner_bisect_left, "unsigned PY_LONG_LONG (__pyx_t_5numpy_uint32_t *, unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, unsigned PY_LONG_LONG)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8072 if (__Pyx_ImportFunction(__pyx_t_1, "random_int32", (void (**)(void))&__pyx_f_6gensim_6models_14word2vec_inner_random_int32, "unsigned PY_LONG_LONG (unsigned PY_LONG_LONG *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8073 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8074 __Pyx_RefNannyFinishContext();
8075 return 0;
8076 __pyx_L1_error:;
8077 __Pyx_XDECREF(__pyx_t_1);
8078 __Pyx_RefNannyFinishContext();
8079 return -1;
8080 }
8081
8082
8083 #ifndef CYTHON_NO_PYINIT_EXPORT
8084 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
8085 #elif PY_MAJOR_VERSION < 3
8086 #ifdef __cplusplus
8087 #define __Pyx_PyMODINIT_FUNC extern "C" void
8088 #else
8089 #define __Pyx_PyMODINIT_FUNC void
8090 #endif
8091 #else
8092 #ifdef __cplusplus
8093 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
8094 #else
8095 #define __Pyx_PyMODINIT_FUNC PyObject *
8096 #endif
8097 #endif
8098
8099
8100 #if PY_MAJOR_VERSION < 3
8101 __Pyx_PyMODINIT_FUNC initfasttext_inner(void) CYTHON_SMALL_CODE; /*proto*/
initfasttext_inner(void)8102 __Pyx_PyMODINIT_FUNC initfasttext_inner(void)
8103 #else
8104 __Pyx_PyMODINIT_FUNC PyInit_fasttext_inner(void) CYTHON_SMALL_CODE; /*proto*/
8105 __Pyx_PyMODINIT_FUNC PyInit_fasttext_inner(void)
8106 #if CYTHON_PEP489_MULTI_PHASE_INIT
8107 {
8108 return PyModuleDef_Init(&__pyx_moduledef);
8109 }
8110 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
8111 #if PY_VERSION_HEX >= 0x030700A1
8112 static PY_INT64_T main_interpreter_id = -1;
8113 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
8114 if (main_interpreter_id == -1) {
8115 main_interpreter_id = current_id;
8116 return (unlikely(current_id == -1)) ? -1 : 0;
8117 } else if (unlikely(main_interpreter_id != current_id))
8118 #else
8119 static PyInterpreterState *main_interpreter = NULL;
8120 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
8121 if (!main_interpreter) {
8122 main_interpreter = current_interpreter;
8123 } else if (unlikely(main_interpreter != current_interpreter))
8124 #endif
8125 {
8126 PyErr_SetString(
8127 PyExc_ImportError,
8128 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
8129 return -1;
8130 }
8131 return 0;
8132 }
8133 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
8134 PyObject *value = PyObject_GetAttrString(spec, from_name);
8135 int result = 0;
8136 if (likely(value)) {
8137 if (allow_none || value != Py_None) {
8138 result = PyDict_SetItemString(moddict, to_name, value);
8139 }
8140 Py_DECREF(value);
8141 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
8142 PyErr_Clear();
8143 } else {
8144 result = -1;
8145 }
8146 return result;
8147 }
8148 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
8149 PyObject *module = NULL, *moddict, *modname;
8150 if (__Pyx_check_single_interpreter())
8151 return NULL;
8152 if (__pyx_m)
8153 return __Pyx_NewRef(__pyx_m);
8154 modname = PyObject_GetAttrString(spec, "name");
8155 if (unlikely(!modname)) goto bad;
8156 module = PyModule_NewObject(modname);
8157 Py_DECREF(modname);
8158 if (unlikely(!module)) goto bad;
8159 moddict = PyModule_GetDict(module);
8160 if (unlikely(!moddict)) goto bad;
8161 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
8162 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
8163 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
8164 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
8165 return module;
8166 bad:
8167 Py_XDECREF(module);
8168 return NULL;
8169 }
8170
8171
8172 static CYTHON_SMALL_CODE int __pyx_pymod_exec_fasttext_inner(PyObject *__pyx_pyinit_module)
8173 #endif
8174 #endif
8175 {
8176 PyObject *__pyx_t_1 = NULL;
8177 PyObject *__pyx_t_2 = NULL;
8178 int __pyx_lineno = 0;
8179 const char *__pyx_filename = NULL;
8180 int __pyx_clineno = 0;
8181 __Pyx_RefNannyDeclarations
8182 #if CYTHON_PEP489_MULTI_PHASE_INIT
8183 if (__pyx_m) {
8184 if (__pyx_m == __pyx_pyinit_module) return 0;
8185 PyErr_SetString(PyExc_RuntimeError, "Module 'fasttext_inner' has already been imported. Re-initialisation is not supported.");
8186 return -1;
8187 }
8188 #elif PY_MAJOR_VERSION >= 3
8189 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
8190 #endif
8191 #if CYTHON_REFNANNY
8192 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
8193 if (!__Pyx_RefNanny) {
8194 PyErr_Clear();
8195 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
8196 if (!__Pyx_RefNanny)
8197 Py_FatalError("failed to import 'refnanny' module");
8198 }
8199 #endif
8200 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_fasttext_inner(void)", 0);
8201 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8202 #ifdef __Pxy_PyFrame_Initialize_Offsets
8203 __Pxy_PyFrame_Initialize_Offsets();
8204 #endif
8205 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
8206 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
8207 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
8208 #ifdef __Pyx_CyFunction_USED
8209 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8210 #endif
8211 #ifdef __Pyx_FusedFunction_USED
8212 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8213 #endif
8214 #ifdef __Pyx_Coroutine_USED
8215 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8216 #endif
8217 #ifdef __Pyx_Generator_USED
8218 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8219 #endif
8220 #ifdef __Pyx_AsyncGen_USED
8221 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8222 #endif
8223 #ifdef __Pyx_StopAsyncIteration_USED
8224 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8225 #endif
8226 /*--- Library function declarations ---*/
8227 /*--- Threads initialization code ---*/
8228 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
8229 #ifdef WITH_THREAD /* Python build with threading support? */
8230 PyEval_InitThreads();
8231 #endif
8232 #endif
8233 /*--- Module creation code ---*/
8234 #if CYTHON_PEP489_MULTI_PHASE_INIT
8235 __pyx_m = __pyx_pyinit_module;
8236 Py_INCREF(__pyx_m);
8237 #else
8238 #if PY_MAJOR_VERSION < 3
8239 __pyx_m = Py_InitModule4("fasttext_inner", __pyx_methods, __pyx_k_Optimized_Cython_functions_for_t, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
8240 #else
8241 __pyx_m = PyModule_Create(&__pyx_moduledef);
8242 #endif
8243 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
8244 #endif
8245 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
8246 Py_INCREF(__pyx_d);
8247 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
8248 Py_INCREF(__pyx_b);
8249 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
8250 Py_INCREF(__pyx_cython_runtime);
8251 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
8252 /*--- Initialize various global constants etc. ---*/
8253 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8254 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
8255 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8256 #endif
8257 if (__pyx_module_is_main_gensim__models__fasttext_inner) {
8258 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8259 }
8260 #if PY_MAJOR_VERSION >= 3
8261 {
8262 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
8263 if (!PyDict_GetItemString(modules, "gensim.models.fasttext_inner")) {
8264 if (unlikely(PyDict_SetItemString(modules, "gensim.models.fasttext_inner", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
8265 }
8266 }
8267 #endif
8268 /*--- Builtin init code ---*/
8269 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8270 /*--- Constants init code ---*/
8271 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8272 /*--- Global type/function init code ---*/
8273 (void)__Pyx_modinit_global_init_code();
8274 (void)__Pyx_modinit_variable_export_code();
8275 if (unlikely(__Pyx_modinit_function_export_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
8276 (void)__Pyx_modinit_type_init_code();
8277 if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
8278 if (unlikely(__Pyx_modinit_variable_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
8279 if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
8280 /*--- Execution code ---*/
8281 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
8282 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8283 #endif
8284
8285 /* "gensim/models/fasttext_inner.pyx":32
8286 *
8287 * import cython
8288 * import numpy as np # <<<<<<<<<<<<<<
8289 * cimport numpy as np
8290 *
8291 */
8292 __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
8293 __Pyx_GOTREF(__pyx_t_1);
8294 if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
8295 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8296
8297 /* "gensim/models/fasttext_inner.pyx":70
8298 * cdef REAL_t[EXP_TABLE_SIZE] LOG_TABLE
8299 *
8300 * cdef int ONE = 1 # <<<<<<<<<<<<<<
8301 * cdef REAL_t ONEF = <REAL_t>1.0
8302 *
8303 */
8304 __pyx_v_6gensim_6models_14fasttext_inner_ONE = 1;
8305
8306 /* "gensim/models/fasttext_inner.pyx":71
8307 *
8308 * cdef int ONE = 1
8309 * cdef REAL_t ONEF = <REAL_t>1.0 # <<<<<<<<<<<<<<
8310 *
8311 *
8312 */
8313 __pyx_v_6gensim_6models_14fasttext_inner_ONEF = ((__pyx_t_6gensim_6models_14word2vec_inner_REAL_t)1.0);
8314
8315 /* "gensim/models/fasttext_inner.pyx":569
8316 *
8317 *
8318 * def train_batch_any(model, sentences, alpha, _work, _neu1): # <<<<<<<<<<<<<<
8319 * """Update the model by training on a sequence of sentences.
8320 *
8321 */
8322 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6gensim_6models_14fasttext_inner_1train_batch_any, NULL, __pyx_n_s_gensim_models_fasttext_inner); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 569, __pyx_L1_error)
8323 __Pyx_GOTREF(__pyx_t_1);
8324 if (PyDict_SetItem(__pyx_d, __pyx_n_s_train_batch_any, __pyx_t_1) < 0) __PYX_ERR(0, 569, __pyx_L1_error)
8325 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8326
8327 /* "gensim/models/fasttext_inner.pyx":668
8328 * # as opposed to a new character.
8329 * #
8330 * cdef unsigned char _MB_MASK = 0xC0 # <<<<<<<<<<<<<<
8331 * cdef unsigned char _MB_START = 0x80
8332 *
8333 */
8334 __pyx_v_6gensim_6models_14fasttext_inner__MB_MASK = 0xC0;
8335
8336 /* "gensim/models/fasttext_inner.pyx":669
8337 * #
8338 * cdef unsigned char _MB_MASK = 0xC0
8339 * cdef unsigned char _MB_START = 0x80 # <<<<<<<<<<<<<<
8340 *
8341 *
8342 */
8343 __pyx_v_6gensim_6models_14fasttext_inner__MB_START = 0x80;
8344
8345 /* "gensim/models/fasttext_inner.pyx":718
8346 *
8347 *
8348 * def init(): # <<<<<<<<<<<<<<
8349 * """Precompute function `sigmoid(x) = 1 / (1 + exp(-x))`, for x values discretized into table EXP_TABLE.
8350 * Also calculate log(sigmoid(x)) into LOG_TABLE.
8351 */
8352 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6gensim_6models_14fasttext_inner_9init, NULL, __pyx_n_s_gensim_models_fasttext_inner); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 718, __pyx_L1_error)
8353 __Pyx_GOTREF(__pyx_t_1);
8354 if (PyDict_SetItem(__pyx_d, __pyx_n_s_init, __pyx_t_1) < 0) __PYX_ERR(0, 718, __pyx_L1_error)
8355 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8356
8357 /* "gensim/models/fasttext_inner.pyx":734
8358 *
8359 *
8360 * init() # initialize the module # <<<<<<<<<<<<<<
8361 * MAX_WORDS_IN_BATCH = MAX_SENTENCE_LEN
8362 */
8363 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_init); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 734, __pyx_L1_error)
8364 __Pyx_GOTREF(__pyx_t_1);
8365 __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 734, __pyx_L1_error)
8366 __Pyx_GOTREF(__pyx_t_2);
8367 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8368 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8369
8370 /* "gensim/models/fasttext_inner.pyx":735
8371 *
8372 * init() # initialize the module
8373 * MAX_WORDS_IN_BATCH = MAX_SENTENCE_LEN # <<<<<<<<<<<<<<
8374 */
8375 if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAX_WORDS_IN_BATCH, __pyx_int_10000) < 0) __PYX_ERR(0, 735, __pyx_L1_error)
8376
8377 /* "gensim/models/fasttext_inner.pyx":1
8378 * #!/usr/bin/env cython # <<<<<<<<<<<<<<
8379 * # cython: boundscheck=False
8380 * # cython: wraparound=False
8381 */
8382 __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
8383 __Pyx_GOTREF(__pyx_t_2);
8384 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8385 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8386
8387 /* "../../envs/gensim/lib/python3.8/site-packages/numpy/__init__.pxd":892
8388 * raise ImportError("numpy.core.umath failed to import")
8389 *
8390 * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<<
8391 * try:
8392 * _import_umath()
8393 */
8394
8395 /*--- Wrapped vars code ---*/
8396
8397 goto __pyx_L0;
8398 __pyx_L1_error:;
8399 __Pyx_XDECREF(__pyx_t_1);
8400 __Pyx_XDECREF(__pyx_t_2);
8401 if (__pyx_m) {
8402 if (__pyx_d) {
8403 __Pyx_AddTraceback("init gensim.models.fasttext_inner", __pyx_clineno, __pyx_lineno, __pyx_filename);
8404 }
8405 Py_CLEAR(__pyx_m);
8406 } else if (!PyErr_Occurred()) {
8407 PyErr_SetString(PyExc_ImportError, "init gensim.models.fasttext_inner");
8408 }
8409 __pyx_L0:;
8410 __Pyx_RefNannyFinishContext();
8411 #if CYTHON_PEP489_MULTI_PHASE_INIT
8412 return (__pyx_m != NULL) ? 0 : -1;
8413 #elif PY_MAJOR_VERSION >= 3
8414 return __pyx_m;
8415 #else
8416 return;
8417 #endif
8418 }
8419
8420 /* --- Runtime support code --- */
8421 /* Refnanny */
8422 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)8423 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
8424 PyObject *m = NULL, *p = NULL;
8425 void *r = NULL;
8426 m = PyImport_ImportModule(modname);
8427 if (!m) goto end;
8428 p = PyObject_GetAttrString(m, "RefNannyAPI");
8429 if (!p) goto end;
8430 r = PyLong_AsVoidPtr(p);
8431 end:
8432 Py_XDECREF(p);
8433 Py_XDECREF(m);
8434 return (__Pyx_RefNannyAPIStruct *)r;
8435 }
8436 #endif
8437
8438 /* PyObjectGetAttrStr */
8439 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)8440 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
8441 PyTypeObject* tp = Py_TYPE(obj);
8442 if (likely(tp->tp_getattro))
8443 return tp->tp_getattro(obj, attr_name);
8444 #if PY_MAJOR_VERSION < 3
8445 if (likely(tp->tp_getattr))
8446 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
8447 #endif
8448 return PyObject_GetAttr(obj, attr_name);
8449 }
8450 #endif
8451
8452 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)8453 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
8454 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
8455 if (unlikely(!result)) {
8456 PyErr_Format(PyExc_NameError,
8457 #if PY_MAJOR_VERSION >= 3
8458 "name '%U' is not defined", name);
8459 #else
8460 "name '%.200s' is not defined", PyString_AS_STRING(name));
8461 #endif
8462 }
8463 return result;
8464 }
8465
8466 /* PyIntCompare */
__Pyx_PyInt_NeObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,CYTHON_UNUSED long inplace)8467 static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
8468 if (op1 == op2) {
8469 Py_RETURN_FALSE;
8470 }
8471 #if PY_MAJOR_VERSION < 3
8472 if (likely(PyInt_CheckExact(op1))) {
8473 const long b = intval;
8474 long a = PyInt_AS_LONG(op1);
8475 if (a != b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
8476 }
8477 #endif
8478 #if CYTHON_USE_PYLONG_INTERNALS
8479 if (likely(PyLong_CheckExact(op1))) {
8480 int unequal;
8481 unsigned long uintval;
8482 Py_ssize_t size = Py_SIZE(op1);
8483 const digit* digits = ((PyLongObject*)op1)->ob_digit;
8484 if (intval == 0) {
8485 if (size != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
8486 } else if (intval < 0) {
8487 if (size >= 0)
8488 Py_RETURN_TRUE;
8489 intval = -intval;
8490 size = -size;
8491 } else {
8492 if (size <= 0)
8493 Py_RETURN_TRUE;
8494 }
8495 uintval = (unsigned long) intval;
8496 #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
8497 if (uintval >> (PyLong_SHIFT * 4)) {
8498 unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
8499 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
8500 } else
8501 #endif
8502 #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
8503 if (uintval >> (PyLong_SHIFT * 3)) {
8504 unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
8505 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
8506 } else
8507 #endif
8508 #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
8509 if (uintval >> (PyLong_SHIFT * 2)) {
8510 unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
8511 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
8512 } else
8513 #endif
8514 #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
8515 if (uintval >> (PyLong_SHIFT * 1)) {
8516 unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
8517 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
8518 } else
8519 #endif
8520 unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
8521 if (unequal != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
8522 }
8523 #endif
8524 if (PyFloat_CheckExact(op1)) {
8525 const long b = intval;
8526 double a = PyFloat_AS_DOUBLE(op1);
8527 if ((double)a != (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
8528 }
8529 return (
8530 PyObject_RichCompare(op1, op2, Py_NE));
8531 }
8532
8533 /* ExtTypeTest */
__Pyx_TypeTest(PyObject * obj,PyTypeObject * type)8534 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
8535 if (unlikely(!type)) {
8536 PyErr_SetString(PyExc_SystemError, "Missing type object");
8537 return 0;
8538 }
8539 if (likely(__Pyx_TypeCheck(obj, type)))
8540 return 1;
8541 PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
8542 Py_TYPE(obj)->tp_name, type->tp_name);
8543 return 0;
8544 }
8545
8546 /* PyObjectCall */
8547 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)8548 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
8549 PyObject *result;
8550 ternaryfunc call = func->ob_type->tp_call;
8551 if (unlikely(!call))
8552 return PyObject_Call(func, arg, kw);
8553 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
8554 return NULL;
8555 result = (*call)(func, arg, kw);
8556 Py_LeaveRecursiveCall();
8557 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
8558 PyErr_SetString(
8559 PyExc_SystemError,
8560 "NULL result without error in PyObject_Call");
8561 }
8562 return result;
8563 }
8564 #endif
8565
8566 /* PyErrFetchRestore */
8567 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)8568 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
8569 PyObject *tmp_type, *tmp_value, *tmp_tb;
8570 tmp_type = tstate->curexc_type;
8571 tmp_value = tstate->curexc_value;
8572 tmp_tb = tstate->curexc_traceback;
8573 tstate->curexc_type = type;
8574 tstate->curexc_value = value;
8575 tstate->curexc_traceback = tb;
8576 Py_XDECREF(tmp_type);
8577 Py_XDECREF(tmp_value);
8578 Py_XDECREF(tmp_tb);
8579 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)8580 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
8581 *type = tstate->curexc_type;
8582 *value = tstate->curexc_value;
8583 *tb = tstate->curexc_traceback;
8584 tstate->curexc_type = 0;
8585 tstate->curexc_value = 0;
8586 tstate->curexc_traceback = 0;
8587 }
8588 #endif
8589
8590 /* WriteUnraisableException */
__Pyx_WriteUnraisable(const char * name,CYTHON_UNUSED int clineno,CYTHON_UNUSED int lineno,CYTHON_UNUSED const char * filename,int full_traceback,CYTHON_UNUSED int nogil)8591 static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
8592 CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
8593 int full_traceback, CYTHON_UNUSED int nogil) {
8594 PyObject *old_exc, *old_val, *old_tb;
8595 PyObject *ctx;
8596 __Pyx_PyThreadState_declare
8597 #ifdef WITH_THREAD
8598 PyGILState_STATE state;
8599 if (nogil)
8600 state = PyGILState_Ensure();
8601 #ifdef _MSC_VER
8602 else state = (PyGILState_STATE)-1;
8603 #endif
8604 #endif
8605 __Pyx_PyThreadState_assign
8606 __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
8607 if (full_traceback) {
8608 Py_XINCREF(old_exc);
8609 Py_XINCREF(old_val);
8610 Py_XINCREF(old_tb);
8611 __Pyx_ErrRestore(old_exc, old_val, old_tb);
8612 PyErr_PrintEx(1);
8613 }
8614 #if PY_MAJOR_VERSION < 3
8615 ctx = PyString_FromString(name);
8616 #else
8617 ctx = PyUnicode_FromString(name);
8618 #endif
8619 __Pyx_ErrRestore(old_exc, old_val, old_tb);
8620 if (!ctx) {
8621 PyErr_WriteUnraisable(Py_None);
8622 } else {
8623 PyErr_WriteUnraisable(ctx);
8624 Py_DECREF(ctx);
8625 }
8626 #ifdef WITH_THREAD
8627 if (nogil)
8628 PyGILState_Release(state);
8629 #endif
8630 }
8631
8632 /* DictGetItem */
8633 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
__Pyx_PyDict_GetItem(PyObject * d,PyObject * key)8634 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
8635 PyObject *value;
8636 value = PyDict_GetItemWithError(d, key);
8637 if (unlikely(!value)) {
8638 if (!PyErr_Occurred()) {
8639 if (unlikely(PyTuple_Check(key))) {
8640 PyObject* args = PyTuple_Pack(1, key);
8641 if (likely(args)) {
8642 PyErr_SetObject(PyExc_KeyError, args);
8643 Py_DECREF(args);
8644 }
8645 } else {
8646 PyErr_SetObject(PyExc_KeyError, key);
8647 }
8648 }
8649 return NULL;
8650 }
8651 Py_INCREF(value);
8652 return value;
8653 }
8654 #endif
8655
8656 /* PyFunctionFastCall */
8657 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)8658 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
8659 PyObject *globals) {
8660 PyFrameObject *f;
8661 PyThreadState *tstate = __Pyx_PyThreadState_Current;
8662 PyObject **fastlocals;
8663 Py_ssize_t i;
8664 PyObject *result;
8665 assert(globals != NULL);
8666 /* XXX Perhaps we should create a specialized
8667 PyFrame_New() that doesn't take locals, but does
8668 take builtins without sanity checking them.
8669 */
8670 assert(tstate != NULL);
8671 f = PyFrame_New(tstate, co, globals, NULL);
8672 if (f == NULL) {
8673 return NULL;
8674 }
8675 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
8676 for (i = 0; i < na; i++) {
8677 Py_INCREF(*args);
8678 fastlocals[i] = *args++;
8679 }
8680 result = PyEval_EvalFrameEx(f,0);
8681 ++tstate->recursion_depth;
8682 Py_DECREF(f);
8683 --tstate->recursion_depth;
8684 return result;
8685 }
8686 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)8687 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
8688 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
8689 PyObject *globals = PyFunction_GET_GLOBALS(func);
8690 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
8691 PyObject *closure;
8692 #if PY_MAJOR_VERSION >= 3
8693 PyObject *kwdefs;
8694 #endif
8695 PyObject *kwtuple, **k;
8696 PyObject **d;
8697 Py_ssize_t nd;
8698 Py_ssize_t nk;
8699 PyObject *result;
8700 assert(kwargs == NULL || PyDict_Check(kwargs));
8701 nk = kwargs ? PyDict_Size(kwargs) : 0;
8702 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
8703 return NULL;
8704 }
8705 if (
8706 #if PY_MAJOR_VERSION >= 3
8707 co->co_kwonlyargcount == 0 &&
8708 #endif
8709 likely(kwargs == NULL || nk == 0) &&
8710 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
8711 if (argdefs == NULL && co->co_argcount == nargs) {
8712 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
8713 goto done;
8714 }
8715 else if (nargs == 0 && argdefs != NULL
8716 && co->co_argcount == Py_SIZE(argdefs)) {
8717 /* function called with no arguments, but all parameters have
8718 a default value: use default values as arguments .*/
8719 args = &PyTuple_GET_ITEM(argdefs, 0);
8720 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
8721 goto done;
8722 }
8723 }
8724 if (kwargs != NULL) {
8725 Py_ssize_t pos, i;
8726 kwtuple = PyTuple_New(2 * nk);
8727 if (kwtuple == NULL) {
8728 result = NULL;
8729 goto done;
8730 }
8731 k = &PyTuple_GET_ITEM(kwtuple, 0);
8732 pos = i = 0;
8733 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
8734 Py_INCREF(k[i]);
8735 Py_INCREF(k[i+1]);
8736 i += 2;
8737 }
8738 nk = i / 2;
8739 }
8740 else {
8741 kwtuple = NULL;
8742 k = NULL;
8743 }
8744 closure = PyFunction_GET_CLOSURE(func);
8745 #if PY_MAJOR_VERSION >= 3
8746 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
8747 #endif
8748 if (argdefs != NULL) {
8749 d = &PyTuple_GET_ITEM(argdefs, 0);
8750 nd = Py_SIZE(argdefs);
8751 }
8752 else {
8753 d = NULL;
8754 nd = 0;
8755 }
8756 #if PY_MAJOR_VERSION >= 3
8757 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
8758 args, (int)nargs,
8759 k, (int)nk,
8760 d, (int)nd, kwdefs, closure);
8761 #else
8762 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
8763 args, (int)nargs,
8764 k, (int)nk,
8765 d, (int)nd, closure);
8766 #endif
8767 Py_XDECREF(kwtuple);
8768 done:
8769 Py_LeaveRecursiveCall();
8770 return result;
8771 }
8772 #endif
8773 #endif
8774
8775 /* PyCFunctionFastCall */
8776 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)8777 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
8778 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
8779 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
8780 PyObject *self = PyCFunction_GET_SELF(func);
8781 int flags = PyCFunction_GET_FLAGS(func);
8782 assert(PyCFunction_Check(func));
8783 assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
8784 assert(nargs >= 0);
8785 assert(nargs == 0 || args != NULL);
8786 /* _PyCFunction_FastCallDict() must not be called with an exception set,
8787 because it may clear it (directly or indirectly) and so the
8788 caller loses its exception */
8789 assert(!PyErr_Occurred());
8790 if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
8791 return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
8792 } else {
8793 return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
8794 }
8795 }
8796 #endif
8797
8798 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)8799 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
8800 PyObject *r;
8801 if (!j) return NULL;
8802 r = PyObject_GetItem(o, j);
8803 Py_DECREF(j);
8804 return r;
8805 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)8806 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
8807 CYTHON_NCP_UNUSED int wraparound,
8808 CYTHON_NCP_UNUSED int boundscheck) {
8809 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8810 Py_ssize_t wrapped_i = i;
8811 if (wraparound & unlikely(i < 0)) {
8812 wrapped_i += PyList_GET_SIZE(o);
8813 }
8814 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
8815 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
8816 Py_INCREF(r);
8817 return r;
8818 }
8819 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
8820 #else
8821 return PySequence_GetItem(o, i);
8822 #endif
8823 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)8824 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
8825 CYTHON_NCP_UNUSED int wraparound,
8826 CYTHON_NCP_UNUSED int boundscheck) {
8827 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8828 Py_ssize_t wrapped_i = i;
8829 if (wraparound & unlikely(i < 0)) {
8830 wrapped_i += PyTuple_GET_SIZE(o);
8831 }
8832 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
8833 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
8834 Py_INCREF(r);
8835 return r;
8836 }
8837 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
8838 #else
8839 return PySequence_GetItem(o, i);
8840 #endif
8841 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)8842 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
8843 CYTHON_NCP_UNUSED int wraparound,
8844 CYTHON_NCP_UNUSED int boundscheck) {
8845 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
8846 if (is_list || PyList_CheckExact(o)) {
8847 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
8848 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
8849 PyObject *r = PyList_GET_ITEM(o, n);
8850 Py_INCREF(r);
8851 return r;
8852 }
8853 }
8854 else if (PyTuple_CheckExact(o)) {
8855 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
8856 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
8857 PyObject *r = PyTuple_GET_ITEM(o, n);
8858 Py_INCREF(r);
8859 return r;
8860 }
8861 } else {
8862 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
8863 if (likely(m && m->sq_item)) {
8864 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
8865 Py_ssize_t l = m->sq_length(o);
8866 if (likely(l >= 0)) {
8867 i += l;
8868 } else {
8869 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
8870 return NULL;
8871 PyErr_Clear();
8872 }
8873 }
8874 return m->sq_item(o, i);
8875 }
8876 }
8877 #else
8878 if (is_list || PySequence_Check(o)) {
8879 return PySequence_GetItem(o, i);
8880 }
8881 #endif
8882 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
8883 }
8884
8885 /* ObjectGetItem */
8886 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetIndex(PyObject * obj,PyObject * index)8887 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
8888 PyObject *runerr;
8889 Py_ssize_t key_value;
8890 PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
8891 if (unlikely(!(m && m->sq_item))) {
8892 PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
8893 return NULL;
8894 }
8895 key_value = __Pyx_PyIndex_AsSsize_t(index);
8896 if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
8897 return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
8898 }
8899 if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
8900 PyErr_Clear();
8901 PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
8902 }
8903 return NULL;
8904 }
__Pyx_PyObject_GetItem(PyObject * obj,PyObject * key)8905 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
8906 PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
8907 if (likely(m && m->mp_subscript)) {
8908 return m->mp_subscript(obj, key);
8909 }
8910 return __Pyx_PyObject_GetIndex(obj, key);
8911 }
8912 #endif
8913
8914 /* None */
__Pyx_RaiseUnboundLocalError(const char * varname)8915 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
8916 PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
8917 }
8918
8919 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)8920 static void __Pyx_RaiseArgtupleInvalid(
8921 const char* func_name,
8922 int exact,
8923 Py_ssize_t num_min,
8924 Py_ssize_t num_max,
8925 Py_ssize_t num_found)
8926 {
8927 Py_ssize_t num_expected;
8928 const char *more_or_less;
8929 if (num_found < num_min) {
8930 num_expected = num_min;
8931 more_or_less = "at least";
8932 } else {
8933 num_expected = num_max;
8934 more_or_less = "at most";
8935 }
8936 if (exact) {
8937 more_or_less = "exactly";
8938 }
8939 PyErr_Format(PyExc_TypeError,
8940 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
8941 func_name, more_or_less, num_expected,
8942 (num_expected == 1) ? "" : "s", num_found);
8943 }
8944
8945 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)8946 static void __Pyx_RaiseDoubleKeywordsError(
8947 const char* func_name,
8948 PyObject* kw_name)
8949 {
8950 PyErr_Format(PyExc_TypeError,
8951 #if PY_MAJOR_VERSION >= 3
8952 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
8953 #else
8954 "%s() got multiple values for keyword argument '%s'", func_name,
8955 PyString_AsString(kw_name));
8956 #endif
8957 }
8958
8959 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)8960 static int __Pyx_ParseOptionalKeywords(
8961 PyObject *kwds,
8962 PyObject **argnames[],
8963 PyObject *kwds2,
8964 PyObject *values[],
8965 Py_ssize_t num_pos_args,
8966 const char* function_name)
8967 {
8968 PyObject *key = 0, *value = 0;
8969 Py_ssize_t pos = 0;
8970 PyObject*** name;
8971 PyObject*** first_kw_arg = argnames + num_pos_args;
8972 while (PyDict_Next(kwds, &pos, &key, &value)) {
8973 name = first_kw_arg;
8974 while (*name && (**name != key)) name++;
8975 if (*name) {
8976 values[name-argnames] = value;
8977 continue;
8978 }
8979 name = first_kw_arg;
8980 #if PY_MAJOR_VERSION < 3
8981 if (likely(PyString_Check(key))) {
8982 while (*name) {
8983 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
8984 && _PyString_Eq(**name, key)) {
8985 values[name-argnames] = value;
8986 break;
8987 }
8988 name++;
8989 }
8990 if (*name) continue;
8991 else {
8992 PyObject*** argname = argnames;
8993 while (argname != first_kw_arg) {
8994 if ((**argname == key) || (
8995 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
8996 && _PyString_Eq(**argname, key))) {
8997 goto arg_passed_twice;
8998 }
8999 argname++;
9000 }
9001 }
9002 } else
9003 #endif
9004 if (likely(PyUnicode_Check(key))) {
9005 while (*name) {
9006 int cmp = (**name == key) ? 0 :
9007 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
9008 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
9009 #endif
9010 PyUnicode_Compare(**name, key);
9011 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
9012 if (cmp == 0) {
9013 values[name-argnames] = value;
9014 break;
9015 }
9016 name++;
9017 }
9018 if (*name) continue;
9019 else {
9020 PyObject*** argname = argnames;
9021 while (argname != first_kw_arg) {
9022 int cmp = (**argname == key) ? 0 :
9023 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
9024 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
9025 #endif
9026 PyUnicode_Compare(**argname, key);
9027 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
9028 if (cmp == 0) goto arg_passed_twice;
9029 argname++;
9030 }
9031 }
9032 } else
9033 goto invalid_keyword_type;
9034 if (kwds2) {
9035 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
9036 } else {
9037 goto invalid_keyword;
9038 }
9039 }
9040 return 0;
9041 arg_passed_twice:
9042 __Pyx_RaiseDoubleKeywordsError(function_name, key);
9043 goto bad;
9044 invalid_keyword_type:
9045 PyErr_Format(PyExc_TypeError,
9046 "%.200s() keywords must be strings", function_name);
9047 goto bad;
9048 invalid_keyword:
9049 PyErr_Format(PyExc_TypeError,
9050 #if PY_MAJOR_VERSION < 3
9051 "%.200s() got an unexpected keyword argument '%.200s'",
9052 function_name, PyString_AsString(key));
9053 #else
9054 "%s() got an unexpected keyword argument '%U'",
9055 function_name, key);
9056 #endif
9057 bad:
9058 return -1;
9059 }
9060
9061 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)9062 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
9063 PyErr_Format(PyExc_ValueError,
9064 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
9065 }
9066
9067 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)9068 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
9069 PyErr_Format(PyExc_ValueError,
9070 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
9071 index, (index == 1) ? "" : "s");
9072 }
9073
9074 /* IterFinish */
__Pyx_IterFinish(void)9075 static CYTHON_INLINE int __Pyx_IterFinish(void) {
9076 #if CYTHON_FAST_THREAD_STATE
9077 PyThreadState *tstate = __Pyx_PyThreadState_Current;
9078 PyObject* exc_type = tstate->curexc_type;
9079 if (unlikely(exc_type)) {
9080 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
9081 PyObject *exc_value, *exc_tb;
9082 exc_value = tstate->curexc_value;
9083 exc_tb = tstate->curexc_traceback;
9084 tstate->curexc_type = 0;
9085 tstate->curexc_value = 0;
9086 tstate->curexc_traceback = 0;
9087 Py_DECREF(exc_type);
9088 Py_XDECREF(exc_value);
9089 Py_XDECREF(exc_tb);
9090 return 0;
9091 } else {
9092 return -1;
9093 }
9094 }
9095 return 0;
9096 #else
9097 if (unlikely(PyErr_Occurred())) {
9098 if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
9099 PyErr_Clear();
9100 return 0;
9101 } else {
9102 return -1;
9103 }
9104 }
9105 return 0;
9106 #endif
9107 }
9108
9109 /* UnpackItemEndCheck */
__Pyx_IternextUnpackEndCheck(PyObject * retval,Py_ssize_t expected)9110 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
9111 if (unlikely(retval)) {
9112 Py_DECREF(retval);
9113 __Pyx_RaiseTooManyValuesError(expected);
9114 return -1;
9115 } else {
9116 return __Pyx_IterFinish();
9117 }
9118 return 0;
9119 }
9120
9121 /* PyIntBinop */
9122 #if !CYTHON_COMPILING_IN_PYPY
__Pyx_PyInt_AddObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,int inplace,int zerodivision_check)9123 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
9124 (void)inplace;
9125 (void)zerodivision_check;
9126 #if PY_MAJOR_VERSION < 3
9127 if (likely(PyInt_CheckExact(op1))) {
9128 const long b = intval;
9129 long x;
9130 long a = PyInt_AS_LONG(op1);
9131 x = (long)((unsigned long)a + b);
9132 if (likely((x^a) >= 0 || (x^b) >= 0))
9133 return PyInt_FromLong(x);
9134 return PyLong_Type.tp_as_number->nb_add(op1, op2);
9135 }
9136 #endif
9137 #if CYTHON_USE_PYLONG_INTERNALS
9138 if (likely(PyLong_CheckExact(op1))) {
9139 const long b = intval;
9140 long a, x;
9141 #ifdef HAVE_LONG_LONG
9142 const PY_LONG_LONG llb = intval;
9143 PY_LONG_LONG lla, llx;
9144 #endif
9145 const digit* digits = ((PyLongObject*)op1)->ob_digit;
9146 const Py_ssize_t size = Py_SIZE(op1);
9147 if (likely(__Pyx_sst_abs(size) <= 1)) {
9148 a = likely(size) ? digits[0] : 0;
9149 if (size == -1) a = -a;
9150 } else {
9151 switch (size) {
9152 case -2:
9153 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
9154 a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
9155 break;
9156 #ifdef HAVE_LONG_LONG
9157 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
9158 lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
9159 goto long_long;
9160 #endif
9161 }
9162 CYTHON_FALLTHROUGH;
9163 case 2:
9164 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
9165 a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
9166 break;
9167 #ifdef HAVE_LONG_LONG
9168 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
9169 lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
9170 goto long_long;
9171 #endif
9172 }
9173 CYTHON_FALLTHROUGH;
9174 case -3:
9175 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
9176 a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
9177 break;
9178 #ifdef HAVE_LONG_LONG
9179 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
9180 lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
9181 goto long_long;
9182 #endif
9183 }
9184 CYTHON_FALLTHROUGH;
9185 case 3:
9186 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
9187 a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
9188 break;
9189 #ifdef HAVE_LONG_LONG
9190 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
9191 lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
9192 goto long_long;
9193 #endif
9194 }
9195 CYTHON_FALLTHROUGH;
9196 case -4:
9197 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
9198 a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
9199 break;
9200 #ifdef HAVE_LONG_LONG
9201 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
9202 lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
9203 goto long_long;
9204 #endif
9205 }
9206 CYTHON_FALLTHROUGH;
9207 case 4:
9208 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
9209 a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
9210 break;
9211 #ifdef HAVE_LONG_LONG
9212 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
9213 lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
9214 goto long_long;
9215 #endif
9216 }
9217 CYTHON_FALLTHROUGH;
9218 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
9219 }
9220 }
9221 x = a + b;
9222 return PyLong_FromLong(x);
9223 #ifdef HAVE_LONG_LONG
9224 long_long:
9225 llx = lla + llb;
9226 return PyLong_FromLongLong(llx);
9227 #endif
9228
9229
9230 }
9231 #endif
9232 if (PyFloat_CheckExact(op1)) {
9233 const long b = intval;
9234 double a = PyFloat_AS_DOUBLE(op1);
9235 double result;
9236 PyFPE_START_PROTECT("add", return NULL)
9237 result = ((double)a) + (double)b;
9238 PyFPE_END_PROTECT(result)
9239 return PyFloat_FromDouble(result);
9240 }
9241 return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
9242 }
9243 #endif
9244
9245 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)9246 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
9247 {
9248 if (unlikely(!type)) {
9249 PyErr_SetString(PyExc_SystemError, "Missing type object");
9250 return 0;
9251 }
9252 else if (exact) {
9253 #if PY_MAJOR_VERSION == 2
9254 if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
9255 #endif
9256 }
9257 else {
9258 if (likely(__Pyx_TypeCheck(obj, type))) return 1;
9259 }
9260 PyErr_Format(PyExc_TypeError,
9261 "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
9262 name, type->tp_name, Py_TYPE(obj)->tp_name);
9263 return 0;
9264 }
9265
9266 /* JoinPyUnicode */
__Pyx_PyUnicode_Join(PyObject * value_tuple,Py_ssize_t value_count,Py_ssize_t result_ulength,CYTHON_UNUSED Py_UCS4 max_char)9267 static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
9268 CYTHON_UNUSED Py_UCS4 max_char) {
9269 #if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9270 PyObject *result_uval;
9271 int result_ukind;
9272 Py_ssize_t i, char_pos;
9273 void *result_udata;
9274 #if CYTHON_PEP393_ENABLED
9275 result_uval = PyUnicode_New(result_ulength, max_char);
9276 if (unlikely(!result_uval)) return NULL;
9277 result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
9278 result_udata = PyUnicode_DATA(result_uval);
9279 #else
9280 result_uval = PyUnicode_FromUnicode(NULL, result_ulength);
9281 if (unlikely(!result_uval)) return NULL;
9282 result_ukind = sizeof(Py_UNICODE);
9283 result_udata = PyUnicode_AS_UNICODE(result_uval);
9284 #endif
9285 char_pos = 0;
9286 for (i=0; i < value_count; i++) {
9287 int ukind;
9288 Py_ssize_t ulength;
9289 void *udata;
9290 PyObject *uval = PyTuple_GET_ITEM(value_tuple, i);
9291 if (unlikely(__Pyx_PyUnicode_READY(uval)))
9292 goto bad;
9293 ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
9294 if (unlikely(!ulength))
9295 continue;
9296 if (unlikely(char_pos + ulength < 0))
9297 goto overflow;
9298 ukind = __Pyx_PyUnicode_KIND(uval);
9299 udata = __Pyx_PyUnicode_DATA(uval);
9300 if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
9301 memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
9302 } else {
9303 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
9304 _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
9305 #else
9306 Py_ssize_t j;
9307 for (j=0; j < ulength; j++) {
9308 Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
9309 __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
9310 }
9311 #endif
9312 }
9313 char_pos += ulength;
9314 }
9315 return result_uval;
9316 overflow:
9317 PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
9318 bad:
9319 Py_DECREF(result_uval);
9320 return NULL;
9321 #else
9322 result_ulength++;
9323 value_count++;
9324 return PyUnicode_Join(__pyx_empty_unicode, value_tuple);
9325 #endif
9326 }
9327
9328 /* PyUnicode_Substring */
__Pyx_PyUnicode_Substring(PyObject * text,Py_ssize_t start,Py_ssize_t stop)9329 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
9330 PyObject* text, Py_ssize_t start, Py_ssize_t stop) {
9331 Py_ssize_t length;
9332 if (unlikely(__Pyx_PyUnicode_READY(text) == -1)) return NULL;
9333 length = __Pyx_PyUnicode_GET_LENGTH(text);
9334 if (start < 0) {
9335 start += length;
9336 if (start < 0)
9337 start = 0;
9338 }
9339 if (stop < 0)
9340 stop += length;
9341 else if (stop > length)
9342 stop = length;
9343 if (stop <= start)
9344 return __Pyx_NewRef(__pyx_empty_unicode);
9345 #if CYTHON_PEP393_ENABLED
9346 return PyUnicode_FromKindAndData(PyUnicode_KIND(text),
9347 PyUnicode_1BYTE_DATA(text) + start*PyUnicode_KIND(text), stop-start);
9348 #else
9349 return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(text)+start, stop-start);
9350 #endif
9351 }
9352
9353 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)9354 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
9355 PyObject *args, *result = NULL;
9356 #if CYTHON_FAST_PYCALL
9357 if (PyFunction_Check(function)) {
9358 PyObject *args[2] = {arg1, arg2};
9359 return __Pyx_PyFunction_FastCall(function, args, 2);
9360 }
9361 #endif
9362 #if CYTHON_FAST_PYCCALL
9363 if (__Pyx_PyFastCFunction_Check(function)) {
9364 PyObject *args[2] = {arg1, arg2};
9365 return __Pyx_PyCFunction_FastCall(function, args, 2);
9366 }
9367 #endif
9368 args = PyTuple_New(2);
9369 if (unlikely(!args)) goto done;
9370 Py_INCREF(arg1);
9371 PyTuple_SET_ITEM(args, 0, arg1);
9372 Py_INCREF(arg2);
9373 PyTuple_SET_ITEM(args, 1, arg2);
9374 Py_INCREF(function);
9375 result = __Pyx_PyObject_Call(function, args, NULL);
9376 Py_DECREF(args);
9377 Py_DECREF(function);
9378 done:
9379 return result;
9380 }
9381
9382 /* PyObjectCallMethO */
9383 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)9384 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
9385 PyObject *self, *result;
9386 PyCFunction cfunc;
9387 cfunc = PyCFunction_GET_FUNCTION(func);
9388 self = PyCFunction_GET_SELF(func);
9389 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
9390 return NULL;
9391 result = cfunc(self, arg);
9392 Py_LeaveRecursiveCall();
9393 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
9394 PyErr_SetString(
9395 PyExc_SystemError,
9396 "NULL result without error in PyObject_Call");
9397 }
9398 return result;
9399 }
9400 #endif
9401
9402 /* PyObjectCallOneArg */
9403 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)9404 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
9405 PyObject *result;
9406 PyObject *args = PyTuple_New(1);
9407 if (unlikely(!args)) return NULL;
9408 Py_INCREF(arg);
9409 PyTuple_SET_ITEM(args, 0, arg);
9410 result = __Pyx_PyObject_Call(func, args, NULL);
9411 Py_DECREF(args);
9412 return result;
9413 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)9414 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
9415 #if CYTHON_FAST_PYCALL
9416 if (PyFunction_Check(func)) {
9417 return __Pyx_PyFunction_FastCall(func, &arg, 1);
9418 }
9419 #endif
9420 if (likely(PyCFunction_Check(func))) {
9421 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
9422 return __Pyx_PyObject_CallMethO(func, arg);
9423 #if CYTHON_FAST_PYCCALL
9424 } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
9425 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
9426 #endif
9427 }
9428 }
9429 return __Pyx__PyObject_CallOneArg(func, arg);
9430 }
9431 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)9432 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
9433 PyObject *result;
9434 PyObject *args = PyTuple_Pack(1, arg);
9435 if (unlikely(!args)) return NULL;
9436 result = __Pyx_PyObject_Call(func, args, NULL);
9437 Py_DECREF(args);
9438 return result;
9439 }
9440 #endif
9441
9442 /* GetTopmostException */
9443 #if CYTHON_USE_EXC_INFO_STACK
9444 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)9445 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
9446 {
9447 _PyErr_StackItem *exc_info = tstate->exc_info;
9448 while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
9449 exc_info->previous_item != NULL)
9450 {
9451 exc_info = exc_info->previous_item;
9452 }
9453 return exc_info;
9454 }
9455 #endif
9456
9457 /* SaveResetException */
9458 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)9459 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
9460 #if CYTHON_USE_EXC_INFO_STACK
9461 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
9462 *type = exc_info->exc_type;
9463 *value = exc_info->exc_value;
9464 *tb = exc_info->exc_traceback;
9465 #else
9466 *type = tstate->exc_type;
9467 *value = tstate->exc_value;
9468 *tb = tstate->exc_traceback;
9469 #endif
9470 Py_XINCREF(*type);
9471 Py_XINCREF(*value);
9472 Py_XINCREF(*tb);
9473 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)9474 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
9475 PyObject *tmp_type, *tmp_value, *tmp_tb;
9476 #if CYTHON_USE_EXC_INFO_STACK
9477 _PyErr_StackItem *exc_info = tstate->exc_info;
9478 tmp_type = exc_info->exc_type;
9479 tmp_value = exc_info->exc_value;
9480 tmp_tb = exc_info->exc_traceback;
9481 exc_info->exc_type = type;
9482 exc_info->exc_value = value;
9483 exc_info->exc_traceback = tb;
9484 #else
9485 tmp_type = tstate->exc_type;
9486 tmp_value = tstate->exc_value;
9487 tmp_tb = tstate->exc_traceback;
9488 tstate->exc_type = type;
9489 tstate->exc_value = value;
9490 tstate->exc_traceback = tb;
9491 #endif
9492 Py_XDECREF(tmp_type);
9493 Py_XDECREF(tmp_value);
9494 Py_XDECREF(tmp_tb);
9495 }
9496 #endif
9497
9498 /* PyErrExceptionMatches */
9499 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)9500 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
9501 Py_ssize_t i, n;
9502 n = PyTuple_GET_SIZE(tuple);
9503 #if PY_MAJOR_VERSION >= 3
9504 for (i=0; i<n; i++) {
9505 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
9506 }
9507 #endif
9508 for (i=0; i<n; i++) {
9509 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
9510 }
9511 return 0;
9512 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)9513 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
9514 PyObject *exc_type = tstate->curexc_type;
9515 if (exc_type == err) return 1;
9516 if (unlikely(!exc_type)) return 0;
9517 if (unlikely(PyTuple_Check(err)))
9518 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
9519 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
9520 }
9521 #endif
9522
9523 /* GetException */
9524 #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)9525 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
9526 #else
9527 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
9528 #endif
9529 {
9530 PyObject *local_type, *local_value, *local_tb;
9531 #if CYTHON_FAST_THREAD_STATE
9532 PyObject *tmp_type, *tmp_value, *tmp_tb;
9533 local_type = tstate->curexc_type;
9534 local_value = tstate->curexc_value;
9535 local_tb = tstate->curexc_traceback;
9536 tstate->curexc_type = 0;
9537 tstate->curexc_value = 0;
9538 tstate->curexc_traceback = 0;
9539 #else
9540 PyErr_Fetch(&local_type, &local_value, &local_tb);
9541 #endif
9542 PyErr_NormalizeException(&local_type, &local_value, &local_tb);
9543 #if CYTHON_FAST_THREAD_STATE
9544 if (unlikely(tstate->curexc_type))
9545 #else
9546 if (unlikely(PyErr_Occurred()))
9547 #endif
9548 goto bad;
9549 #if PY_MAJOR_VERSION >= 3
9550 if (local_tb) {
9551 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
9552 goto bad;
9553 }
9554 #endif
9555 Py_XINCREF(local_tb);
9556 Py_XINCREF(local_type);
9557 Py_XINCREF(local_value);
9558 *type = local_type;
9559 *value = local_value;
9560 *tb = local_tb;
9561 #if CYTHON_FAST_THREAD_STATE
9562 #if CYTHON_USE_EXC_INFO_STACK
9563 {
9564 _PyErr_StackItem *exc_info = tstate->exc_info;
9565 tmp_type = exc_info->exc_type;
9566 tmp_value = exc_info->exc_value;
9567 tmp_tb = exc_info->exc_traceback;
9568 exc_info->exc_type = local_type;
9569 exc_info->exc_value = local_value;
9570 exc_info->exc_traceback = local_tb;
9571 }
9572 #else
9573 tmp_type = tstate->exc_type;
9574 tmp_value = tstate->exc_value;
9575 tmp_tb = tstate->exc_traceback;
9576 tstate->exc_type = local_type;
9577 tstate->exc_value = local_value;
9578 tstate->exc_traceback = local_tb;
9579 #endif
9580 Py_XDECREF(tmp_type);
9581 Py_XDECREF(tmp_value);
9582 Py_XDECREF(tmp_tb);
9583 #else
9584 PyErr_SetExcInfo(local_type, local_value, local_tb);
9585 #endif
9586 return 0;
9587 bad:
9588 *type = 0;
9589 *value = 0;
9590 *tb = 0;
9591 Py_XDECREF(local_type);
9592 Py_XDECREF(local_value);
9593 Py_XDECREF(local_tb);
9594 return -1;
9595 }
9596
9597 /* RaiseException */
9598 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)9599 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
9600 CYTHON_UNUSED PyObject *cause) {
9601 __Pyx_PyThreadState_declare
9602 Py_XINCREF(type);
9603 if (!value || value == Py_None)
9604 value = NULL;
9605 else
9606 Py_INCREF(value);
9607 if (!tb || tb == Py_None)
9608 tb = NULL;
9609 else {
9610 Py_INCREF(tb);
9611 if (!PyTraceBack_Check(tb)) {
9612 PyErr_SetString(PyExc_TypeError,
9613 "raise: arg 3 must be a traceback or None");
9614 goto raise_error;
9615 }
9616 }
9617 if (PyType_Check(type)) {
9618 #if CYTHON_COMPILING_IN_PYPY
9619 if (!value) {
9620 Py_INCREF(Py_None);
9621 value = Py_None;
9622 }
9623 #endif
9624 PyErr_NormalizeException(&type, &value, &tb);
9625 } else {
9626 if (value) {
9627 PyErr_SetString(PyExc_TypeError,
9628 "instance exception may not have a separate value");
9629 goto raise_error;
9630 }
9631 value = type;
9632 type = (PyObject*) Py_TYPE(type);
9633 Py_INCREF(type);
9634 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
9635 PyErr_SetString(PyExc_TypeError,
9636 "raise: exception class must be a subclass of BaseException");
9637 goto raise_error;
9638 }
9639 }
9640 __Pyx_PyThreadState_assign
9641 __Pyx_ErrRestore(type, value, tb);
9642 return;
9643 raise_error:
9644 Py_XDECREF(value);
9645 Py_XDECREF(type);
9646 Py_XDECREF(tb);
9647 return;
9648 }
9649 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)9650 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
9651 PyObject* owned_instance = NULL;
9652 if (tb == Py_None) {
9653 tb = 0;
9654 } else if (tb && !PyTraceBack_Check(tb)) {
9655 PyErr_SetString(PyExc_TypeError,
9656 "raise: arg 3 must be a traceback or None");
9657 goto bad;
9658 }
9659 if (value == Py_None)
9660 value = 0;
9661 if (PyExceptionInstance_Check(type)) {
9662 if (value) {
9663 PyErr_SetString(PyExc_TypeError,
9664 "instance exception may not have a separate value");
9665 goto bad;
9666 }
9667 value = type;
9668 type = (PyObject*) Py_TYPE(value);
9669 } else if (PyExceptionClass_Check(type)) {
9670 PyObject *instance_class = NULL;
9671 if (value && PyExceptionInstance_Check(value)) {
9672 instance_class = (PyObject*) Py_TYPE(value);
9673 if (instance_class != type) {
9674 int is_subclass = PyObject_IsSubclass(instance_class, type);
9675 if (!is_subclass) {
9676 instance_class = NULL;
9677 } else if (unlikely(is_subclass == -1)) {
9678 goto bad;
9679 } else {
9680 type = instance_class;
9681 }
9682 }
9683 }
9684 if (!instance_class) {
9685 PyObject *args;
9686 if (!value)
9687 args = PyTuple_New(0);
9688 else if (PyTuple_Check(value)) {
9689 Py_INCREF(value);
9690 args = value;
9691 } else
9692 args = PyTuple_Pack(1, value);
9693 if (!args)
9694 goto bad;
9695 owned_instance = PyObject_Call(type, args, NULL);
9696 Py_DECREF(args);
9697 if (!owned_instance)
9698 goto bad;
9699 value = owned_instance;
9700 if (!PyExceptionInstance_Check(value)) {
9701 PyErr_Format(PyExc_TypeError,
9702 "calling %R should have returned an instance of "
9703 "BaseException, not %R",
9704 type, Py_TYPE(value));
9705 goto bad;
9706 }
9707 }
9708 } else {
9709 PyErr_SetString(PyExc_TypeError,
9710 "raise: exception class must be a subclass of BaseException");
9711 goto bad;
9712 }
9713 if (cause) {
9714 PyObject *fixed_cause;
9715 if (cause == Py_None) {
9716 fixed_cause = NULL;
9717 } else if (PyExceptionClass_Check(cause)) {
9718 fixed_cause = PyObject_CallObject(cause, NULL);
9719 if (fixed_cause == NULL)
9720 goto bad;
9721 } else if (PyExceptionInstance_Check(cause)) {
9722 fixed_cause = cause;
9723 Py_INCREF(fixed_cause);
9724 } else {
9725 PyErr_SetString(PyExc_TypeError,
9726 "exception causes must derive from "
9727 "BaseException");
9728 goto bad;
9729 }
9730 PyException_SetCause(value, fixed_cause);
9731 }
9732 PyErr_SetObject(type, value);
9733 if (tb) {
9734 #if CYTHON_COMPILING_IN_PYPY
9735 PyObject *tmp_type, *tmp_value, *tmp_tb;
9736 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
9737 Py_INCREF(tb);
9738 PyErr_Restore(tmp_type, tmp_value, tb);
9739 Py_XDECREF(tmp_tb);
9740 #else
9741 PyThreadState *tstate = __Pyx_PyThreadState_Current;
9742 PyObject* tmp_tb = tstate->curexc_traceback;
9743 if (tb != tmp_tb) {
9744 Py_INCREF(tb);
9745 tstate->curexc_traceback = tb;
9746 Py_XDECREF(tmp_tb);
9747 }
9748 #endif
9749 }
9750 bad:
9751 Py_XDECREF(owned_instance);
9752 return;
9753 }
9754 #endif
9755
9756 /* TypeImport */
9757 #ifndef __PYX_HAVE_RT_ImportType
9758 #define __PYX_HAVE_RT_ImportType
__Pyx_ImportType(PyObject * module,const char * module_name,const char * class_name,size_t size,enum __Pyx_ImportType_CheckSize check_size)9759 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
9760 size_t size, enum __Pyx_ImportType_CheckSize check_size)
9761 {
9762 PyObject *result = 0;
9763 char warning[200];
9764 Py_ssize_t basicsize;
9765 #ifdef Py_LIMITED_API
9766 PyObject *py_basicsize;
9767 #endif
9768 result = PyObject_GetAttrString(module, class_name);
9769 if (!result)
9770 goto bad;
9771 if (!PyType_Check(result)) {
9772 PyErr_Format(PyExc_TypeError,
9773 "%.200s.%.200s is not a type object",
9774 module_name, class_name);
9775 goto bad;
9776 }
9777 #ifndef Py_LIMITED_API
9778 basicsize = ((PyTypeObject *)result)->tp_basicsize;
9779 #else
9780 py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
9781 if (!py_basicsize)
9782 goto bad;
9783 basicsize = PyLong_AsSsize_t(py_basicsize);
9784 Py_DECREF(py_basicsize);
9785 py_basicsize = 0;
9786 if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
9787 goto bad;
9788 #endif
9789 if ((size_t)basicsize < size) {
9790 PyErr_Format(PyExc_ValueError,
9791 "%.200s.%.200s size changed, may indicate binary incompatibility. "
9792 "Expected %zd from C header, got %zd from PyObject",
9793 module_name, class_name, size, basicsize);
9794 goto bad;
9795 }
9796 if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
9797 PyErr_Format(PyExc_ValueError,
9798 "%.200s.%.200s size changed, may indicate binary incompatibility. "
9799 "Expected %zd from C header, got %zd from PyObject",
9800 module_name, class_name, size, basicsize);
9801 goto bad;
9802 }
9803 else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
9804 PyOS_snprintf(warning, sizeof(warning),
9805 "%s.%s size changed, may indicate binary incompatibility. "
9806 "Expected %zd from C header, got %zd from PyObject",
9807 module_name, class_name, size, basicsize);
9808 if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
9809 }
9810 return (PyTypeObject *)result;
9811 bad:
9812 Py_XDECREF(result);
9813 return NULL;
9814 }
9815 #endif
9816
9817 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)9818 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
9819 PyObject *empty_list = 0;
9820 PyObject *module = 0;
9821 PyObject *global_dict = 0;
9822 PyObject *empty_dict = 0;
9823 PyObject *list;
9824 #if PY_MAJOR_VERSION < 3
9825 PyObject *py_import;
9826 py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
9827 if (!py_import)
9828 goto bad;
9829 #endif
9830 if (from_list)
9831 list = from_list;
9832 else {
9833 empty_list = PyList_New(0);
9834 if (!empty_list)
9835 goto bad;
9836 list = empty_list;
9837 }
9838 global_dict = PyModule_GetDict(__pyx_m);
9839 if (!global_dict)
9840 goto bad;
9841 empty_dict = PyDict_New();
9842 if (!empty_dict)
9843 goto bad;
9844 {
9845 #if PY_MAJOR_VERSION >= 3
9846 if (level == -1) {
9847 if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
9848 module = PyImport_ImportModuleLevelObject(
9849 name, global_dict, empty_dict, list, 1);
9850 if (!module) {
9851 if (!PyErr_ExceptionMatches(PyExc_ImportError))
9852 goto bad;
9853 PyErr_Clear();
9854 }
9855 }
9856 level = 0;
9857 }
9858 #endif
9859 if (!module) {
9860 #if PY_MAJOR_VERSION < 3
9861 PyObject *py_level = PyInt_FromLong(level);
9862 if (!py_level)
9863 goto bad;
9864 module = PyObject_CallFunctionObjArgs(py_import,
9865 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
9866 Py_DECREF(py_level);
9867 #else
9868 module = PyImport_ImportModuleLevelObject(
9869 name, global_dict, empty_dict, list, level);
9870 #endif
9871 }
9872 }
9873 bad:
9874 #if PY_MAJOR_VERSION < 3
9875 Py_XDECREF(py_import);
9876 #endif
9877 Py_XDECREF(empty_list);
9878 Py_XDECREF(empty_dict);
9879 return module;
9880 }
9881
9882 /* PyDictVersioning */
9883 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)9884 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
9885 PyObject *dict = Py_TYPE(obj)->tp_dict;
9886 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
9887 }
__Pyx_get_object_dict_version(PyObject * obj)9888 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
9889 PyObject **dictptr = NULL;
9890 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
9891 if (offset) {
9892 #if CYTHON_COMPILING_IN_CPYTHON
9893 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
9894 #else
9895 dictptr = _PyObject_GetDictPtr(obj);
9896 #endif
9897 }
9898 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
9899 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)9900 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
9901 PyObject *dict = Py_TYPE(obj)->tp_dict;
9902 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
9903 return 0;
9904 return obj_dict_version == __Pyx_get_object_dict_version(obj);
9905 }
9906 #endif
9907
9908 /* GetModuleGlobalName */
9909 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)9910 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
9911 #else
9912 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
9913 #endif
9914 {
9915 PyObject *result;
9916 #if !CYTHON_AVOID_BORROWED_REFS
9917 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
9918 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
9919 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
9920 if (likely(result)) {
9921 return __Pyx_NewRef(result);
9922 } else if (unlikely(PyErr_Occurred())) {
9923 return NULL;
9924 }
9925 #else
9926 result = PyDict_GetItem(__pyx_d, name);
9927 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
9928 if (likely(result)) {
9929 return __Pyx_NewRef(result);
9930 }
9931 #endif
9932 #else
9933 result = PyObject_GetItem(__pyx_d, name);
9934 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
9935 if (likely(result)) {
9936 return __Pyx_NewRef(result);
9937 }
9938 PyErr_Clear();
9939 #endif
9940 return __Pyx_GetBuiltinName(name);
9941 }
9942
9943 /* PyObjectCallNoArg */
9944 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)9945 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
9946 #if CYTHON_FAST_PYCALL
9947 if (PyFunction_Check(func)) {
9948 return __Pyx_PyFunction_FastCall(func, NULL, 0);
9949 }
9950 #endif
9951 #ifdef __Pyx_CyFunction_USED
9952 if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
9953 #else
9954 if (likely(PyCFunction_Check(func)))
9955 #endif
9956 {
9957 if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
9958 return __Pyx_PyObject_CallMethO(func, NULL);
9959 }
9960 }
9961 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
9962 }
9963 #endif
9964
9965 /* CLineInTraceback */
9966 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)9967 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
9968 PyObject *use_cline;
9969 PyObject *ptype, *pvalue, *ptraceback;
9970 #if CYTHON_COMPILING_IN_CPYTHON
9971 PyObject **cython_runtime_dict;
9972 #endif
9973 if (unlikely(!__pyx_cython_runtime)) {
9974 return c_line;
9975 }
9976 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
9977 #if CYTHON_COMPILING_IN_CPYTHON
9978 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
9979 if (likely(cython_runtime_dict)) {
9980 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
9981 use_cline, *cython_runtime_dict,
9982 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
9983 } else
9984 #endif
9985 {
9986 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
9987 if (use_cline_obj) {
9988 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
9989 Py_DECREF(use_cline_obj);
9990 } else {
9991 PyErr_Clear();
9992 use_cline = NULL;
9993 }
9994 }
9995 if (!use_cline) {
9996 c_line = 0;
9997 PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
9998 }
9999 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
10000 c_line = 0;
10001 }
10002 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
10003 return c_line;
10004 }
10005 #endif
10006
10007 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)10008 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
10009 int start = 0, mid = 0, end = count - 1;
10010 if (end >= 0 && code_line > entries[end].code_line) {
10011 return count;
10012 }
10013 while (start < end) {
10014 mid = start + (end - start) / 2;
10015 if (code_line < entries[mid].code_line) {
10016 end = mid;
10017 } else if (code_line > entries[mid].code_line) {
10018 start = mid + 1;
10019 } else {
10020 return mid;
10021 }
10022 }
10023 if (code_line <= entries[mid].code_line) {
10024 return mid;
10025 } else {
10026 return mid + 1;
10027 }
10028 }
__pyx_find_code_object(int code_line)10029 static PyCodeObject *__pyx_find_code_object(int code_line) {
10030 PyCodeObject* code_object;
10031 int pos;
10032 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
10033 return NULL;
10034 }
10035 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
10036 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
10037 return NULL;
10038 }
10039 code_object = __pyx_code_cache.entries[pos].code_object;
10040 Py_INCREF(code_object);
10041 return code_object;
10042 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)10043 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
10044 int pos, i;
10045 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
10046 if (unlikely(!code_line)) {
10047 return;
10048 }
10049 if (unlikely(!entries)) {
10050 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
10051 if (likely(entries)) {
10052 __pyx_code_cache.entries = entries;
10053 __pyx_code_cache.max_count = 64;
10054 __pyx_code_cache.count = 1;
10055 entries[0].code_line = code_line;
10056 entries[0].code_object = code_object;
10057 Py_INCREF(code_object);
10058 }
10059 return;
10060 }
10061 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
10062 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
10063 PyCodeObject* tmp = entries[pos].code_object;
10064 entries[pos].code_object = code_object;
10065 Py_DECREF(tmp);
10066 return;
10067 }
10068 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
10069 int new_max = __pyx_code_cache.max_count + 64;
10070 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
10071 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
10072 if (unlikely(!entries)) {
10073 return;
10074 }
10075 __pyx_code_cache.entries = entries;
10076 __pyx_code_cache.max_count = new_max;
10077 }
10078 for (i=__pyx_code_cache.count; i>pos; i--) {
10079 entries[i] = entries[i-1];
10080 }
10081 entries[pos].code_line = code_line;
10082 entries[pos].code_object = code_object;
10083 __pyx_code_cache.count++;
10084 Py_INCREF(code_object);
10085 }
10086
10087 /* AddTraceback */
10088 #include "compile.h"
10089 #include "frameobject.h"
10090 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)10091 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
10092 const char *funcname, int c_line,
10093 int py_line, const char *filename) {
10094 PyCodeObject *py_code = 0;
10095 PyObject *py_srcfile = 0;
10096 PyObject *py_funcname = 0;
10097 #if PY_MAJOR_VERSION < 3
10098 py_srcfile = PyString_FromString(filename);
10099 #else
10100 py_srcfile = PyUnicode_FromString(filename);
10101 #endif
10102 if (!py_srcfile) goto bad;
10103 if (c_line) {
10104 #if PY_MAJOR_VERSION < 3
10105 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
10106 #else
10107 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
10108 #endif
10109 }
10110 else {
10111 #if PY_MAJOR_VERSION < 3
10112 py_funcname = PyString_FromString(funcname);
10113 #else
10114 py_funcname = PyUnicode_FromString(funcname);
10115 #endif
10116 }
10117 if (!py_funcname) goto bad;
10118 py_code = __Pyx_PyCode_New(
10119 0,
10120 0,
10121 0,
10122 0,
10123 0,
10124 __pyx_empty_bytes, /*PyObject *code,*/
10125 __pyx_empty_tuple, /*PyObject *consts,*/
10126 __pyx_empty_tuple, /*PyObject *names,*/
10127 __pyx_empty_tuple, /*PyObject *varnames,*/
10128 __pyx_empty_tuple, /*PyObject *freevars,*/
10129 __pyx_empty_tuple, /*PyObject *cellvars,*/
10130 py_srcfile, /*PyObject *filename,*/
10131 py_funcname, /*PyObject *name,*/
10132 py_line,
10133 __pyx_empty_bytes /*PyObject *lnotab*/
10134 );
10135 Py_DECREF(py_srcfile);
10136 Py_DECREF(py_funcname);
10137 return py_code;
10138 bad:
10139 Py_XDECREF(py_srcfile);
10140 Py_XDECREF(py_funcname);
10141 return NULL;
10142 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)10143 static void __Pyx_AddTraceback(const char *funcname, int c_line,
10144 int py_line, const char *filename) {
10145 PyCodeObject *py_code = 0;
10146 PyFrameObject *py_frame = 0;
10147 PyThreadState *tstate = __Pyx_PyThreadState_Current;
10148 if (c_line) {
10149 c_line = __Pyx_CLineForTraceback(tstate, c_line);
10150 }
10151 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
10152 if (!py_code) {
10153 py_code = __Pyx_CreateCodeObjectForTraceback(
10154 funcname, c_line, py_line, filename);
10155 if (!py_code) goto bad;
10156 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
10157 }
10158 py_frame = PyFrame_New(
10159 tstate, /*PyThreadState *tstate,*/
10160 py_code, /*PyCodeObject *code,*/
10161 __pyx_d, /*PyObject *globals,*/
10162 0 /*PyObject *locals*/
10163 );
10164 if (!py_frame) goto bad;
10165 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
10166 PyTraceBack_Here(py_frame);
10167 bad:
10168 Py_XDECREF(py_code);
10169 Py_XDECREF(py_frame);
10170 }
10171
10172 /* CIntFromPyVerify */
10173 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
10174 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
10175 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
10176 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
10177 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
10178 {\
10179 func_type value = func_value;\
10180 if (sizeof(target_type) < sizeof(func_type)) {\
10181 if (unlikely(value != (func_type) (target_type) value)) {\
10182 func_type zero = 0;\
10183 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
10184 return (target_type) -1;\
10185 if (is_unsigned && unlikely(value < zero))\
10186 goto raise_neg_overflow;\
10187 else\
10188 goto raise_overflow;\
10189 }\
10190 }\
10191 return (target_type) value;\
10192 }
10193
10194 /* CIntToPy */
__Pyx_PyInt_From_npy_uint32(npy_uint32 value)10195 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_uint32(npy_uint32 value) {
10196 const npy_uint32 neg_one = (npy_uint32) ((npy_uint32) 0 - (npy_uint32) 1), const_zero = (npy_uint32) 0;
10197 const int is_unsigned = neg_one > const_zero;
10198 if (is_unsigned) {
10199 if (sizeof(npy_uint32) < sizeof(long)) {
10200 return PyInt_FromLong((long) value);
10201 } else if (sizeof(npy_uint32) <= sizeof(unsigned long)) {
10202 return PyLong_FromUnsignedLong((unsigned long) value);
10203 #ifdef HAVE_LONG_LONG
10204 } else if (sizeof(npy_uint32) <= sizeof(unsigned PY_LONG_LONG)) {
10205 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
10206 #endif
10207 }
10208 } else {
10209 if (sizeof(npy_uint32) <= sizeof(long)) {
10210 return PyInt_FromLong((long) value);
10211 #ifdef HAVE_LONG_LONG
10212 } else if (sizeof(npy_uint32) <= sizeof(PY_LONG_LONG)) {
10213 return PyLong_FromLongLong((PY_LONG_LONG) value);
10214 #endif
10215 }
10216 }
10217 {
10218 int one = 1; int little = (int)*(unsigned char *)&one;
10219 unsigned char *bytes = (unsigned char *)&value;
10220 return _PyLong_FromByteArray(bytes, sizeof(npy_uint32),
10221 little, !is_unsigned);
10222 }
10223 }
10224
10225 /* CIntToPy */
__Pyx_PyInt_From_long(long value)10226 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
10227 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
10228 const int is_unsigned = neg_one > const_zero;
10229 if (is_unsigned) {
10230 if (sizeof(long) < sizeof(long)) {
10231 return PyInt_FromLong((long) value);
10232 } else if (sizeof(long) <= sizeof(unsigned long)) {
10233 return PyLong_FromUnsignedLong((unsigned long) value);
10234 #ifdef HAVE_LONG_LONG
10235 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
10236 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
10237 #endif
10238 }
10239 } else {
10240 if (sizeof(long) <= sizeof(long)) {
10241 return PyInt_FromLong((long) value);
10242 #ifdef HAVE_LONG_LONG
10243 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
10244 return PyLong_FromLongLong((PY_LONG_LONG) value);
10245 #endif
10246 }
10247 }
10248 {
10249 int one = 1; int little = (int)*(unsigned char *)&one;
10250 unsigned char *bytes = (unsigned char *)&value;
10251 return _PyLong_FromByteArray(bytes, sizeof(long),
10252 little, !is_unsigned);
10253 }
10254 }
10255
10256 /* CIntToPy */
__Pyx_PyInt_From_int(int value)10257 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
10258 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
10259 const int is_unsigned = neg_one > const_zero;
10260 if (is_unsigned) {
10261 if (sizeof(int) < sizeof(long)) {
10262 return PyInt_FromLong((long) value);
10263 } else if (sizeof(int) <= sizeof(unsigned long)) {
10264 return PyLong_FromUnsignedLong((unsigned long) value);
10265 #ifdef HAVE_LONG_LONG
10266 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
10267 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
10268 #endif
10269 }
10270 } else {
10271 if (sizeof(int) <= sizeof(long)) {
10272 return PyInt_FromLong((long) value);
10273 #ifdef HAVE_LONG_LONG
10274 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
10275 return PyLong_FromLongLong((PY_LONG_LONG) value);
10276 #endif
10277 }
10278 }
10279 {
10280 int one = 1; int little = (int)*(unsigned char *)&one;
10281 unsigned char *bytes = (unsigned char *)&value;
10282 return _PyLong_FromByteArray(bytes, sizeof(int),
10283 little, !is_unsigned);
10284 }
10285 }
10286
10287 /* CIntToPy */
__Pyx_PyInt_From_unsigned_int(unsigned int value)10288 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
10289 const unsigned int neg_one = (unsigned int) ((unsigned int) 0 - (unsigned int) 1), const_zero = (unsigned int) 0;
10290 const int is_unsigned = neg_one > const_zero;
10291 if (is_unsigned) {
10292 if (sizeof(unsigned int) < sizeof(long)) {
10293 return PyInt_FromLong((long) value);
10294 } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
10295 return PyLong_FromUnsignedLong((unsigned long) value);
10296 #ifdef HAVE_LONG_LONG
10297 } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
10298 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
10299 #endif
10300 }
10301 } else {
10302 if (sizeof(unsigned int) <= sizeof(long)) {
10303 return PyInt_FromLong((long) value);
10304 #ifdef HAVE_LONG_LONG
10305 } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
10306 return PyLong_FromLongLong((PY_LONG_LONG) value);
10307 #endif
10308 }
10309 }
10310 {
10311 int one = 1; int little = (int)*(unsigned char *)&one;
10312 unsigned char *bytes = (unsigned char *)&value;
10313 return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
10314 little, !is_unsigned);
10315 }
10316 }
10317
10318 /* Declarations */
10319 #if CYTHON_CCOMPLEX
10320 #ifdef __cplusplus
__pyx_t_float_complex_from_parts(float x,float y)10321 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
10322 return ::std::complex< float >(x, y);
10323 }
10324 #else
__pyx_t_float_complex_from_parts(float x,float y)10325 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
10326 return x + y*(__pyx_t_float_complex)_Complex_I;
10327 }
10328 #endif
10329 #else
__pyx_t_float_complex_from_parts(float x,float y)10330 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
10331 __pyx_t_float_complex z;
10332 z.real = x;
10333 z.imag = y;
10334 return z;
10335 }
10336 #endif
10337
10338 /* Arithmetic */
10339 #if CYTHON_CCOMPLEX
10340 #else
__Pyx_c_eq_float(__pyx_t_float_complex a,__pyx_t_float_complex b)10341 static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
10342 return (a.real == b.real) && (a.imag == b.imag);
10343 }
__Pyx_c_sum_float(__pyx_t_float_complex a,__pyx_t_float_complex b)10344 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
10345 __pyx_t_float_complex z;
10346 z.real = a.real + b.real;
10347 z.imag = a.imag + b.imag;
10348 return z;
10349 }
__Pyx_c_diff_float(__pyx_t_float_complex a,__pyx_t_float_complex b)10350 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
10351 __pyx_t_float_complex z;
10352 z.real = a.real - b.real;
10353 z.imag = a.imag - b.imag;
10354 return z;
10355 }
__Pyx_c_prod_float(__pyx_t_float_complex a,__pyx_t_float_complex b)10356 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
10357 __pyx_t_float_complex z;
10358 z.real = a.real * b.real - a.imag * b.imag;
10359 z.imag = a.real * b.imag + a.imag * b.real;
10360 return z;
10361 }
10362 #if 1
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)10363 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
10364 if (b.imag == 0) {
10365 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
10366 } else if (fabsf(b.real) >= fabsf(b.imag)) {
10367 if (b.real == 0 && b.imag == 0) {
10368 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
10369 } else {
10370 float r = b.imag / b.real;
10371 float s = (float)(1.0) / (b.real + b.imag * r);
10372 return __pyx_t_float_complex_from_parts(
10373 (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
10374 }
10375 } else {
10376 float r = b.real / b.imag;
10377 float s = (float)(1.0) / (b.imag + b.real * r);
10378 return __pyx_t_float_complex_from_parts(
10379 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
10380 }
10381 }
10382 #else
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)10383 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
10384 if (b.imag == 0) {
10385 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
10386 } else {
10387 float denom = b.real * b.real + b.imag * b.imag;
10388 return __pyx_t_float_complex_from_parts(
10389 (a.real * b.real + a.imag * b.imag) / denom,
10390 (a.imag * b.real - a.real * b.imag) / denom);
10391 }
10392 }
10393 #endif
__Pyx_c_neg_float(__pyx_t_float_complex a)10394 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
10395 __pyx_t_float_complex z;
10396 z.real = -a.real;
10397 z.imag = -a.imag;
10398 return z;
10399 }
__Pyx_c_is_zero_float(__pyx_t_float_complex a)10400 static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
10401 return (a.real == 0) && (a.imag == 0);
10402 }
__Pyx_c_conj_float(__pyx_t_float_complex a)10403 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
10404 __pyx_t_float_complex z;
10405 z.real = a.real;
10406 z.imag = -a.imag;
10407 return z;
10408 }
10409 #if 1
__Pyx_c_abs_float(__pyx_t_float_complex z)10410 static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
10411 #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
10412 return sqrtf(z.real*z.real + z.imag*z.imag);
10413 #else
10414 return hypotf(z.real, z.imag);
10415 #endif
10416 }
__Pyx_c_pow_float(__pyx_t_float_complex a,__pyx_t_float_complex b)10417 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
10418 __pyx_t_float_complex z;
10419 float r, lnr, theta, z_r, z_theta;
10420 if (b.imag == 0 && b.real == (int)b.real) {
10421 if (b.real < 0) {
10422 float denom = a.real * a.real + a.imag * a.imag;
10423 a.real = a.real / denom;
10424 a.imag = -a.imag / denom;
10425 b.real = -b.real;
10426 }
10427 switch ((int)b.real) {
10428 case 0:
10429 z.real = 1;
10430 z.imag = 0;
10431 return z;
10432 case 1:
10433 return a;
10434 case 2:
10435 return __Pyx_c_prod_float(a, a);
10436 case 3:
10437 z = __Pyx_c_prod_float(a, a);
10438 return __Pyx_c_prod_float(z, a);
10439 case 4:
10440 z = __Pyx_c_prod_float(a, a);
10441 return __Pyx_c_prod_float(z, z);
10442 }
10443 }
10444 if (a.imag == 0) {
10445 if (a.real == 0) {
10446 return a;
10447 } else if (b.imag == 0) {
10448 z.real = powf(a.real, b.real);
10449 z.imag = 0;
10450 return z;
10451 } else if (a.real > 0) {
10452 r = a.real;
10453 theta = 0;
10454 } else {
10455 r = -a.real;
10456 theta = atan2f(0.0, -1.0);
10457 }
10458 } else {
10459 r = __Pyx_c_abs_float(a);
10460 theta = atan2f(a.imag, a.real);
10461 }
10462 lnr = logf(r);
10463 z_r = expf(lnr * b.real - theta * b.imag);
10464 z_theta = theta * b.real + lnr * b.imag;
10465 z.real = z_r * cosf(z_theta);
10466 z.imag = z_r * sinf(z_theta);
10467 return z;
10468 }
10469 #endif
10470 #endif
10471
10472 /* Declarations */
10473 #if CYTHON_CCOMPLEX
10474 #ifdef __cplusplus
__pyx_t_double_complex_from_parts(double x,double y)10475 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
10476 return ::std::complex< double >(x, y);
10477 }
10478 #else
__pyx_t_double_complex_from_parts(double x,double y)10479 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
10480 return x + y*(__pyx_t_double_complex)_Complex_I;
10481 }
10482 #endif
10483 #else
__pyx_t_double_complex_from_parts(double x,double y)10484 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
10485 __pyx_t_double_complex z;
10486 z.real = x;
10487 z.imag = y;
10488 return z;
10489 }
10490 #endif
10491
10492 /* Arithmetic */
10493 #if CYTHON_CCOMPLEX
10494 #else
__Pyx_c_eq_double(__pyx_t_double_complex a,__pyx_t_double_complex b)10495 static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
10496 return (a.real == b.real) && (a.imag == b.imag);
10497 }
__Pyx_c_sum_double(__pyx_t_double_complex a,__pyx_t_double_complex b)10498 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
10499 __pyx_t_double_complex z;
10500 z.real = a.real + b.real;
10501 z.imag = a.imag + b.imag;
10502 return z;
10503 }
__Pyx_c_diff_double(__pyx_t_double_complex a,__pyx_t_double_complex b)10504 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
10505 __pyx_t_double_complex z;
10506 z.real = a.real - b.real;
10507 z.imag = a.imag - b.imag;
10508 return z;
10509 }
__Pyx_c_prod_double(__pyx_t_double_complex a,__pyx_t_double_complex b)10510 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
10511 __pyx_t_double_complex z;
10512 z.real = a.real * b.real - a.imag * b.imag;
10513 z.imag = a.real * b.imag + a.imag * b.real;
10514 return z;
10515 }
10516 #if 1
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)10517 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
10518 if (b.imag == 0) {
10519 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
10520 } else if (fabs(b.real) >= fabs(b.imag)) {
10521 if (b.real == 0 && b.imag == 0) {
10522 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
10523 } else {
10524 double r = b.imag / b.real;
10525 double s = (double)(1.0) / (b.real + b.imag * r);
10526 return __pyx_t_double_complex_from_parts(
10527 (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
10528 }
10529 } else {
10530 double r = b.real / b.imag;
10531 double s = (double)(1.0) / (b.imag + b.real * r);
10532 return __pyx_t_double_complex_from_parts(
10533 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
10534 }
10535 }
10536 #else
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)10537 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
10538 if (b.imag == 0) {
10539 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
10540 } else {
10541 double denom = b.real * b.real + b.imag * b.imag;
10542 return __pyx_t_double_complex_from_parts(
10543 (a.real * b.real + a.imag * b.imag) / denom,
10544 (a.imag * b.real - a.real * b.imag) / denom);
10545 }
10546 }
10547 #endif
__Pyx_c_neg_double(__pyx_t_double_complex a)10548 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
10549 __pyx_t_double_complex z;
10550 z.real = -a.real;
10551 z.imag = -a.imag;
10552 return z;
10553 }
__Pyx_c_is_zero_double(__pyx_t_double_complex a)10554 static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
10555 return (a.real == 0) && (a.imag == 0);
10556 }
__Pyx_c_conj_double(__pyx_t_double_complex a)10557 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
10558 __pyx_t_double_complex z;
10559 z.real = a.real;
10560 z.imag = -a.imag;
10561 return z;
10562 }
10563 #if 1
__Pyx_c_abs_double(__pyx_t_double_complex z)10564 static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
10565 #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
10566 return sqrt(z.real*z.real + z.imag*z.imag);
10567 #else
10568 return hypot(z.real, z.imag);
10569 #endif
10570 }
__Pyx_c_pow_double(__pyx_t_double_complex a,__pyx_t_double_complex b)10571 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
10572 __pyx_t_double_complex z;
10573 double r, lnr, theta, z_r, z_theta;
10574 if (b.imag == 0 && b.real == (int)b.real) {
10575 if (b.real < 0) {
10576 double denom = a.real * a.real + a.imag * a.imag;
10577 a.real = a.real / denom;
10578 a.imag = -a.imag / denom;
10579 b.real = -b.real;
10580 }
10581 switch ((int)b.real) {
10582 case 0:
10583 z.real = 1;
10584 z.imag = 0;
10585 return z;
10586 case 1:
10587 return a;
10588 case 2:
10589 return __Pyx_c_prod_double(a, a);
10590 case 3:
10591 z = __Pyx_c_prod_double(a, a);
10592 return __Pyx_c_prod_double(z, a);
10593 case 4:
10594 z = __Pyx_c_prod_double(a, a);
10595 return __Pyx_c_prod_double(z, z);
10596 }
10597 }
10598 if (a.imag == 0) {
10599 if (a.real == 0) {
10600 return a;
10601 } else if (b.imag == 0) {
10602 z.real = pow(a.real, b.real);
10603 z.imag = 0;
10604 return z;
10605 } else if (a.real > 0) {
10606 r = a.real;
10607 theta = 0;
10608 } else {
10609 r = -a.real;
10610 theta = atan2(0.0, -1.0);
10611 }
10612 } else {
10613 r = __Pyx_c_abs_double(a);
10614 theta = atan2(a.imag, a.real);
10615 }
10616 lnr = log(r);
10617 z_r = exp(lnr * b.real - theta * b.imag);
10618 z_theta = theta * b.real + lnr * b.imag;
10619 z.real = z_r * cos(z_theta);
10620 z.imag = z_r * sin(z_theta);
10621 return z;
10622 }
10623 #endif
10624 #endif
10625
10626 /* CIntFromPy */
__Pyx_PyInt_As_unsigned_int(PyObject * x)10627 static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) {
10628 const unsigned int neg_one = (unsigned int) ((unsigned int) 0 - (unsigned int) 1), const_zero = (unsigned int) 0;
10629 const int is_unsigned = neg_one > const_zero;
10630 #if PY_MAJOR_VERSION < 3
10631 if (likely(PyInt_Check(x))) {
10632 if (sizeof(unsigned int) < sizeof(long)) {
10633 __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x))
10634 } else {
10635 long val = PyInt_AS_LONG(x);
10636 if (is_unsigned && unlikely(val < 0)) {
10637 goto raise_neg_overflow;
10638 }
10639 return (unsigned int) val;
10640 }
10641 } else
10642 #endif
10643 if (likely(PyLong_Check(x))) {
10644 if (is_unsigned) {
10645 #if CYTHON_USE_PYLONG_INTERNALS
10646 const digit* digits = ((PyLongObject*)x)->ob_digit;
10647 switch (Py_SIZE(x)) {
10648 case 0: return (unsigned int) 0;
10649 case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0])
10650 case 2:
10651 if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
10652 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
10653 __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10654 } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) {
10655 return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
10656 }
10657 }
10658 break;
10659 case 3:
10660 if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
10661 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
10662 __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10663 } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) {
10664 return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
10665 }
10666 }
10667 break;
10668 case 4:
10669 if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
10670 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
10671 __PYX_VERIFY_RETURN_INT(unsigned 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])))
10672 } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) {
10673 return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
10674 }
10675 }
10676 break;
10677 }
10678 #endif
10679 #if CYTHON_COMPILING_IN_CPYTHON
10680 if (unlikely(Py_SIZE(x) < 0)) {
10681 goto raise_neg_overflow;
10682 }
10683 #else
10684 {
10685 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
10686 if (unlikely(result < 0))
10687 return (unsigned int) -1;
10688 if (unlikely(result == 1))
10689 goto raise_neg_overflow;
10690 }
10691 #endif
10692 if (sizeof(unsigned int) <= sizeof(unsigned long)) {
10693 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x))
10694 #ifdef HAVE_LONG_LONG
10695 } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
10696 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
10697 #endif
10698 }
10699 } else {
10700 #if CYTHON_USE_PYLONG_INTERNALS
10701 const digit* digits = ((PyLongObject*)x)->ob_digit;
10702 switch (Py_SIZE(x)) {
10703 case 0: return (unsigned int) 0;
10704 case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0]))
10705 case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0])
10706 case -2:
10707 if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) {
10708 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
10709 __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10710 } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
10711 return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
10712 }
10713 }
10714 break;
10715 case 2:
10716 if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
10717 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
10718 __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10719 } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
10720 return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
10721 }
10722 }
10723 break;
10724 case -3:
10725 if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
10726 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
10727 __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10728 } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
10729 return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
10730 }
10731 }
10732 break;
10733 case 3:
10734 if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
10735 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
10736 __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10737 } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
10738 return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
10739 }
10740 }
10741 break;
10742 case -4:
10743 if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
10744 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
10745 __PYX_VERIFY_RETURN_INT(unsigned 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])))
10746 } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
10747 return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
10748 }
10749 }
10750 break;
10751 case 4:
10752 if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
10753 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
10754 __PYX_VERIFY_RETURN_INT(unsigned 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])))
10755 } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
10756 return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
10757 }
10758 }
10759 break;
10760 }
10761 #endif
10762 if (sizeof(unsigned int) <= sizeof(long)) {
10763 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x))
10764 #ifdef HAVE_LONG_LONG
10765 } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
10766 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x))
10767 #endif
10768 }
10769 }
10770 {
10771 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
10772 PyErr_SetString(PyExc_RuntimeError,
10773 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
10774 #else
10775 unsigned int val;
10776 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
10777 #if PY_MAJOR_VERSION < 3
10778 if (likely(v) && !PyLong_Check(v)) {
10779 PyObject *tmp = v;
10780 v = PyNumber_Long(tmp);
10781 Py_DECREF(tmp);
10782 }
10783 #endif
10784 if (likely(v)) {
10785 int one = 1; int is_little = (int)*(unsigned char *)&one;
10786 unsigned char *bytes = (unsigned char *)&val;
10787 int ret = _PyLong_AsByteArray((PyLongObject *)v,
10788 bytes, sizeof(val),
10789 is_little, !is_unsigned);
10790 Py_DECREF(v);
10791 if (likely(!ret))
10792 return val;
10793 }
10794 #endif
10795 return (unsigned int) -1;
10796 }
10797 } else {
10798 unsigned int val;
10799 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
10800 if (!tmp) return (unsigned int) -1;
10801 val = __Pyx_PyInt_As_unsigned_int(tmp);
10802 Py_DECREF(tmp);
10803 return val;
10804 }
10805 raise_overflow:
10806 PyErr_SetString(PyExc_OverflowError,
10807 "value too large to convert to unsigned int");
10808 return (unsigned int) -1;
10809 raise_neg_overflow:
10810 PyErr_SetString(PyExc_OverflowError,
10811 "can't convert negative value to unsigned int");
10812 return (unsigned int) -1;
10813 }
10814
10815 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)10816 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
10817 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
10818 const int is_unsigned = neg_one > const_zero;
10819 #if PY_MAJOR_VERSION < 3
10820 if (likely(PyInt_Check(x))) {
10821 if (sizeof(int) < sizeof(long)) {
10822 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
10823 } else {
10824 long val = PyInt_AS_LONG(x);
10825 if (is_unsigned && unlikely(val < 0)) {
10826 goto raise_neg_overflow;
10827 }
10828 return (int) val;
10829 }
10830 } else
10831 #endif
10832 if (likely(PyLong_Check(x))) {
10833 if (is_unsigned) {
10834 #if CYTHON_USE_PYLONG_INTERNALS
10835 const digit* digits = ((PyLongObject*)x)->ob_digit;
10836 switch (Py_SIZE(x)) {
10837 case 0: return (int) 0;
10838 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
10839 case 2:
10840 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
10841 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
10842 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10843 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
10844 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
10845 }
10846 }
10847 break;
10848 case 3:
10849 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
10850 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
10851 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10852 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
10853 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
10854 }
10855 }
10856 break;
10857 case 4:
10858 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
10859 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
10860 __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])))
10861 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
10862 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
10863 }
10864 }
10865 break;
10866 }
10867 #endif
10868 #if CYTHON_COMPILING_IN_CPYTHON
10869 if (unlikely(Py_SIZE(x) < 0)) {
10870 goto raise_neg_overflow;
10871 }
10872 #else
10873 {
10874 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
10875 if (unlikely(result < 0))
10876 return (int) -1;
10877 if (unlikely(result == 1))
10878 goto raise_neg_overflow;
10879 }
10880 #endif
10881 if (sizeof(int) <= sizeof(unsigned long)) {
10882 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
10883 #ifdef HAVE_LONG_LONG
10884 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
10885 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
10886 #endif
10887 }
10888 } else {
10889 #if CYTHON_USE_PYLONG_INTERNALS
10890 const digit* digits = ((PyLongObject*)x)->ob_digit;
10891 switch (Py_SIZE(x)) {
10892 case 0: return (int) 0;
10893 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
10894 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
10895 case -2:
10896 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
10897 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
10898 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10899 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
10900 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
10901 }
10902 }
10903 break;
10904 case 2:
10905 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
10906 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
10907 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10908 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
10909 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
10910 }
10911 }
10912 break;
10913 case -3:
10914 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
10915 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
10916 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10917 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
10918 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
10919 }
10920 }
10921 break;
10922 case 3:
10923 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
10924 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
10925 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10926 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
10927 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
10928 }
10929 }
10930 break;
10931 case -4:
10932 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
10933 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
10934 __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])))
10935 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
10936 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
10937 }
10938 }
10939 break;
10940 case 4:
10941 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
10942 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
10943 __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])))
10944 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
10945 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
10946 }
10947 }
10948 break;
10949 }
10950 #endif
10951 if (sizeof(int) <= sizeof(long)) {
10952 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
10953 #ifdef HAVE_LONG_LONG
10954 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
10955 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
10956 #endif
10957 }
10958 }
10959 {
10960 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
10961 PyErr_SetString(PyExc_RuntimeError,
10962 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
10963 #else
10964 int val;
10965 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
10966 #if PY_MAJOR_VERSION < 3
10967 if (likely(v) && !PyLong_Check(v)) {
10968 PyObject *tmp = v;
10969 v = PyNumber_Long(tmp);
10970 Py_DECREF(tmp);
10971 }
10972 #endif
10973 if (likely(v)) {
10974 int one = 1; int is_little = (int)*(unsigned char *)&one;
10975 unsigned char *bytes = (unsigned char *)&val;
10976 int ret = _PyLong_AsByteArray((PyLongObject *)v,
10977 bytes, sizeof(val),
10978 is_little, !is_unsigned);
10979 Py_DECREF(v);
10980 if (likely(!ret))
10981 return val;
10982 }
10983 #endif
10984 return (int) -1;
10985 }
10986 } else {
10987 int val;
10988 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
10989 if (!tmp) return (int) -1;
10990 val = __Pyx_PyInt_As_int(tmp);
10991 Py_DECREF(tmp);
10992 return val;
10993 }
10994 raise_overflow:
10995 PyErr_SetString(PyExc_OverflowError,
10996 "value too large to convert to int");
10997 return (int) -1;
10998 raise_neg_overflow:
10999 PyErr_SetString(PyExc_OverflowError,
11000 "can't convert negative value to int");
11001 return (int) -1;
11002 }
11003
11004 /* CIntFromPy */
__Pyx_PyInt_As_npy_uint32(PyObject * x)11005 static CYTHON_INLINE npy_uint32 __Pyx_PyInt_As_npy_uint32(PyObject *x) {
11006 const npy_uint32 neg_one = (npy_uint32) ((npy_uint32) 0 - (npy_uint32) 1), const_zero = (npy_uint32) 0;
11007 const int is_unsigned = neg_one > const_zero;
11008 #if PY_MAJOR_VERSION < 3
11009 if (likely(PyInt_Check(x))) {
11010 if (sizeof(npy_uint32) < sizeof(long)) {
11011 __PYX_VERIFY_RETURN_INT(npy_uint32, long, PyInt_AS_LONG(x))
11012 } else {
11013 long val = PyInt_AS_LONG(x);
11014 if (is_unsigned && unlikely(val < 0)) {
11015 goto raise_neg_overflow;
11016 }
11017 return (npy_uint32) val;
11018 }
11019 } else
11020 #endif
11021 if (likely(PyLong_Check(x))) {
11022 if (is_unsigned) {
11023 #if CYTHON_USE_PYLONG_INTERNALS
11024 const digit* digits = ((PyLongObject*)x)->ob_digit;
11025 switch (Py_SIZE(x)) {
11026 case 0: return (npy_uint32) 0;
11027 case 1: __PYX_VERIFY_RETURN_INT(npy_uint32, digit, digits[0])
11028 case 2:
11029 if (8 * sizeof(npy_uint32) > 1 * PyLong_SHIFT) {
11030 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11031 __PYX_VERIFY_RETURN_INT(npy_uint32, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11032 } else if (8 * sizeof(npy_uint32) >= 2 * PyLong_SHIFT) {
11033 return (npy_uint32) (((((npy_uint32)digits[1]) << PyLong_SHIFT) | (npy_uint32)digits[0]));
11034 }
11035 }
11036 break;
11037 case 3:
11038 if (8 * sizeof(npy_uint32) > 2 * PyLong_SHIFT) {
11039 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11040 __PYX_VERIFY_RETURN_INT(npy_uint32, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11041 } else if (8 * sizeof(npy_uint32) >= 3 * PyLong_SHIFT) {
11042 return (npy_uint32) (((((((npy_uint32)digits[2]) << PyLong_SHIFT) | (npy_uint32)digits[1]) << PyLong_SHIFT) | (npy_uint32)digits[0]));
11043 }
11044 }
11045 break;
11046 case 4:
11047 if (8 * sizeof(npy_uint32) > 3 * PyLong_SHIFT) {
11048 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11049 __PYX_VERIFY_RETURN_INT(npy_uint32, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11050 } else if (8 * sizeof(npy_uint32) >= 4 * PyLong_SHIFT) {
11051 return (npy_uint32) (((((((((npy_uint32)digits[3]) << PyLong_SHIFT) | (npy_uint32)digits[2]) << PyLong_SHIFT) | (npy_uint32)digits[1]) << PyLong_SHIFT) | (npy_uint32)digits[0]));
11052 }
11053 }
11054 break;
11055 }
11056 #endif
11057 #if CYTHON_COMPILING_IN_CPYTHON
11058 if (unlikely(Py_SIZE(x) < 0)) {
11059 goto raise_neg_overflow;
11060 }
11061 #else
11062 {
11063 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
11064 if (unlikely(result < 0))
11065 return (npy_uint32) -1;
11066 if (unlikely(result == 1))
11067 goto raise_neg_overflow;
11068 }
11069 #endif
11070 if (sizeof(npy_uint32) <= sizeof(unsigned long)) {
11071 __PYX_VERIFY_RETURN_INT_EXC(npy_uint32, unsigned long, PyLong_AsUnsignedLong(x))
11072 #ifdef HAVE_LONG_LONG
11073 } else if (sizeof(npy_uint32) <= sizeof(unsigned PY_LONG_LONG)) {
11074 __PYX_VERIFY_RETURN_INT_EXC(npy_uint32, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
11075 #endif
11076 }
11077 } else {
11078 #if CYTHON_USE_PYLONG_INTERNALS
11079 const digit* digits = ((PyLongObject*)x)->ob_digit;
11080 switch (Py_SIZE(x)) {
11081 case 0: return (npy_uint32) 0;
11082 case -1: __PYX_VERIFY_RETURN_INT(npy_uint32, sdigit, (sdigit) (-(sdigit)digits[0]))
11083 case 1: __PYX_VERIFY_RETURN_INT(npy_uint32, digit, +digits[0])
11084 case -2:
11085 if (8 * sizeof(npy_uint32) - 1 > 1 * PyLong_SHIFT) {
11086 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11087 __PYX_VERIFY_RETURN_INT(npy_uint32, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11088 } else if (8 * sizeof(npy_uint32) - 1 > 2 * PyLong_SHIFT) {
11089 return (npy_uint32) (((npy_uint32)-1)*(((((npy_uint32)digits[1]) << PyLong_SHIFT) | (npy_uint32)digits[0])));
11090 }
11091 }
11092 break;
11093 case 2:
11094 if (8 * sizeof(npy_uint32) > 1 * PyLong_SHIFT) {
11095 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11096 __PYX_VERIFY_RETURN_INT(npy_uint32, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11097 } else if (8 * sizeof(npy_uint32) - 1 > 2 * PyLong_SHIFT) {
11098 return (npy_uint32) ((((((npy_uint32)digits[1]) << PyLong_SHIFT) | (npy_uint32)digits[0])));
11099 }
11100 }
11101 break;
11102 case -3:
11103 if (8 * sizeof(npy_uint32) - 1 > 2 * PyLong_SHIFT) {
11104 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11105 __PYX_VERIFY_RETURN_INT(npy_uint32, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11106 } else if (8 * sizeof(npy_uint32) - 1 > 3 * PyLong_SHIFT) {
11107 return (npy_uint32) (((npy_uint32)-1)*(((((((npy_uint32)digits[2]) << PyLong_SHIFT) | (npy_uint32)digits[1]) << PyLong_SHIFT) | (npy_uint32)digits[0])));
11108 }
11109 }
11110 break;
11111 case 3:
11112 if (8 * sizeof(npy_uint32) > 2 * PyLong_SHIFT) {
11113 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11114 __PYX_VERIFY_RETURN_INT(npy_uint32, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11115 } else if (8 * sizeof(npy_uint32) - 1 > 3 * PyLong_SHIFT) {
11116 return (npy_uint32) ((((((((npy_uint32)digits[2]) << PyLong_SHIFT) | (npy_uint32)digits[1]) << PyLong_SHIFT) | (npy_uint32)digits[0])));
11117 }
11118 }
11119 break;
11120 case -4:
11121 if (8 * sizeof(npy_uint32) - 1 > 3 * PyLong_SHIFT) {
11122 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11123 __PYX_VERIFY_RETURN_INT(npy_uint32, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11124 } else if (8 * sizeof(npy_uint32) - 1 > 4 * PyLong_SHIFT) {
11125 return (npy_uint32) (((npy_uint32)-1)*(((((((((npy_uint32)digits[3]) << PyLong_SHIFT) | (npy_uint32)digits[2]) << PyLong_SHIFT) | (npy_uint32)digits[1]) << PyLong_SHIFT) | (npy_uint32)digits[0])));
11126 }
11127 }
11128 break;
11129 case 4:
11130 if (8 * sizeof(npy_uint32) > 3 * PyLong_SHIFT) {
11131 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11132 __PYX_VERIFY_RETURN_INT(npy_uint32, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11133 } else if (8 * sizeof(npy_uint32) - 1 > 4 * PyLong_SHIFT) {
11134 return (npy_uint32) ((((((((((npy_uint32)digits[3]) << PyLong_SHIFT) | (npy_uint32)digits[2]) << PyLong_SHIFT) | (npy_uint32)digits[1]) << PyLong_SHIFT) | (npy_uint32)digits[0])));
11135 }
11136 }
11137 break;
11138 }
11139 #endif
11140 if (sizeof(npy_uint32) <= sizeof(long)) {
11141 __PYX_VERIFY_RETURN_INT_EXC(npy_uint32, long, PyLong_AsLong(x))
11142 #ifdef HAVE_LONG_LONG
11143 } else if (sizeof(npy_uint32) <= sizeof(PY_LONG_LONG)) {
11144 __PYX_VERIFY_RETURN_INT_EXC(npy_uint32, PY_LONG_LONG, PyLong_AsLongLong(x))
11145 #endif
11146 }
11147 }
11148 {
11149 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
11150 PyErr_SetString(PyExc_RuntimeError,
11151 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
11152 #else
11153 npy_uint32 val;
11154 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
11155 #if PY_MAJOR_VERSION < 3
11156 if (likely(v) && !PyLong_Check(v)) {
11157 PyObject *tmp = v;
11158 v = PyNumber_Long(tmp);
11159 Py_DECREF(tmp);
11160 }
11161 #endif
11162 if (likely(v)) {
11163 int one = 1; int is_little = (int)*(unsigned char *)&one;
11164 unsigned char *bytes = (unsigned char *)&val;
11165 int ret = _PyLong_AsByteArray((PyLongObject *)v,
11166 bytes, sizeof(val),
11167 is_little, !is_unsigned);
11168 Py_DECREF(v);
11169 if (likely(!ret))
11170 return val;
11171 }
11172 #endif
11173 return (npy_uint32) -1;
11174 }
11175 } else {
11176 npy_uint32 val;
11177 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
11178 if (!tmp) return (npy_uint32) -1;
11179 val = __Pyx_PyInt_As_npy_uint32(tmp);
11180 Py_DECREF(tmp);
11181 return val;
11182 }
11183 raise_overflow:
11184 PyErr_SetString(PyExc_OverflowError,
11185 "value too large to convert to npy_uint32");
11186 return (npy_uint32) -1;
11187 raise_neg_overflow:
11188 PyErr_SetString(PyExc_OverflowError,
11189 "can't convert negative value to npy_uint32");
11190 return (npy_uint32) -1;
11191 }
11192
11193 /* CIntFromPy */
__Pyx_PyInt_As_PY_LONG_LONG(PyObject * x)11194 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_As_PY_LONG_LONG(PyObject *x) {
11195 const PY_LONG_LONG neg_one = (PY_LONG_LONG) ((PY_LONG_LONG) 0 - (PY_LONG_LONG) 1), const_zero = (PY_LONG_LONG) 0;
11196 const int is_unsigned = neg_one > const_zero;
11197 #if PY_MAJOR_VERSION < 3
11198 if (likely(PyInt_Check(x))) {
11199 if (sizeof(PY_LONG_LONG) < sizeof(long)) {
11200 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, PyInt_AS_LONG(x))
11201 } else {
11202 long val = PyInt_AS_LONG(x);
11203 if (is_unsigned && unlikely(val < 0)) {
11204 goto raise_neg_overflow;
11205 }
11206 return (PY_LONG_LONG) val;
11207 }
11208 } else
11209 #endif
11210 if (likely(PyLong_Check(x))) {
11211 if (is_unsigned) {
11212 #if CYTHON_USE_PYLONG_INTERNALS
11213 const digit* digits = ((PyLongObject*)x)->ob_digit;
11214 switch (Py_SIZE(x)) {
11215 case 0: return (PY_LONG_LONG) 0;
11216 case 1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, digit, digits[0])
11217 case 2:
11218 if (8 * sizeof(PY_LONG_LONG) > 1 * PyLong_SHIFT) {
11219 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11220 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11221 } else if (8 * sizeof(PY_LONG_LONG) >= 2 * PyLong_SHIFT) {
11222 return (PY_LONG_LONG) (((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0]));
11223 }
11224 }
11225 break;
11226 case 3:
11227 if (8 * sizeof(PY_LONG_LONG) > 2 * PyLong_SHIFT) {
11228 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11229 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11230 } else if (8 * sizeof(PY_LONG_LONG) >= 3 * PyLong_SHIFT) {
11231 return (PY_LONG_LONG) (((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0]));
11232 }
11233 }
11234 break;
11235 case 4:
11236 if (8 * sizeof(PY_LONG_LONG) > 3 * PyLong_SHIFT) {
11237 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11238 __PYX_VERIFY_RETURN_INT(PY_LONG_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])))
11239 } else if (8 * sizeof(PY_LONG_LONG) >= 4 * PyLong_SHIFT) {
11240 return (PY_LONG_LONG) (((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0]));
11241 }
11242 }
11243 break;
11244 }
11245 #endif
11246 #if CYTHON_COMPILING_IN_CPYTHON
11247 if (unlikely(Py_SIZE(x) < 0)) {
11248 goto raise_neg_overflow;
11249 }
11250 #else
11251 {
11252 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
11253 if (unlikely(result < 0))
11254 return (PY_LONG_LONG) -1;
11255 if (unlikely(result == 1))
11256 goto raise_neg_overflow;
11257 }
11258 #endif
11259 if (sizeof(PY_LONG_LONG) <= sizeof(unsigned long)) {
11260 __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x))
11261 #ifdef HAVE_LONG_LONG
11262 } else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
11263 __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
11264 #endif
11265 }
11266 } else {
11267 #if CYTHON_USE_PYLONG_INTERNALS
11268 const digit* digits = ((PyLongObject*)x)->ob_digit;
11269 switch (Py_SIZE(x)) {
11270 case 0: return (PY_LONG_LONG) 0;
11271 case -1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, sdigit, (sdigit) (-(sdigit)digits[0]))
11272 case 1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, digit, +digits[0])
11273 case -2:
11274 if (8 * sizeof(PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT) {
11275 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11276 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11277 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
11278 return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
11279 }
11280 }
11281 break;
11282 case 2:
11283 if (8 * sizeof(PY_LONG_LONG) > 1 * PyLong_SHIFT) {
11284 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11285 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11286 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
11287 return (PY_LONG_LONG) ((((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
11288 }
11289 }
11290 break;
11291 case -3:
11292 if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
11293 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11294 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11295 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
11296 return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
11297 }
11298 }
11299 break;
11300 case 3:
11301 if (8 * sizeof(PY_LONG_LONG) > 2 * PyLong_SHIFT) {
11302 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11303 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11304 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
11305 return (PY_LONG_LONG) ((((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
11306 }
11307 }
11308 break;
11309 case -4:
11310 if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
11311 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11312 __PYX_VERIFY_RETURN_INT(PY_LONG_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])))
11313 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
11314 return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
11315 }
11316 }
11317 break;
11318 case 4:
11319 if (8 * sizeof(PY_LONG_LONG) > 3 * PyLong_SHIFT) {
11320 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11321 __PYX_VERIFY_RETURN_INT(PY_LONG_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])))
11322 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
11323 return (PY_LONG_LONG) ((((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
11324 }
11325 }
11326 break;
11327 }
11328 #endif
11329 if (sizeof(PY_LONG_LONG) <= sizeof(long)) {
11330 __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, long, PyLong_AsLong(x))
11331 #ifdef HAVE_LONG_LONG
11332 } else if (sizeof(PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
11333 __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x))
11334 #endif
11335 }
11336 }
11337 {
11338 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
11339 PyErr_SetString(PyExc_RuntimeError,
11340 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
11341 #else
11342 PY_LONG_LONG val;
11343 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
11344 #if PY_MAJOR_VERSION < 3
11345 if (likely(v) && !PyLong_Check(v)) {
11346 PyObject *tmp = v;
11347 v = PyNumber_Long(tmp);
11348 Py_DECREF(tmp);
11349 }
11350 #endif
11351 if (likely(v)) {
11352 int one = 1; int is_little = (int)*(unsigned char *)&one;
11353 unsigned char *bytes = (unsigned char *)&val;
11354 int ret = _PyLong_AsByteArray((PyLongObject *)v,
11355 bytes, sizeof(val),
11356 is_little, !is_unsigned);
11357 Py_DECREF(v);
11358 if (likely(!ret))
11359 return val;
11360 }
11361 #endif
11362 return (PY_LONG_LONG) -1;
11363 }
11364 } else {
11365 PY_LONG_LONG val;
11366 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
11367 if (!tmp) return (PY_LONG_LONG) -1;
11368 val = __Pyx_PyInt_As_PY_LONG_LONG(tmp);
11369 Py_DECREF(tmp);
11370 return val;
11371 }
11372 raise_overflow:
11373 PyErr_SetString(PyExc_OverflowError,
11374 "value too large to convert to PY_LONG_LONG");
11375 return (PY_LONG_LONG) -1;
11376 raise_neg_overflow:
11377 PyErr_SetString(PyExc_OverflowError,
11378 "can't convert negative value to PY_LONG_LONG");
11379 return (PY_LONG_LONG) -1;
11380 }
11381
11382 /* CIntFromPy */
__Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject * x)11383 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *x) {
11384 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) ((unsigned PY_LONG_LONG) 0 - (unsigned PY_LONG_LONG) 1), const_zero = (unsigned PY_LONG_LONG) 0;
11385 const int is_unsigned = neg_one > const_zero;
11386 #if PY_MAJOR_VERSION < 3
11387 if (likely(PyInt_Check(x))) {
11388 if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
11389 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, PyInt_AS_LONG(x))
11390 } else {
11391 long val = PyInt_AS_LONG(x);
11392 if (is_unsigned && unlikely(val < 0)) {
11393 goto raise_neg_overflow;
11394 }
11395 return (unsigned PY_LONG_LONG) val;
11396 }
11397 } else
11398 #endif
11399 if (likely(PyLong_Check(x))) {
11400 if (is_unsigned) {
11401 #if CYTHON_USE_PYLONG_INTERNALS
11402 const digit* digits = ((PyLongObject*)x)->ob_digit;
11403 switch (Py_SIZE(x)) {
11404 case 0: return (unsigned PY_LONG_LONG) 0;
11405 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, digits[0])
11406 case 2:
11407 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
11408 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11409 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11410 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 2 * PyLong_SHIFT) {
11411 return (unsigned PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
11412 }
11413 }
11414 break;
11415 case 3:
11416 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
11417 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11418 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11419 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 3 * PyLong_SHIFT) {
11420 return (unsigned PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
11421 }
11422 }
11423 break;
11424 case 4:
11425 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
11426 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11427 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_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])))
11428 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 4 * PyLong_SHIFT) {
11429 return (unsigned PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
11430 }
11431 }
11432 break;
11433 }
11434 #endif
11435 #if CYTHON_COMPILING_IN_CPYTHON
11436 if (unlikely(Py_SIZE(x) < 0)) {
11437 goto raise_neg_overflow;
11438 }
11439 #else
11440 {
11441 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
11442 if (unlikely(result < 0))
11443 return (unsigned PY_LONG_LONG) -1;
11444 if (unlikely(result == 1))
11445 goto raise_neg_overflow;
11446 }
11447 #endif
11448 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
11449 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x))
11450 #ifdef HAVE_LONG_LONG
11451 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
11452 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
11453 #endif
11454 }
11455 } else {
11456 #if CYTHON_USE_PYLONG_INTERNALS
11457 const digit* digits = ((PyLongObject*)x)->ob_digit;
11458 switch (Py_SIZE(x)) {
11459 case 0: return (unsigned PY_LONG_LONG) 0;
11460 case -1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, sdigit, (sdigit) (-(sdigit)digits[0]))
11461 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, +digits[0])
11462 case -2:
11463 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT) {
11464 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11465 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11466 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
11467 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
11468 }
11469 }
11470 break;
11471 case 2:
11472 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
11473 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11474 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11475 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
11476 return (unsigned PY_LONG_LONG) ((((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
11477 }
11478 }
11479 break;
11480 case -3:
11481 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
11482 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11483 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11484 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
11485 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
11486 }
11487 }
11488 break;
11489 case 3:
11490 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
11491 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11492 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11493 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
11494 return (unsigned PY_LONG_LONG) ((((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
11495 }
11496 }
11497 break;
11498 case -4:
11499 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
11500 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11501 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_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])))
11502 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
11503 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
11504 }
11505 }
11506 break;
11507 case 4:
11508 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
11509 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11510 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_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])))
11511 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
11512 return (unsigned PY_LONG_LONG) ((((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
11513 }
11514 }
11515 break;
11516 }
11517 #endif
11518 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
11519 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, long, PyLong_AsLong(x))
11520 #ifdef HAVE_LONG_LONG
11521 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
11522 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x))
11523 #endif
11524 }
11525 }
11526 {
11527 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
11528 PyErr_SetString(PyExc_RuntimeError,
11529 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
11530 #else
11531 unsigned PY_LONG_LONG val;
11532 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
11533 #if PY_MAJOR_VERSION < 3
11534 if (likely(v) && !PyLong_Check(v)) {
11535 PyObject *tmp = v;
11536 v = PyNumber_Long(tmp);
11537 Py_DECREF(tmp);
11538 }
11539 #endif
11540 if (likely(v)) {
11541 int one = 1; int is_little = (int)*(unsigned char *)&one;
11542 unsigned char *bytes = (unsigned char *)&val;
11543 int ret = _PyLong_AsByteArray((PyLongObject *)v,
11544 bytes, sizeof(val),
11545 is_little, !is_unsigned);
11546 Py_DECREF(v);
11547 if (likely(!ret))
11548 return val;
11549 }
11550 #endif
11551 return (unsigned PY_LONG_LONG) -1;
11552 }
11553 } else {
11554 unsigned PY_LONG_LONG val;
11555 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
11556 if (!tmp) return (unsigned PY_LONG_LONG) -1;
11557 val = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(tmp);
11558 Py_DECREF(tmp);
11559 return val;
11560 }
11561 raise_overflow:
11562 PyErr_SetString(PyExc_OverflowError,
11563 "value too large to convert to unsigned PY_LONG_LONG");
11564 return (unsigned PY_LONG_LONG) -1;
11565 raise_neg_overflow:
11566 PyErr_SetString(PyExc_OverflowError,
11567 "can't convert negative value to unsigned PY_LONG_LONG");
11568 return (unsigned PY_LONG_LONG) -1;
11569 }
11570
11571 /* CIntFromPy */
__Pyx_PyInt_As_char(PyObject * x)11572 static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
11573 const char neg_one = (char) ((char) 0 - (char) 1), const_zero = (char) 0;
11574 const int is_unsigned = neg_one > const_zero;
11575 #if PY_MAJOR_VERSION < 3
11576 if (likely(PyInt_Check(x))) {
11577 if (sizeof(char) < sizeof(long)) {
11578 __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
11579 } else {
11580 long val = PyInt_AS_LONG(x);
11581 if (is_unsigned && unlikely(val < 0)) {
11582 goto raise_neg_overflow;
11583 }
11584 return (char) val;
11585 }
11586 } else
11587 #endif
11588 if (likely(PyLong_Check(x))) {
11589 if (is_unsigned) {
11590 #if CYTHON_USE_PYLONG_INTERNALS
11591 const digit* digits = ((PyLongObject*)x)->ob_digit;
11592 switch (Py_SIZE(x)) {
11593 case 0: return (char) 0;
11594 case 1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
11595 case 2:
11596 if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
11597 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11598 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11599 } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
11600 return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
11601 }
11602 }
11603 break;
11604 case 3:
11605 if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
11606 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11607 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11608 } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
11609 return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
11610 }
11611 }
11612 break;
11613 case 4:
11614 if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
11615 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11616 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11617 } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
11618 return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
11619 }
11620 }
11621 break;
11622 }
11623 #endif
11624 #if CYTHON_COMPILING_IN_CPYTHON
11625 if (unlikely(Py_SIZE(x) < 0)) {
11626 goto raise_neg_overflow;
11627 }
11628 #else
11629 {
11630 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
11631 if (unlikely(result < 0))
11632 return (char) -1;
11633 if (unlikely(result == 1))
11634 goto raise_neg_overflow;
11635 }
11636 #endif
11637 if (sizeof(char) <= sizeof(unsigned long)) {
11638 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
11639 #ifdef HAVE_LONG_LONG
11640 } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
11641 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
11642 #endif
11643 }
11644 } else {
11645 #if CYTHON_USE_PYLONG_INTERNALS
11646 const digit* digits = ((PyLongObject*)x)->ob_digit;
11647 switch (Py_SIZE(x)) {
11648 case 0: return (char) 0;
11649 case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
11650 case 1: __PYX_VERIFY_RETURN_INT(char, digit, +digits[0])
11651 case -2:
11652 if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
11653 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11654 __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11655 } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
11656 return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
11657 }
11658 }
11659 break;
11660 case 2:
11661 if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
11662 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11663 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11664 } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
11665 return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
11666 }
11667 }
11668 break;
11669 case -3:
11670 if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
11671 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11672 __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11673 } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
11674 return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
11675 }
11676 }
11677 break;
11678 case 3:
11679 if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
11680 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11681 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11682 } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
11683 return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
11684 }
11685 }
11686 break;
11687 case -4:
11688 if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
11689 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11690 __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11691 } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
11692 return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
11693 }
11694 }
11695 break;
11696 case 4:
11697 if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
11698 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11699 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11700 } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
11701 return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
11702 }
11703 }
11704 break;
11705 }
11706 #endif
11707 if (sizeof(char) <= sizeof(long)) {
11708 __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
11709 #ifdef HAVE_LONG_LONG
11710 } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
11711 __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
11712 #endif
11713 }
11714 }
11715 {
11716 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
11717 PyErr_SetString(PyExc_RuntimeError,
11718 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
11719 #else
11720 char val;
11721 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
11722 #if PY_MAJOR_VERSION < 3
11723 if (likely(v) && !PyLong_Check(v)) {
11724 PyObject *tmp = v;
11725 v = PyNumber_Long(tmp);
11726 Py_DECREF(tmp);
11727 }
11728 #endif
11729 if (likely(v)) {
11730 int one = 1; int is_little = (int)*(unsigned char *)&one;
11731 unsigned char *bytes = (unsigned char *)&val;
11732 int ret = _PyLong_AsByteArray((PyLongObject *)v,
11733 bytes, sizeof(val),
11734 is_little, !is_unsigned);
11735 Py_DECREF(v);
11736 if (likely(!ret))
11737 return val;
11738 }
11739 #endif
11740 return (char) -1;
11741 }
11742 } else {
11743 char val;
11744 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
11745 if (!tmp) return (char) -1;
11746 val = __Pyx_PyInt_As_char(tmp);
11747 Py_DECREF(tmp);
11748 return val;
11749 }
11750 raise_overflow:
11751 PyErr_SetString(PyExc_OverflowError,
11752 "value too large to convert to char");
11753 return (char) -1;
11754 raise_neg_overflow:
11755 PyErr_SetString(PyExc_OverflowError,
11756 "can't convert negative value to char");
11757 return (char) -1;
11758 }
11759
11760 /* CIntFromPy */
__Pyx_PyInt_As_size_t(PyObject * x)11761 static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
11762 const size_t neg_one = (size_t) ((size_t) 0 - (size_t) 1), const_zero = (size_t) 0;
11763 const int is_unsigned = neg_one > const_zero;
11764 #if PY_MAJOR_VERSION < 3
11765 if (likely(PyInt_Check(x))) {
11766 if (sizeof(size_t) < sizeof(long)) {
11767 __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
11768 } else {
11769 long val = PyInt_AS_LONG(x);
11770 if (is_unsigned && unlikely(val < 0)) {
11771 goto raise_neg_overflow;
11772 }
11773 return (size_t) val;
11774 }
11775 } else
11776 #endif
11777 if (likely(PyLong_Check(x))) {
11778 if (is_unsigned) {
11779 #if CYTHON_USE_PYLONG_INTERNALS
11780 const digit* digits = ((PyLongObject*)x)->ob_digit;
11781 switch (Py_SIZE(x)) {
11782 case 0: return (size_t) 0;
11783 case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
11784 case 2:
11785 if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
11786 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11787 __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11788 } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
11789 return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
11790 }
11791 }
11792 break;
11793 case 3:
11794 if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
11795 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11796 __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11797 } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
11798 return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
11799 }
11800 }
11801 break;
11802 case 4:
11803 if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
11804 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11805 __PYX_VERIFY_RETURN_INT(size_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])))
11806 } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
11807 return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
11808 }
11809 }
11810 break;
11811 }
11812 #endif
11813 #if CYTHON_COMPILING_IN_CPYTHON
11814 if (unlikely(Py_SIZE(x) < 0)) {
11815 goto raise_neg_overflow;
11816 }
11817 #else
11818 {
11819 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
11820 if (unlikely(result < 0))
11821 return (size_t) -1;
11822 if (unlikely(result == 1))
11823 goto raise_neg_overflow;
11824 }
11825 #endif
11826 if (sizeof(size_t) <= sizeof(unsigned long)) {
11827 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
11828 #ifdef HAVE_LONG_LONG
11829 } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
11830 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
11831 #endif
11832 }
11833 } else {
11834 #if CYTHON_USE_PYLONG_INTERNALS
11835 const digit* digits = ((PyLongObject*)x)->ob_digit;
11836 switch (Py_SIZE(x)) {
11837 case 0: return (size_t) 0;
11838 case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
11839 case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0])
11840 case -2:
11841 if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
11842 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11843 __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11844 } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
11845 return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
11846 }
11847 }
11848 break;
11849 case 2:
11850 if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
11851 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11852 __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11853 } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
11854 return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
11855 }
11856 }
11857 break;
11858 case -3:
11859 if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
11860 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11861 __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11862 } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
11863 return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
11864 }
11865 }
11866 break;
11867 case 3:
11868 if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
11869 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11870 __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11871 } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
11872 return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
11873 }
11874 }
11875 break;
11876 case -4:
11877 if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
11878 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11879 __PYX_VERIFY_RETURN_INT(size_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])))
11880 } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
11881 return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
11882 }
11883 }
11884 break;
11885 case 4:
11886 if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
11887 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11888 __PYX_VERIFY_RETURN_INT(size_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])))
11889 } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
11890 return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
11891 }
11892 }
11893 break;
11894 }
11895 #endif
11896 if (sizeof(size_t) <= sizeof(long)) {
11897 __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
11898 #ifdef HAVE_LONG_LONG
11899 } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
11900 __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
11901 #endif
11902 }
11903 }
11904 {
11905 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
11906 PyErr_SetString(PyExc_RuntimeError,
11907 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
11908 #else
11909 size_t val;
11910 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
11911 #if PY_MAJOR_VERSION < 3
11912 if (likely(v) && !PyLong_Check(v)) {
11913 PyObject *tmp = v;
11914 v = PyNumber_Long(tmp);
11915 Py_DECREF(tmp);
11916 }
11917 #endif
11918 if (likely(v)) {
11919 int one = 1; int is_little = (int)*(unsigned char *)&one;
11920 unsigned char *bytes = (unsigned char *)&val;
11921 int ret = _PyLong_AsByteArray((PyLongObject *)v,
11922 bytes, sizeof(val),
11923 is_little, !is_unsigned);
11924 Py_DECREF(v);
11925 if (likely(!ret))
11926 return val;
11927 }
11928 #endif
11929 return (size_t) -1;
11930 }
11931 } else {
11932 size_t val;
11933 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
11934 if (!tmp) return (size_t) -1;
11935 val = __Pyx_PyInt_As_size_t(tmp);
11936 Py_DECREF(tmp);
11937 return val;
11938 }
11939 raise_overflow:
11940 PyErr_SetString(PyExc_OverflowError,
11941 "value too large to convert to size_t");
11942 return (size_t) -1;
11943 raise_neg_overflow:
11944 PyErr_SetString(PyExc_OverflowError,
11945 "can't convert negative value to size_t");
11946 return (size_t) -1;
11947 }
11948
11949 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)11950 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
11951 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
11952 const int is_unsigned = neg_one > const_zero;
11953 #if PY_MAJOR_VERSION < 3
11954 if (likely(PyInt_Check(x))) {
11955 if (sizeof(long) < sizeof(long)) {
11956 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
11957 } else {
11958 long val = PyInt_AS_LONG(x);
11959 if (is_unsigned && unlikely(val < 0)) {
11960 goto raise_neg_overflow;
11961 }
11962 return (long) val;
11963 }
11964 } else
11965 #endif
11966 if (likely(PyLong_Check(x))) {
11967 if (is_unsigned) {
11968 #if CYTHON_USE_PYLONG_INTERNALS
11969 const digit* digits = ((PyLongObject*)x)->ob_digit;
11970 switch (Py_SIZE(x)) {
11971 case 0: return (long) 0;
11972 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
11973 case 2:
11974 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
11975 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11976 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11977 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
11978 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
11979 }
11980 }
11981 break;
11982 case 3:
11983 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
11984 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11985 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11986 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
11987 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
11988 }
11989 }
11990 break;
11991 case 4:
11992 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
11993 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11994 __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])))
11995 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
11996 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
11997 }
11998 }
11999 break;
12000 }
12001 #endif
12002 #if CYTHON_COMPILING_IN_CPYTHON
12003 if (unlikely(Py_SIZE(x) < 0)) {
12004 goto raise_neg_overflow;
12005 }
12006 #else
12007 {
12008 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
12009 if (unlikely(result < 0))
12010 return (long) -1;
12011 if (unlikely(result == 1))
12012 goto raise_neg_overflow;
12013 }
12014 #endif
12015 if (sizeof(long) <= sizeof(unsigned long)) {
12016 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
12017 #ifdef HAVE_LONG_LONG
12018 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
12019 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
12020 #endif
12021 }
12022 } else {
12023 #if CYTHON_USE_PYLONG_INTERNALS
12024 const digit* digits = ((PyLongObject*)x)->ob_digit;
12025 switch (Py_SIZE(x)) {
12026 case 0: return (long) 0;
12027 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
12028 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
12029 case -2:
12030 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
12031 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
12032 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12033 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
12034 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12035 }
12036 }
12037 break;
12038 case 2:
12039 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
12040 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
12041 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12042 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
12043 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12044 }
12045 }
12046 break;
12047 case -3:
12048 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
12049 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
12050 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12051 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
12052 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12053 }
12054 }
12055 break;
12056 case 3:
12057 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
12058 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
12059 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
12060 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
12061 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12062 }
12063 }
12064 break;
12065 case -4:
12066 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
12067 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
12068 __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])))
12069 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
12070 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12071 }
12072 }
12073 break;
12074 case 4:
12075 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
12076 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
12077 __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])))
12078 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
12079 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
12080 }
12081 }
12082 break;
12083 }
12084 #endif
12085 if (sizeof(long) <= sizeof(long)) {
12086 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
12087 #ifdef HAVE_LONG_LONG
12088 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
12089 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
12090 #endif
12091 }
12092 }
12093 {
12094 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
12095 PyErr_SetString(PyExc_RuntimeError,
12096 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
12097 #else
12098 long val;
12099 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
12100 #if PY_MAJOR_VERSION < 3
12101 if (likely(v) && !PyLong_Check(v)) {
12102 PyObject *tmp = v;
12103 v = PyNumber_Long(tmp);
12104 Py_DECREF(tmp);
12105 }
12106 #endif
12107 if (likely(v)) {
12108 int one = 1; int is_little = (int)*(unsigned char *)&one;
12109 unsigned char *bytes = (unsigned char *)&val;
12110 int ret = _PyLong_AsByteArray((PyLongObject *)v,
12111 bytes, sizeof(val),
12112 is_little, !is_unsigned);
12113 Py_DECREF(v);
12114 if (likely(!ret))
12115 return val;
12116 }
12117 #endif
12118 return (long) -1;
12119 }
12120 } else {
12121 long val;
12122 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
12123 if (!tmp) return (long) -1;
12124 val = __Pyx_PyInt_As_long(tmp);
12125 Py_DECREF(tmp);
12126 return val;
12127 }
12128 raise_overflow:
12129 PyErr_SetString(PyExc_OverflowError,
12130 "value too large to convert to long");
12131 return (long) -1;
12132 raise_neg_overflow:
12133 PyErr_SetString(PyExc_OverflowError,
12134 "can't convert negative value to long");
12135 return (long) -1;
12136 }
12137
12138 /* FastTypeChecks */
12139 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)12140 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
12141 while (a) {
12142 a = a->tp_base;
12143 if (a == b)
12144 return 1;
12145 }
12146 return b == &PyBaseObject_Type;
12147 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)12148 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
12149 PyObject *mro;
12150 if (a == b) return 1;
12151 mro = a->tp_mro;
12152 if (likely(mro)) {
12153 Py_ssize_t i, n;
12154 n = PyTuple_GET_SIZE(mro);
12155 for (i = 0; i < n; i++) {
12156 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
12157 return 1;
12158 }
12159 return 0;
12160 }
12161 return __Pyx_InBases(a, b);
12162 }
12163 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)12164 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
12165 PyObject *exception, *value, *tb;
12166 int res;
12167 __Pyx_PyThreadState_declare
12168 __Pyx_PyThreadState_assign
12169 __Pyx_ErrFetch(&exception, &value, &tb);
12170 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
12171 if (unlikely(res == -1)) {
12172 PyErr_WriteUnraisable(err);
12173 res = 0;
12174 }
12175 if (!res) {
12176 res = PyObject_IsSubclass(err, exc_type2);
12177 if (unlikely(res == -1)) {
12178 PyErr_WriteUnraisable(err);
12179 res = 0;
12180 }
12181 }
12182 __Pyx_ErrRestore(exception, value, tb);
12183 return res;
12184 }
12185 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)12186 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
12187 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
12188 if (!res) {
12189 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
12190 }
12191 return res;
12192 }
12193 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)12194 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
12195 Py_ssize_t i, n;
12196 assert(PyExceptionClass_Check(exc_type));
12197 n = PyTuple_GET_SIZE(tuple);
12198 #if PY_MAJOR_VERSION >= 3
12199 for (i=0; i<n; i++) {
12200 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
12201 }
12202 #endif
12203 for (i=0; i<n; i++) {
12204 PyObject *t = PyTuple_GET_ITEM(tuple, i);
12205 #if PY_MAJOR_VERSION < 3
12206 if (likely(exc_type == t)) return 1;
12207 #endif
12208 if (likely(PyExceptionClass_Check(t))) {
12209 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
12210 } else {
12211 }
12212 }
12213 return 0;
12214 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)12215 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
12216 if (likely(err == exc_type)) return 1;
12217 if (likely(PyExceptionClass_Check(err))) {
12218 if (likely(PyExceptionClass_Check(exc_type))) {
12219 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
12220 } else if (likely(PyTuple_Check(exc_type))) {
12221 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
12222 } else {
12223 }
12224 }
12225 return PyErr_GivenExceptionMatches(err, exc_type);
12226 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)12227 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
12228 assert(PyExceptionClass_Check(exc_type1));
12229 assert(PyExceptionClass_Check(exc_type2));
12230 if (likely(err == exc_type1 || err == exc_type2)) return 1;
12231 if (likely(PyExceptionClass_Check(err))) {
12232 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
12233 }
12234 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
12235 }
12236 #endif
12237
12238 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)12239 static int __Pyx_check_binary_version(void) {
12240 char ctversion[4], rtversion[4];
12241 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
12242 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
12243 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
12244 char message[200];
12245 PyOS_snprintf(message, sizeof(message),
12246 "compiletime version %s of module '%.100s' "
12247 "does not match runtime version %s",
12248 ctversion, __Pyx_MODULE_NAME, rtversion);
12249 return PyErr_WarnEx(NULL, message, 1);
12250 }
12251 return 0;
12252 }
12253
12254 /* FunctionExport */
__Pyx_ExportFunction(const char * name,void (* f)(void),const char * sig)12255 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
12256 PyObject *d = 0;
12257 PyObject *cobj = 0;
12258 union {
12259 void (*fp)(void);
12260 void *p;
12261 } tmp;
12262 d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
12263 if (!d) {
12264 PyErr_Clear();
12265 d = PyDict_New();
12266 if (!d)
12267 goto bad;
12268 Py_INCREF(d);
12269 if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
12270 goto bad;
12271 }
12272 tmp.fp = f;
12273 #if PY_VERSION_HEX >= 0x02070000
12274 cobj = PyCapsule_New(tmp.p, sig, 0);
12275 #else
12276 cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
12277 #endif
12278 if (!cobj)
12279 goto bad;
12280 if (PyDict_SetItemString(d, name, cobj) < 0)
12281 goto bad;
12282 Py_DECREF(cobj);
12283 Py_DECREF(d);
12284 return 0;
12285 bad:
12286 Py_XDECREF(cobj);
12287 Py_XDECREF(d);
12288 return -1;
12289 }
12290
12291 /* VoidPtrImport */
12292 #ifndef __PYX_HAVE_RT_ImportVoidPtr
12293 #define __PYX_HAVE_RT_ImportVoidPtr
__Pyx_ImportVoidPtr(PyObject * module,const char * name,void ** p,const char * sig)12294 static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
12295 PyObject *d = 0;
12296 PyObject *cobj = 0;
12297 d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
12298 if (!d)
12299 goto bad;
12300 cobj = PyDict_GetItemString(d, name);
12301 if (!cobj) {
12302 PyErr_Format(PyExc_ImportError,
12303 "%.200s does not export expected C variable %.200s",
12304 PyModule_GetName(module), name);
12305 goto bad;
12306 }
12307 #if PY_VERSION_HEX >= 0x02070000
12308 if (!PyCapsule_IsValid(cobj, sig)) {
12309 PyErr_Format(PyExc_TypeError,
12310 "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
12311 PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
12312 goto bad;
12313 }
12314 *p = PyCapsule_GetPointer(cobj, sig);
12315 #else
12316 {const char *desc, *s1, *s2;
12317 desc = (const char *)PyCObject_GetDesc(cobj);
12318 if (!desc)
12319 goto bad;
12320 s1 = desc; s2 = sig;
12321 while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
12322 if (*s1 != *s2) {
12323 PyErr_Format(PyExc_TypeError,
12324 "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
12325 PyModule_GetName(module), name, sig, desc);
12326 goto bad;
12327 }
12328 *p = PyCObject_AsVoidPtr(cobj);}
12329 #endif
12330 if (!(*p))
12331 goto bad;
12332 Py_DECREF(d);
12333 return 0;
12334 bad:
12335 Py_XDECREF(d);
12336 return -1;
12337 }
12338 #endif
12339
12340 /* FunctionImport */
12341 #ifndef __PYX_HAVE_RT_ImportFunction
12342 #define __PYX_HAVE_RT_ImportFunction
__Pyx_ImportFunction(PyObject * module,const char * funcname,void (** f)(void),const char * sig)12343 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
12344 PyObject *d = 0;
12345 PyObject *cobj = 0;
12346 union {
12347 void (*fp)(void);
12348 void *p;
12349 } tmp;
12350 d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
12351 if (!d)
12352 goto bad;
12353 cobj = PyDict_GetItemString(d, funcname);
12354 if (!cobj) {
12355 PyErr_Format(PyExc_ImportError,
12356 "%.200s does not export expected C function %.200s",
12357 PyModule_GetName(module), funcname);
12358 goto bad;
12359 }
12360 #if PY_VERSION_HEX >= 0x02070000
12361 if (!PyCapsule_IsValid(cobj, sig)) {
12362 PyErr_Format(PyExc_TypeError,
12363 "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
12364 PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
12365 goto bad;
12366 }
12367 tmp.p = PyCapsule_GetPointer(cobj, sig);
12368 #else
12369 {const char *desc, *s1, *s2;
12370 desc = (const char *)PyCObject_GetDesc(cobj);
12371 if (!desc)
12372 goto bad;
12373 s1 = desc; s2 = sig;
12374 while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
12375 if (*s1 != *s2) {
12376 PyErr_Format(PyExc_TypeError,
12377 "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
12378 PyModule_GetName(module), funcname, sig, desc);
12379 goto bad;
12380 }
12381 tmp.p = PyCObject_AsVoidPtr(cobj);}
12382 #endif
12383 *f = tmp.fp;
12384 if (!(*f))
12385 goto bad;
12386 Py_DECREF(d);
12387 return 0;
12388 bad:
12389 Py_XDECREF(d);
12390 return -1;
12391 }
12392 #endif
12393
12394 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)12395 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
12396 while (t->p) {
12397 #if PY_MAJOR_VERSION < 3
12398 if (t->is_unicode) {
12399 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
12400 } else if (t->intern) {
12401 *t->p = PyString_InternFromString(t->s);
12402 } else {
12403 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
12404 }
12405 #else
12406 if (t->is_unicode | t->is_str) {
12407 if (t->intern) {
12408 *t->p = PyUnicode_InternFromString(t->s);
12409 } else if (t->encoding) {
12410 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
12411 } else {
12412 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
12413 }
12414 } else {
12415 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
12416 }
12417 #endif
12418 if (!*t->p)
12419 return -1;
12420 if (PyObject_Hash(*t->p) == -1)
12421 return -1;
12422 ++t;
12423 }
12424 return 0;
12425 }
12426
__Pyx_PyUnicode_FromString(const char * c_str)12427 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
12428 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
12429 }
__Pyx_PyObject_AsString(PyObject * o)12430 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
12431 Py_ssize_t ignore;
12432 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
12433 }
12434 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
12435 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)12436 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
12437 char* defenc_c;
12438 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
12439 if (!defenc) return NULL;
12440 defenc_c = PyBytes_AS_STRING(defenc);
12441 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
12442 {
12443 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
12444 char* c;
12445 for (c = defenc_c; c < end; c++) {
12446 if ((unsigned char) (*c) >= 128) {
12447 PyUnicode_AsASCIIString(o);
12448 return NULL;
12449 }
12450 }
12451 }
12452 #endif
12453 *length = PyBytes_GET_SIZE(defenc);
12454 return defenc_c;
12455 }
12456 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)12457 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
12458 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
12459 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
12460 if (likely(PyUnicode_IS_ASCII(o))) {
12461 *length = PyUnicode_GET_LENGTH(o);
12462 return PyUnicode_AsUTF8(o);
12463 } else {
12464 PyUnicode_AsASCIIString(o);
12465 return NULL;
12466 }
12467 #else
12468 return PyUnicode_AsUTF8AndSize(o, length);
12469 #endif
12470 }
12471 #endif
12472 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)12473 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
12474 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
12475 if (
12476 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
12477 __Pyx_sys_getdefaultencoding_not_ascii &&
12478 #endif
12479 PyUnicode_Check(o)) {
12480 return __Pyx_PyUnicode_AsStringAndSize(o, length);
12481 } else
12482 #endif
12483 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
12484 if (PyByteArray_Check(o)) {
12485 *length = PyByteArray_GET_SIZE(o);
12486 return PyByteArray_AS_STRING(o);
12487 } else
12488 #endif
12489 {
12490 char* result;
12491 int r = PyBytes_AsStringAndSize(o, &result, length);
12492 if (unlikely(r < 0)) {
12493 return NULL;
12494 } else {
12495 return result;
12496 }
12497 }
12498 }
__Pyx_PyObject_IsTrue(PyObject * x)12499 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
12500 int is_true = x == Py_True;
12501 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
12502 else return PyObject_IsTrue(x);
12503 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)12504 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
12505 int retval;
12506 if (unlikely(!x)) return -1;
12507 retval = __Pyx_PyObject_IsTrue(x);
12508 Py_DECREF(x);
12509 return retval;
12510 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)12511 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
12512 #if PY_MAJOR_VERSION >= 3
12513 if (PyLong_Check(result)) {
12514 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
12515 "__int__ returned non-int (type %.200s). "
12516 "The ability to return an instance of a strict subclass of int "
12517 "is deprecated, and may be removed in a future version of Python.",
12518 Py_TYPE(result)->tp_name)) {
12519 Py_DECREF(result);
12520 return NULL;
12521 }
12522 return result;
12523 }
12524 #endif
12525 PyErr_Format(PyExc_TypeError,
12526 "__%.4s__ returned non-%.4s (type %.200s)",
12527 type_name, type_name, Py_TYPE(result)->tp_name);
12528 Py_DECREF(result);
12529 return NULL;
12530 }
__Pyx_PyNumber_IntOrLong(PyObject * x)12531 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
12532 #if CYTHON_USE_TYPE_SLOTS
12533 PyNumberMethods *m;
12534 #endif
12535 const char *name = NULL;
12536 PyObject *res = NULL;
12537 #if PY_MAJOR_VERSION < 3
12538 if (likely(PyInt_Check(x) || PyLong_Check(x)))
12539 #else
12540 if (likely(PyLong_Check(x)))
12541 #endif
12542 return __Pyx_NewRef(x);
12543 #if CYTHON_USE_TYPE_SLOTS
12544 m = Py_TYPE(x)->tp_as_number;
12545 #if PY_MAJOR_VERSION < 3
12546 if (m && m->nb_int) {
12547 name = "int";
12548 res = m->nb_int(x);
12549 }
12550 else if (m && m->nb_long) {
12551 name = "long";
12552 res = m->nb_long(x);
12553 }
12554 #else
12555 if (likely(m && m->nb_int)) {
12556 name = "int";
12557 res = m->nb_int(x);
12558 }
12559 #endif
12560 #else
12561 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
12562 res = PyNumber_Int(x);
12563 }
12564 #endif
12565 if (likely(res)) {
12566 #if PY_MAJOR_VERSION < 3
12567 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
12568 #else
12569 if (unlikely(!PyLong_CheckExact(res))) {
12570 #endif
12571 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
12572 }
12573 }
12574 else if (!PyErr_Occurred()) {
12575 PyErr_SetString(PyExc_TypeError,
12576 "an integer is required");
12577 }
12578 return res;
12579 }
12580 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
12581 Py_ssize_t ival;
12582 PyObject *x;
12583 #if PY_MAJOR_VERSION < 3
12584 if (likely(PyInt_CheckExact(b))) {
12585 if (sizeof(Py_ssize_t) >= sizeof(long))
12586 return PyInt_AS_LONG(b);
12587 else
12588 return PyInt_AsSsize_t(b);
12589 }
12590 #endif
12591 if (likely(PyLong_CheckExact(b))) {
12592 #if CYTHON_USE_PYLONG_INTERNALS
12593 const digit* digits = ((PyLongObject*)b)->ob_digit;
12594 const Py_ssize_t size = Py_SIZE(b);
12595 if (likely(__Pyx_sst_abs(size) <= 1)) {
12596 ival = likely(size) ? digits[0] : 0;
12597 if (size == -1) ival = -ival;
12598 return ival;
12599 } else {
12600 switch (size) {
12601 case 2:
12602 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
12603 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12604 }
12605 break;
12606 case -2:
12607 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
12608 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12609 }
12610 break;
12611 case 3:
12612 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
12613 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12614 }
12615 break;
12616 case -3:
12617 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
12618 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12619 }
12620 break;
12621 case 4:
12622 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
12623 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]));
12624 }
12625 break;
12626 case -4:
12627 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
12628 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]));
12629 }
12630 break;
12631 }
12632 }
12633 #endif
12634 return PyLong_AsSsize_t(b);
12635 }
12636 x = PyNumber_Index(b);
12637 if (!x) return -1;
12638 ival = PyInt_AsSsize_t(x);
12639 Py_DECREF(x);
12640 return ival;
12641 }
12642 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
12643 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
12644 }
12645 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
12646 return PyInt_FromSize_t(ival);
12647 }
12648
12649
12650 #endif /* Py_PYTHON_H */
12651