You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6704 lines
257 KiB

4 years ago
  1. /* Generated by Cython 0.29.1 */
  2. #define PY_SSIZE_T_CLEAN
  3. #include "Python.h"
  4. #ifndef Py_PYTHON_H
  5. #error Python headers needed to compile C extensions, please install development version of Python.
  6. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
  7. #error Cython requires Python 2.6+ or Python 3.3+.
  8. #else
  9. #define CYTHON_ABI "0_29_1"
  10. #define CYTHON_HEX_VERSION 0x001D01F0
  11. #define CYTHON_FUTURE_DIVISION 0
  12. #include <stddef.h>
  13. #ifndef offsetof
  14. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  15. #endif
  16. #if !defined(WIN32) && !defined(MS_WINDOWS)
  17. #ifndef __stdcall
  18. #define __stdcall
  19. #endif
  20. #ifndef __cdecl
  21. #define __cdecl
  22. #endif
  23. #ifndef __fastcall
  24. #define __fastcall
  25. #endif
  26. #endif
  27. #ifndef DL_IMPORT
  28. #define DL_IMPORT(t) t
  29. #endif
  30. #ifndef DL_EXPORT
  31. #define DL_EXPORT(t) t
  32. #endif
  33. #define __PYX_COMMA ,
  34. #ifndef HAVE_LONG_LONG
  35. #if PY_VERSION_HEX >= 0x02070000
  36. #define HAVE_LONG_LONG
  37. #endif
  38. #endif
  39. #ifndef PY_LONG_LONG
  40. #define PY_LONG_LONG LONG_LONG
  41. #endif
  42. #ifndef Py_HUGE_VAL
  43. #define Py_HUGE_VAL HUGE_VAL
  44. #endif
  45. #ifdef PYPY_VERSION
  46. #define CYTHON_COMPILING_IN_PYPY 1
  47. #define CYTHON_COMPILING_IN_PYSTON 0
  48. #define CYTHON_COMPILING_IN_CPYTHON 0
  49. #undef CYTHON_USE_TYPE_SLOTS
  50. #define CYTHON_USE_TYPE_SLOTS 0
  51. #undef CYTHON_USE_PYTYPE_LOOKUP
  52. #define CYTHON_USE_PYTYPE_LOOKUP 0
  53. #if PY_VERSION_HEX < 0x03050000
  54. #undef CYTHON_USE_ASYNC_SLOTS
  55. #define CYTHON_USE_ASYNC_SLOTS 0
  56. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  57. #define CYTHON_USE_ASYNC_SLOTS 1
  58. #endif
  59. #undef CYTHON_USE_PYLIST_INTERNALS
  60. #define CYTHON_USE_PYLIST_INTERNALS 0
  61. #undef CYTHON_USE_UNICODE_INTERNALS
  62. #define CYTHON_USE_UNICODE_INTERNALS 0
  63. #undef CYTHON_USE_UNICODE_WRITER
  64. #define CYTHON_USE_UNICODE_WRITER 0
  65. #undef CYTHON_USE_PYLONG_INTERNALS
  66. #define CYTHON_USE_PYLONG_INTERNALS 0
  67. #undef CYTHON_AVOID_BORROWED_REFS
  68. #define CYTHON_AVOID_BORROWED_REFS 1
  69. #undef CYTHON_ASSUME_SAFE_MACROS
  70. #define CYTHON_ASSUME_SAFE_MACROS 0
  71. #undef CYTHON_UNPACK_METHODS
  72. #define CYTHON_UNPACK_METHODS 0
  73. #undef CYTHON_FAST_THREAD_STATE
  74. #define CYTHON_FAST_THREAD_STATE 0
  75. #undef CYTHON_FAST_PYCALL
  76. #define CYTHON_FAST_PYCALL 0
  77. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  78. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  79. #undef CYTHON_USE_TP_FINALIZE
  80. #define CYTHON_USE_TP_FINALIZE 0
  81. #undef CYTHON_USE_DICT_VERSIONS
  82. #define CYTHON_USE_DICT_VERSIONS 0
  83. #undef CYTHON_USE_EXC_INFO_STACK
  84. #define CYTHON_USE_EXC_INFO_STACK 0
  85. #elif defined(PYSTON_VERSION)
  86. #define CYTHON_COMPILING_IN_PYPY 0
  87. #define CYTHON_COMPILING_IN_PYSTON 1
  88. #define CYTHON_COMPILING_IN_CPYTHON 0
  89. #ifndef CYTHON_USE_TYPE_SLOTS
  90. #define CYTHON_USE_TYPE_SLOTS 1
  91. #endif
  92. #undef CYTHON_USE_PYTYPE_LOOKUP
  93. #define CYTHON_USE_PYTYPE_LOOKUP 0
  94. #undef CYTHON_USE_ASYNC_SLOTS
  95. #define CYTHON_USE_ASYNC_SLOTS 0
  96. #undef CYTHON_USE_PYLIST_INTERNALS
  97. #define CYTHON_USE_PYLIST_INTERNALS 0
  98. #ifndef CYTHON_USE_UNICODE_INTERNALS
  99. #define CYTHON_USE_UNICODE_INTERNALS 1
  100. #endif
  101. #undef CYTHON_USE_UNICODE_WRITER
  102. #define CYTHON_USE_UNICODE_WRITER 0
  103. #undef CYTHON_USE_PYLONG_INTERNALS
  104. #define CYTHON_USE_PYLONG_INTERNALS 0
  105. #ifndef CYTHON_AVOID_BORROWED_REFS
  106. #define CYTHON_AVOID_BORROWED_REFS 0
  107. #endif
  108. #ifndef CYTHON_ASSUME_SAFE_MACROS
  109. #define CYTHON_ASSUME_SAFE_MACROS 1
  110. #endif
  111. #ifndef CYTHON_UNPACK_METHODS
  112. #define CYTHON_UNPACK_METHODS 1
  113. #endif
  114. #undef CYTHON_FAST_THREAD_STATE
  115. #define CYTHON_FAST_THREAD_STATE 0
  116. #undef CYTHON_FAST_PYCALL
  117. #define CYTHON_FAST_PYCALL 0
  118. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  119. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  120. #undef CYTHON_USE_TP_FINALIZE
  121. #define CYTHON_USE_TP_FINALIZE 0
  122. #undef CYTHON_USE_DICT_VERSIONS
  123. #define CYTHON_USE_DICT_VERSIONS 0
  124. #undef CYTHON_USE_EXC_INFO_STACK
  125. #define CYTHON_USE_EXC_INFO_STACK 0
  126. #else
  127. #define CYTHON_COMPILING_IN_PYPY 0
  128. #define CYTHON_COMPILING_IN_PYSTON 0
  129. #define CYTHON_COMPILING_IN_CPYTHON 1
  130. #ifndef CYTHON_USE_TYPE_SLOTS
  131. #define CYTHON_USE_TYPE_SLOTS 1
  132. #endif
  133. #if PY_VERSION_HEX < 0x02070000
  134. #undef CYTHON_USE_PYTYPE_LOOKUP
  135. #define CYTHON_USE_PYTYPE_LOOKUP 0
  136. #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
  137. #define CYTHON_USE_PYTYPE_LOOKUP 1
  138. #endif
  139. #if PY_MAJOR_VERSION < 3
  140. #undef CYTHON_USE_ASYNC_SLOTS
  141. #define CYTHON_USE_ASYNC_SLOTS 0
  142. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  143. #define CYTHON_USE_ASYNC_SLOTS 1
  144. #endif
  145. #if PY_VERSION_HEX < 0x02070000
  146. #undef CYTHON_USE_PYLONG_INTERNALS
  147. #define CYTHON_USE_PYLONG_INTERNALS 0
  148. #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
  149. #define CYTHON_USE_PYLONG_INTERNALS 1
  150. #endif
  151. #ifndef CYTHON_USE_PYLIST_INTERNALS
  152. #define CYTHON_USE_PYLIST_INTERNALS 1
  153. #endif
  154. #ifndef CYTHON_USE_UNICODE_INTERNALS
  155. #define CYTHON_USE_UNICODE_INTERNALS 1
  156. #endif
  157. #if PY_VERSION_HEX < 0x030300F0
  158. #undef CYTHON_USE_UNICODE_WRITER
  159. #define CYTHON_USE_UNICODE_WRITER 0
  160. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  161. #define CYTHON_USE_UNICODE_WRITER 1
  162. #endif
  163. #ifndef CYTHON_AVOID_BORROWED_REFS
  164. #define CYTHON_AVOID_BORROWED_REFS 0
  165. #endif
  166. #ifndef CYTHON_ASSUME_SAFE_MACROS
  167. #define CYTHON_ASSUME_SAFE_MACROS 1
  168. #endif
  169. #ifndef CYTHON_UNPACK_METHODS
  170. #define CYTHON_UNPACK_METHODS 1
  171. #endif
  172. #ifndef CYTHON_FAST_THREAD_STATE
  173. #define CYTHON_FAST_THREAD_STATE 1
  174. #endif
  175. #ifndef CYTHON_FAST_PYCALL
  176. #define CYTHON_FAST_PYCALL 1
  177. #endif
  178. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  179. #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  180. #endif
  181. #ifndef CYTHON_USE_TP_FINALIZE
  182. #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  183. #endif
  184. #ifndef CYTHON_USE_DICT_VERSIONS
  185. #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  186. #endif
  187. #ifndef CYTHON_USE_EXC_INFO_STACK
  188. #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  189. #endif
  190. #endif
  191. #if !defined(CYTHON_FAST_PYCCALL)
  192. #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
  193. #endif
  194. #if CYTHON_USE_PYLONG_INTERNALS
  195. #include "longintrepr.h"
  196. #undef SHIFT
  197. #undef BASE
  198. #undef MASK
  199. #ifdef SIZEOF_VOID_P
  200. enum { __pyx_check_sizeof_voidp = 1/(SIZEOF_VOID_P == sizeof(void*)) };
  201. #endif
  202. #endif
  203. #ifndef __has_attribute
  204. #define __has_attribute(x) 0
  205. #endif
  206. #ifndef __has_cpp_attribute
  207. #define __has_cpp_attribute(x) 0
  208. #endif
  209. #ifndef CYTHON_RESTRICT
  210. #if defined(__GNUC__)
  211. #define CYTHON_RESTRICT __restrict__
  212. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  213. #define CYTHON_RESTRICT __restrict
  214. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  215. #define CYTHON_RESTRICT restrict
  216. #else
  217. #define CYTHON_RESTRICT
  218. #endif
  219. #endif
  220. #ifndef CYTHON_UNUSED
  221. # if defined(__GNUC__)
  222. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  223. # define CYTHON_UNUSED __attribute__ ((__unused__))
  224. # else
  225. # define CYTHON_UNUSED
  226. # endif
  227. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  228. # define CYTHON_UNUSED __attribute__ ((__unused__))
  229. # else
  230. # define CYTHON_UNUSED
  231. # endif
  232. #endif
  233. #ifndef CYTHON_MAYBE_UNUSED_VAR
  234. # if defined(__cplusplus)
  235. template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
  236. # else
  237. # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
  238. # endif
  239. #endif
  240. #ifndef CYTHON_NCP_UNUSED
  241. # if CYTHON_COMPILING_IN_CPYTHON
  242. # define CYTHON_NCP_UNUSED
  243. # else
  244. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  245. # endif
  246. #endif
  247. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  248. #ifdef _MSC_VER
  249. #ifndef _MSC_STDINT_H_
  250. #if _MSC_VER < 1300
  251. typedef unsigned char uint8_t;
  252. typedef unsigned int uint32_t;
  253. #else
  254. typedef unsigned __int8 uint8_t;
  255. typedef unsigned __int32 uint32_t;
  256. #endif
  257. #endif
  258. #else
  259. #include <stdint.h>
  260. #endif
  261. #ifndef CYTHON_FALLTHROUGH
  262. #if defined(__cplusplus) && __cplusplus >= 201103L
  263. #if __has_cpp_attribute(fallthrough)
  264. #define CYTHON_FALLTHROUGH [[fallthrough]]
  265. #elif __has_cpp_attribute(clang::fallthrough)
  266. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  267. #elif __has_cpp_attribute(gnu::fallthrough)
  268. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  269. #endif
  270. #endif
  271. #ifndef CYTHON_FALLTHROUGH
  272. #if __has_attribute(fallthrough)
  273. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  274. #else
  275. #define CYTHON_FALLTHROUGH
  276. #endif
  277. #endif
  278. #if defined(__clang__ ) && defined(__apple_build_version__)
  279. #if __apple_build_version__ < 7000000
  280. #undef CYTHON_FALLTHROUGH
  281. #define CYTHON_FALLTHROUGH
  282. #endif
  283. #endif
  284. #endif
  285. #ifndef __cplusplus
  286. #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
  287. #endif
  288. #ifndef CYTHON_INLINE
  289. #if defined(__clang__)
  290. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  291. #else
  292. #define CYTHON_INLINE inline
  293. #endif
  294. #endif
  295. template<typename T>
  296. void __Pyx_call_destructor(T& x) {
  297. x.~T();
  298. }
  299. template<typename T>
  300. class __Pyx_FakeReference {
  301. public:
  302. __Pyx_FakeReference() : ptr(NULL) { }
  303. __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
  304. T *operator->() { return ptr; }
  305. T *operator&() { return ptr; }
  306. operator T&() { return *ptr; }
  307. template<typename U> bool operator ==(U other) { return *ptr == other; }
  308. template<typename U> bool operator !=(U other) { return *ptr != other; }
  309. private:
  310. T *ptr;
  311. };
  312. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  313. #define Py_OptimizeFlag 0
  314. #endif
  315. #define __PYX_BUILD_PY_SSIZE_T "n"
  316. #define CYTHON_FORMAT_SSIZE_T "z"
  317. #if PY_MAJOR_VERSION < 3
  318. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  319. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  320. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  321. #define __Pyx_DefaultClassType PyClass_Type
  322. #else
  323. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  324. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  325. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  326. #define __Pyx_DefaultClassType PyType_Type
  327. #endif
  328. #ifndef Py_TPFLAGS_CHECKTYPES
  329. #define Py_TPFLAGS_CHECKTYPES 0
  330. #endif
  331. #ifndef Py_TPFLAGS_HAVE_INDEX
  332. #define Py_TPFLAGS_HAVE_INDEX 0
  333. #endif
  334. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  335. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  336. #endif
  337. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  338. #define Py_TPFLAGS_HAVE_FINALIZE 0
  339. #endif
  340. #ifndef METH_STACKLESS
  341. #define METH_STACKLESS 0
  342. #endif
  343. #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  344. #ifndef METH_FASTCALL
  345. #define METH_FASTCALL 0x80
  346. #endif
  347. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  348. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  349. Py_ssize_t nargs, PyObject *kwnames);
  350. #else
  351. #define __Pyx_PyCFunctionFast _PyCFunctionFast
  352. #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  353. #endif
  354. #if CYTHON_FAST_PYCCALL
  355. #define __Pyx_PyFastCFunction_Check(func)\
  356. ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
  357. #else
  358. #define __Pyx_PyFastCFunction_Check(func) 0
  359. #endif
  360. #if CYTHON_USE_DICT_VERSIONS
  361. #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
  362. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
  363. (version_var) = __PYX_GET_DICT_VERSION(dict);\
  364. (cache_var) = (value);
  365. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
  366. static PY_UINT64_T __pyx_dict_version = 0;\
  367. static PyObject *__pyx_dict_cached_value = NULL;\
  368. if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
  369. (VAR) = __pyx_dict_cached_value;\
  370. } else {\
  371. (VAR) = __pyx_dict_cached_value = (LOOKUP);\
  372. __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
  373. }\
  374. }
  375. #else
  376. #define __PYX_GET_DICT_VERSION(dict) (0)
  377. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
  378. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
  379. #endif
  380. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  381. #define PyObject_Malloc(s) PyMem_Malloc(s)
  382. #define PyObject_Free(p) PyMem_Free(p)
  383. #define PyObject_Realloc(p) PyMem_Realloc(p)
  384. #endif
  385. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  386. #define PyMem_RawMalloc(n) PyMem_Malloc(n)
  387. #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
  388. #define PyMem_RawFree(p) PyMem_Free(p)
  389. #endif
  390. #if CYTHON_COMPILING_IN_PYSTON
  391. #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
  392. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
  393. #else
  394. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  395. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  396. #endif
  397. #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  398. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  399. #elif PY_VERSION_HEX >= 0x03060000
  400. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  401. #elif PY_VERSION_HEX >= 0x03000000
  402. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  403. #else
  404. #define __Pyx_PyThreadState_Current _PyThreadState_Current
  405. #endif
  406. #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
  407. #include "pythread.h"
  408. #define Py_tss_NEEDS_INIT 0
  409. typedef int Py_tss_t;
  410. static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  411. *key = PyThread_create_key();
  412. return 0; // PyThread_create_key reports success always
  413. }
  414. static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  415. Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  416. *key = Py_tss_NEEDS_INIT;
  417. return key;
  418. }
  419. static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  420. PyObject_Free(key);
  421. }
  422. static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  423. return *key != Py_tss_NEEDS_INIT;
  424. }
  425. static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  426. PyThread_delete_key(*key);
  427. *key = Py_tss_NEEDS_INIT;
  428. }
  429. static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  430. return PyThread_set_key_value(*key, value);
  431. }
  432. static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  433. return PyThread_get_key_value(*key);
  434. }
  435. #endif // TSS (Thread Specific Storage) API
  436. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  437. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  438. #else
  439. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  440. #endif
  441. #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  442. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  443. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  444. #else
  445. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  446. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  447. #endif
  448. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
  449. #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  450. #else
  451. #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
  452. #endif
  453. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  454. #define CYTHON_PEP393_ENABLED 1
  455. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  456. 0 : _PyUnicode_Ready((PyObject *)(op)))
  457. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  458. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  459. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  460. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  461. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  462. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  463. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
  464. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  465. #else
  466. #define CYTHON_PEP393_ENABLED 0
  467. #define PyUnicode_1BYTE_KIND 1
  468. #define PyUnicode_2BYTE_KIND 2
  469. #define PyUnicode_4BYTE_KIND 4
  470. #define __Pyx_PyUnicode_READY(op) (0)
  471. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  472. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  473. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  474. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  475. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  476. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  477. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  478. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  479. #endif
  480. #if CYTHON_COMPILING_IN_PYPY
  481. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  482. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  483. #else
  484. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  485. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  486. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  487. #endif
  488. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  489. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  490. #endif
  491. #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  492. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  493. #endif
  494. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  495. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  496. #endif
  497. #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))
  498. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  499. #if PY_MAJOR_VERSION >= 3
  500. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  501. #else
  502. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  503. #endif
  504. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  505. #define PyObject_ASCII(o) PyObject_Repr(o)
  506. #endif
  507. #if PY_MAJOR_VERSION >= 3
  508. #define PyBaseString_Type PyUnicode_Type
  509. #define PyStringObject PyUnicodeObject
  510. #define PyString_Type PyUnicode_Type
  511. #define PyString_Check PyUnicode_Check
  512. #define PyString_CheckExact PyUnicode_CheckExact
  513. #define PyObject_Unicode PyObject_Str
  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 CYTHON_ASSUME_SAFE_MACROS
  526. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  527. #else
  528. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  529. #endif
  530. #if PY_MAJOR_VERSION >= 3
  531. #define PyIntObject PyLongObject
  532. #define PyInt_Type PyLong_Type
  533. #define PyInt_Check(op) PyLong_Check(op)
  534. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  535. #define PyInt_FromString PyLong_FromString
  536. #define PyInt_FromUnicode PyLong_FromUnicode
  537. #define PyInt_FromLong PyLong_FromLong
  538. #define PyInt_FromSize_t PyLong_FromSize_t
  539. #define PyInt_FromSsize_t PyLong_FromSsize_t
  540. #define PyInt_AsLong PyLong_AsLong
  541. #define PyInt_AS_LONG PyLong_AS_LONG
  542. #define PyInt_AsSsize_t PyLong_AsSsize_t
  543. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  544. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  545. #define PyNumber_Int PyNumber_Long
  546. #endif
  547. #if PY_MAJOR_VERSION >= 3
  548. #define PyBoolObject PyLongObject
  549. #endif
  550. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  551. #ifndef PyUnicode_InternFromString
  552. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  553. #endif
  554. #endif
  555. #if PY_VERSION_HEX < 0x030200A4
  556. typedef long Py_hash_t;
  557. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  558. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  559. #else
  560. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  561. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  562. #endif
  563. #if PY_MAJOR_VERSION >= 3
  564. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
  565. #else
  566. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  567. #endif
  568. #if CYTHON_USE_ASYNC_SLOTS
  569. #if PY_VERSION_HEX >= 0x030500B1
  570. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  571. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  572. #else
  573. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  574. #endif
  575. #else
  576. #define __Pyx_PyType_AsAsync(obj) NULL
  577. #endif
  578. #ifndef __Pyx_PyAsyncMethodsStruct
  579. typedef struct {
  580. unaryfunc am_await;
  581. unaryfunc am_aiter;
  582. unaryfunc am_anext;
  583. } __Pyx_PyAsyncMethodsStruct;
  584. #endif
  585. #if defined(WIN32) || defined(MS_WINDOWS)
  586. #define _USE_MATH_DEFINES
  587. #endif
  588. #include <math.h>
  589. #ifdef NAN
  590. #define __PYX_NAN() ((float) NAN)
  591. #else
  592. static CYTHON_INLINE float __PYX_NAN() {
  593. float value;
  594. memset(&value, 0xFF, sizeof(value));
  595. return value;
  596. }
  597. #endif
  598. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  599. #define __Pyx_truncl trunc
  600. #else
  601. #define __Pyx_truncl truncl
  602. #endif
  603. #define __PYX_ERR(f_index, lineno, Ln_error) \
  604. { \
  605. __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
  606. }
  607. #ifndef __PYX_EXTERN_C
  608. #ifdef __cplusplus
  609. #define __PYX_EXTERN_C extern "C"
  610. #else
  611. #define __PYX_EXTERN_C extern
  612. #endif
  613. #endif
  614. #define __PYX_HAVE__thinc__linalg
  615. #define __PYX_HAVE_API__thinc__linalg
  616. /* Early includes */
  617. #include <stdint.h>
  618. #include <string.h>
  619. #include "math.h"
  620. #ifdef _OPENMP
  621. #include <omp.h>
  622. #endif /* _OPENMP */
  623. #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
  624. #define CYTHON_WITHOUT_ASSERTIONS
  625. #endif
  626. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  627. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  628. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  629. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  630. #define __PYX_DEFAULT_STRING_ENCODING ""
  631. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  632. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  633. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  634. #define __Pyx_long_cast(x) ((long)x)
  635. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  636. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  637. (sizeof(type) > sizeof(Py_ssize_t) &&\
  638. likely(v < (type)PY_SSIZE_T_MAX ||\
  639. v == (type)PY_SSIZE_T_MAX) &&\
  640. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  641. v == (type)PY_SSIZE_T_MIN))) ||\
  642. (sizeof(type) == sizeof(Py_ssize_t) &&\
  643. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  644. v == (type)PY_SSIZE_T_MAX))) )
  645. static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
  646. return (size_t) i < (size_t) limit;
  647. }
  648. #if defined (__cplusplus) && __cplusplus >= 201103L
  649. #include <cstdlib>
  650. #define __Pyx_sst_abs(value) std::abs(value)
  651. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  652. #define __Pyx_sst_abs(value) abs(value)
  653. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  654. #define __Pyx_sst_abs(value) labs(value)
  655. #elif defined (_MSC_VER)
  656. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  657. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  658. #define __Pyx_sst_abs(value) llabs(value)
  659. #elif defined (__GNUC__)
  660. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  661. #else
  662. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  663. #endif
  664. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  665. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  666. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  667. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  668. #define __Pyx_PyBytes_FromString PyBytes_FromString
  669. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  670. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  671. #if PY_MAJOR_VERSION < 3
  672. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  673. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  674. #else
  675. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  676. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  677. #endif
  678. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  679. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  680. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  681. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  682. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  683. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  684. #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
  685. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  686. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  687. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  688. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  689. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  690. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  691. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  692. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  693. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  694. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
  695. const Py_UNICODE *u_end = u;
  696. while (*u_end++) ;
  697. return (size_t)(u_end - u - 1);
  698. }
  699. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  700. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  701. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  702. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  703. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  704. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  705. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  706. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
  707. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  708. #define __Pyx_PySequence_Tuple(obj)\
  709. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  710. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  711. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  712. #if CYTHON_ASSUME_SAFE_MACROS
  713. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  714. #else
  715. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  716. #endif
  717. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  718. #if PY_MAJOR_VERSION >= 3
  719. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  720. #else
  721. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  722. #endif
  723. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  724. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  725. static int __Pyx_sys_getdefaultencoding_not_ascii;
  726. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  727. PyObject* sys;
  728. PyObject* default_encoding = NULL;
  729. PyObject* ascii_chars_u = NULL;
  730. PyObject* ascii_chars_b = NULL;
  731. const char* default_encoding_c;
  732. sys = PyImport_ImportModule("sys");
  733. if (!sys) goto bad;
  734. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  735. Py_DECREF(sys);
  736. if (!default_encoding) goto bad;
  737. default_encoding_c = PyBytes_AsString(default_encoding);
  738. if (!default_encoding_c) goto bad;
  739. if (strcmp(default_encoding_c, "ascii") == 0) {
  740. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  741. } else {
  742. char ascii_chars[128];
  743. int c;
  744. for (c = 0; c < 128; c++) {
  745. ascii_chars[c] = c;
  746. }
  747. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  748. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  749. if (!ascii_chars_u) goto bad;
  750. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  751. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  752. PyErr_Format(
  753. PyExc_ValueError,
  754. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  755. default_encoding_c);
  756. goto bad;
  757. }
  758. Py_DECREF(ascii_chars_u);
  759. Py_DECREF(ascii_chars_b);
  760. }
  761. Py_DECREF(default_encoding);
  762. return 0;
  763. bad:
  764. Py_XDECREF(default_encoding);
  765. Py_XDECREF(ascii_chars_u);
  766. Py_XDECREF(ascii_chars_b);
  767. return -1;
  768. }
  769. #endif
  770. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  771. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  772. #else
  773. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  774. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  775. static char* __PYX_DEFAULT_STRING_ENCODING;
  776. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  777. PyObject* sys;
  778. PyObject* default_encoding = NULL;
  779. char* default_encoding_c;
  780. sys = PyImport_ImportModule("sys");
  781. if (!sys) goto bad;
  782. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  783. Py_DECREF(sys);
  784. if (!default_encoding) goto bad;
  785. default_encoding_c = PyBytes_AsString(default_encoding);
  786. if (!default_encoding_c) goto bad;
  787. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
  788. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  789. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  790. Py_DECREF(default_encoding);
  791. return 0;
  792. bad:
  793. Py_XDECREF(default_encoding);
  794. return -1;
  795. }
  796. #endif
  797. #endif
  798. /* Test for GCC > 2.95 */
  799. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  800. #define likely(x) __builtin_expect(!!(x), 1)
  801. #define unlikely(x) __builtin_expect(!!(x), 0)
  802. #else /* !__GNUC__ or GCC < 2.95 */
  803. #define likely(x) (x)
  804. #define unlikely(x) (x)
  805. #endif /* __GNUC__ */
  806. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  807. static PyObject *__pyx_m = NULL;
  808. static PyObject *__pyx_d;
  809. static PyObject *__pyx_b;
  810. static PyObject *__pyx_cython_runtime = NULL;
  811. static PyObject *__pyx_empty_tuple;
  812. static PyObject *__pyx_empty_bytes;
  813. static PyObject *__pyx_empty_unicode;
  814. static int __pyx_lineno;
  815. static int __pyx_clineno = 0;
  816. static const char * __pyx_cfilenm= __FILE__;
  817. static const char *__pyx_filename;
  818. static const char *__pyx_f[] = {
  819. "linalg.pxd",
  820. "linalg.pyx",
  821. "cymem.pxd",
  822. };
  823. /* "typedefs.pxd":7
  824. *
  825. *
  826. * ctypedef float weight_t # <<<<<<<<<<<<<<
  827. * ctypedef uint64_t atom_t
  828. * ctypedef uint64_t feat_t
  829. */
  830. typedef float __pyx_t_5thinc_8typedefs_weight_t;
  831. /* "typedefs.pxd":8
  832. *
  833. * ctypedef float weight_t
  834. * ctypedef uint64_t atom_t # <<<<<<<<<<<<<<
  835. * ctypedef uint64_t feat_t
  836. * ctypedef uint64_t hash_t
  837. */
  838. typedef uint64_t __pyx_t_5thinc_8typedefs_atom_t;
  839. /* "typedefs.pxd":9
  840. * ctypedef float weight_t
  841. * ctypedef uint64_t atom_t
  842. * ctypedef uint64_t feat_t # <<<<<<<<<<<<<<
  843. * ctypedef uint64_t hash_t
  844. * ctypedef int32_t class_t
  845. */
  846. typedef uint64_t __pyx_t_5thinc_8typedefs_feat_t;
  847. /* "typedefs.pxd":10
  848. * ctypedef uint64_t atom_t
  849. * ctypedef uint64_t feat_t
  850. * ctypedef uint64_t hash_t # <<<<<<<<<<<<<<
  851. * ctypedef int32_t class_t
  852. * ctypedef uint32_t count_t
  853. */
  854. typedef uint64_t __pyx_t_5thinc_8typedefs_hash_t;
  855. /* "typedefs.pxd":11
  856. * ctypedef uint64_t feat_t
  857. * ctypedef uint64_t hash_t
  858. * ctypedef int32_t class_t # <<<<<<<<<<<<<<
  859. * ctypedef uint32_t count_t
  860. * ctypedef uint32_t time_t
  861. */
  862. typedef int32_t __pyx_t_5thinc_8typedefs_class_t;
  863. /* "typedefs.pxd":12
  864. * ctypedef uint64_t hash_t
  865. * ctypedef int32_t class_t
  866. * ctypedef uint32_t count_t # <<<<<<<<<<<<<<
  867. * ctypedef uint32_t time_t
  868. * ctypedef int32_t len_t
  869. */
  870. typedef uint32_t __pyx_t_5thinc_8typedefs_count_t;
  871. /* "typedefs.pxd":13
  872. * ctypedef int32_t class_t
  873. * ctypedef uint32_t count_t
  874. * ctypedef uint32_t time_t # <<<<<<<<<<<<<<
  875. * ctypedef int32_t len_t
  876. * ctypedef int32_t idx_t
  877. */
  878. typedef uint32_t __pyx_t_5thinc_8typedefs_time_t;
  879. /* "typedefs.pxd":14
  880. * ctypedef uint32_t count_t
  881. * ctypedef uint32_t time_t
  882. * ctypedef int32_t len_t # <<<<<<<<<<<<<<
  883. * ctypedef int32_t idx_t
  884. *
  885. */
  886. typedef int32_t __pyx_t_5thinc_8typedefs_len_t;
  887. /* "typedefs.pxd":15
  888. * ctypedef uint32_t time_t
  889. * ctypedef int32_t len_t
  890. * ctypedef int32_t idx_t # <<<<<<<<<<<<<<
  891. *
  892. *
  893. */
  894. typedef int32_t __pyx_t_5thinc_8typedefs_idx_t;
  895. /*--- Type declarations ---*/
  896. struct __pyx_obj_5cymem_5cymem_PyMalloc;
  897. struct __pyx_obj_5cymem_5cymem_PyFree;
  898. struct __pyx_obj_5cymem_5cymem_Pool;
  899. struct __pyx_obj_5cymem_5cymem_Address;
  900. struct __pyx_obj_5thinc_6linalg_Matrix;
  901. struct __pyx_obj_5thinc_6linalg_Vec;
  902. struct __pyx_obj_5thinc_6linalg_VecVec;
  903. struct __pyx_obj_5thinc_6linalg_Mat;
  904. struct __pyx_obj_5thinc_6linalg_MatVec;
  905. struct __pyx_obj_5thinc_6linalg_MatMat;
  906. /* "cymem/cymem.pxd":1
  907. * ctypedef void* (*malloc_t)(size_t n) # <<<<<<<<<<<<<<
  908. * ctypedef void (*free_t)(void *p)
  909. *
  910. */
  911. typedef void *(*__pyx_t_5cymem_5cymem_malloc_t)(size_t);
  912. /* "cymem/cymem.pxd":2
  913. * ctypedef void* (*malloc_t)(size_t n)
  914. * ctypedef void (*free_t)(void *p) # <<<<<<<<<<<<<<
  915. *
  916. * cdef class PyMalloc:
  917. */
  918. typedef void (*__pyx_t_5cymem_5cymem_free_t)(void *);
  919. /* "cymem/cymem.pxd":4
  920. * ctypedef void (*free_t)(void *p)
  921. *
  922. * cdef class PyMalloc: # <<<<<<<<<<<<<<
  923. * cdef malloc_t malloc
  924. * cdef void _set(self, malloc_t malloc)
  925. */
  926. struct __pyx_obj_5cymem_5cymem_PyMalloc {
  927. PyObject_HEAD
  928. struct __pyx_vtabstruct_5cymem_5cymem_PyMalloc *__pyx_vtab;
  929. __pyx_t_5cymem_5cymem_malloc_t malloc;
  930. };
  931. /* "cymem/cymem.pxd":10
  932. * cdef PyMalloc WrapMalloc(malloc_t malloc)
  933. *
  934. * cdef class PyFree: # <<<<<<<<<<<<<<
  935. * cdef free_t free
  936. * cdef void _set(self, free_t free)
  937. */
  938. struct __pyx_obj_5cymem_5cymem_PyFree {
  939. PyObject_HEAD
  940. struct __pyx_vtabstruct_5cymem_5cymem_PyFree *__pyx_vtab;
  941. __pyx_t_5cymem_5cymem_free_t free;
  942. };
  943. /* "cymem/cymem.pxd":16
  944. * cdef PyFree WrapFree(free_t free)
  945. *
  946. * cdef class Pool: # <<<<<<<<<<<<<<
  947. * cdef readonly size_t size
  948. * cdef readonly dict addresses
  949. */
  950. struct __pyx_obj_5cymem_5cymem_Pool {
  951. PyObject_HEAD
  952. struct __pyx_vtabstruct_5cymem_5cymem_Pool *__pyx_vtab;
  953. size_t size;
  954. PyObject *addresses;
  955. PyObject *refs;
  956. struct __pyx_obj_5cymem_5cymem_PyMalloc *pymalloc;
  957. struct __pyx_obj_5cymem_5cymem_PyFree *pyfree;
  958. };
  959. /* "cymem/cymem.pxd":28
  960. *
  961. *
  962. * cdef class Address: # <<<<<<<<<<<<<<
  963. * cdef void* ptr
  964. * cdef readonly PyMalloc pymalloc
  965. */
  966. struct __pyx_obj_5cymem_5cymem_Address {
  967. PyObject_HEAD
  968. void *ptr;
  969. struct __pyx_obj_5cymem_5cymem_PyMalloc *pymalloc;
  970. struct __pyx_obj_5cymem_5cymem_PyFree *pyfree;
  971. };
  972. /* "thinc/linalg.pxd":22
  973. *
  974. *
  975. * cdef class Matrix: # <<<<<<<<<<<<<<
  976. * cdef readonly Pool mem
  977. * cdef weight_t* data
  978. */
  979. struct __pyx_obj_5thinc_6linalg_Matrix {
  980. PyObject_HEAD
  981. struct __pyx_obj_5cymem_5cymem_Pool *mem;
  982. __pyx_t_5thinc_8typedefs_weight_t *data;
  983. int32_t nr_row;
  984. int32_t nr_col;
  985. };
  986. /* "thinc/linalg.pxd":29
  987. *
  988. *
  989. * cdef class Vec: # <<<<<<<<<<<<<<
  990. * @staticmethod
  991. * cdef inline int arg_max(const weight_t* scores, const int n_classes) nogil:
  992. */
  993. struct __pyx_obj_5thinc_6linalg_Vec {
  994. PyObject_HEAD
  995. struct __pyx_vtabstruct_5thinc_6linalg_Vec *__pyx_vtab;
  996. };
  997. /* "thinc/linalg.pxd":140
  998. *
  999. *
  1000. * cdef class VecVec: # <<<<<<<<<<<<<<
  1001. * @staticmethod
  1002. * cdef inline void add(weight_t* output,
  1003. */
  1004. struct __pyx_obj_5thinc_6linalg_VecVec {
  1005. PyObject_HEAD
  1006. struct __pyx_vtabstruct_5thinc_6linalg_VecVec *__pyx_vtab;
  1007. };
  1008. /* "thinc/linalg.pxd":231
  1009. *
  1010. *
  1011. * cdef class Mat: # <<<<<<<<<<<<<<
  1012. * @staticmethod
  1013. * cdef inline void mean_row(weight_t* Ex,
  1014. */
  1015. struct __pyx_obj_5thinc_6linalg_Mat {
  1016. PyObject_HEAD
  1017. struct __pyx_vtabstruct_5thinc_6linalg_Mat *__pyx_vtab;
  1018. };
  1019. /* "thinc/linalg.pxd":259
  1020. *
  1021. *
  1022. * cdef class MatVec: # <<<<<<<<<<<<<<
  1023. * @staticmethod
  1024. * cdef inline void add_i(weight_t* mat,
  1025. */
  1026. struct __pyx_obj_5thinc_6linalg_MatVec {
  1027. PyObject_HEAD
  1028. struct __pyx_vtabstruct_5thinc_6linalg_MatVec *__pyx_vtab;
  1029. };
  1030. /* "thinc/linalg.pxd":425
  1031. *
  1032. *
  1033. * cdef class MatMat: # <<<<<<<<<<<<<<
  1034. * @staticmethod
  1035. * cdef inline void add(weight_t* output,
  1036. */
  1037. struct __pyx_obj_5thinc_6linalg_MatMat {
  1038. PyObject_HEAD
  1039. struct __pyx_vtabstruct_5thinc_6linalg_MatMat *__pyx_vtab;
  1040. };
  1041. /* "cymem/cymem.pxd":4
  1042. * ctypedef void (*free_t)(void *p)
  1043. *
  1044. * cdef class PyMalloc: # <<<<<<<<<<<<<<
  1045. * cdef malloc_t malloc
  1046. * cdef void _set(self, malloc_t malloc)
  1047. */
  1048. struct __pyx_vtabstruct_5cymem_5cymem_PyMalloc {
  1049. void (*_set)(struct __pyx_obj_5cymem_5cymem_PyMalloc *, __pyx_t_5cymem_5cymem_malloc_t);
  1050. };
  1051. static struct __pyx_vtabstruct_5cymem_5cymem_PyMalloc *__pyx_vtabptr_5cymem_5cymem_PyMalloc;
  1052. /* "cymem/cymem.pxd":10
  1053. * cdef PyMalloc WrapMalloc(malloc_t malloc)
  1054. *
  1055. * cdef class PyFree: # <<<<<<<<<<<<<<
  1056. * cdef free_t free
  1057. * cdef void _set(self, free_t free)
  1058. */
  1059. struct __pyx_vtabstruct_5cymem_5cymem_PyFree {
  1060. void (*_set)(struct __pyx_obj_5cymem_5cymem_PyFree *, __pyx_t_5cymem_5cymem_free_t);
  1061. };
  1062. static struct __pyx_vtabstruct_5cymem_5cymem_PyFree *__pyx_vtabptr_5cymem_5cymem_PyFree;
  1063. /* "cymem/cymem.pxd":16
  1064. * cdef PyFree WrapFree(free_t free)
  1065. *
  1066. * cdef class Pool: # <<<<<<<<<<<<<<
  1067. * cdef readonly size_t size
  1068. * cdef readonly dict addresses
  1069. */
  1070. struct __pyx_vtabstruct_5cymem_5cymem_Pool {
  1071. void *(*alloc)(struct __pyx_obj_5cymem_5cymem_Pool *, size_t, size_t);
  1072. void (*free)(struct __pyx_obj_5cymem_5cymem_Pool *, void *);
  1073. void *(*realloc)(struct __pyx_obj_5cymem_5cymem_Pool *, void *, size_t);
  1074. };
  1075. static struct __pyx_vtabstruct_5cymem_5cymem_Pool *__pyx_vtabptr_5cymem_5cymem_Pool;
  1076. /* "thinc/linalg.pxd":29
  1077. *
  1078. *
  1079. * cdef class Vec: # <<<<<<<<<<<<<<
  1080. * @staticmethod
  1081. * cdef inline int arg_max(const weight_t* scores, const int n_classes) nogil:
  1082. */
  1083. struct __pyx_vtabstruct_5thinc_6linalg_Vec {
  1084. int (*arg_max)(__pyx_t_5thinc_8typedefs_weight_t const *, int const );
  1085. __pyx_t_5thinc_8typedefs_weight_t (*max)(__pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1086. __pyx_t_5thinc_8typedefs_weight_t (*sum)(__pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1087. __pyx_t_5thinc_8typedefs_weight_t (*norm)(__pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1088. void (*add)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1089. void (*add_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1090. void (*mul)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1091. void (*mul_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1092. void (*pow)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1093. void (*pow_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const , int32_t);
  1094. void (*div)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1095. void (*div_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const , int32_t);
  1096. void (*exp)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1097. void (*exp_i)(__pyx_t_5thinc_8typedefs_weight_t *, int32_t);
  1098. void (*reciprocal_i)(__pyx_t_5thinc_8typedefs_weight_t *, int32_t);
  1099. };
  1100. static struct __pyx_vtabstruct_5thinc_6linalg_Vec *__pyx_vtabptr_5thinc_6linalg_Vec;
  1101. static CYTHON_INLINE int __pyx_f_5thinc_6linalg_3Vec_arg_max(__pyx_t_5thinc_8typedefs_weight_t const *, int const );
  1102. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_3Vec_max(__pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1103. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_3Vec_sum(__pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1104. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_3Vec_norm(__pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1105. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_add(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1106. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_add_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1107. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_mul(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1108. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_mul_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1109. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_pow(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1110. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_pow_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const , int32_t);
  1111. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_div(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1112. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_div_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const , int32_t);
  1113. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_exp(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1114. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_exp_i(__pyx_t_5thinc_8typedefs_weight_t *, int32_t);
  1115. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_reciprocal_i(__pyx_t_5thinc_8typedefs_weight_t *, int32_t);
  1116. /* "thinc/linalg.pxd":140
  1117. *
  1118. *
  1119. * cdef class VecVec: # <<<<<<<<<<<<<<
  1120. * @staticmethod
  1121. * cdef inline void add(weight_t* output,
  1122. */
  1123. struct __pyx_vtabstruct_5thinc_6linalg_VecVec {
  1124. void (*add)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1125. void (*add_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1126. void (*batch_add_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t, int32_t);
  1127. void (*add_pow)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1128. void (*add_pow_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1129. void (*mul)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1130. void (*mul_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1131. __pyx_t_5thinc_8typedefs_weight_t (*dot)(__pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1132. int (*arg_max_if_true)(__pyx_t_5thinc_8typedefs_weight_t const *, int const *, int const );
  1133. int (*arg_max_if_zero)(__pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int const );
  1134. };
  1135. static struct __pyx_vtabstruct_5thinc_6linalg_VecVec *__pyx_vtabptr_5thinc_6linalg_VecVec;
  1136. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1137. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1138. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_batch_add_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t, int32_t);
  1139. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add_pow(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1140. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add_pow_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t);
  1141. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_mul(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1142. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_mul_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1143. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_6VecVec_dot(__pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t);
  1144. static CYTHON_INLINE int __pyx_f_5thinc_6linalg_6VecVec_arg_max_if_true(__pyx_t_5thinc_8typedefs_weight_t const *, int const *, int const );
  1145. static CYTHON_INLINE int __pyx_f_5thinc_6linalg_6VecVec_arg_max_if_zero(__pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int const );
  1146. /* "thinc/linalg.pxd":231
  1147. *
  1148. *
  1149. * cdef class Mat: # <<<<<<<<<<<<<<
  1150. * @staticmethod
  1151. * cdef inline void mean_row(weight_t* Ex,
  1152. */
  1153. struct __pyx_vtabstruct_5thinc_6linalg_Mat {
  1154. void (*mean_row)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1155. void (*var_row)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, __pyx_t_5thinc_8typedefs_weight_t);
  1156. };
  1157. static struct __pyx_vtabstruct_5thinc_6linalg_Mat *__pyx_vtabptr_5thinc_6linalg_Mat;
  1158. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Mat_mean_row(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1159. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Mat_var_row(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, __pyx_t_5thinc_8typedefs_weight_t);
  1160. /* "thinc/linalg.pxd":259
  1161. *
  1162. *
  1163. * cdef class MatVec: # <<<<<<<<<<<<<<
  1164. * @staticmethod
  1165. * cdef inline void add_i(weight_t* mat,
  1166. */
  1167. struct __pyx_vtabstruct_5thinc_6linalg_MatVec {
  1168. void (*add_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t, int32_t);
  1169. void (*mul)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1170. void (*mul_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1171. void (*dot)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1172. void (*batch_dot)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, int32_t);
  1173. void (*T_dot)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1174. void (*batch_T_dot)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, int32_t);
  1175. };
  1176. static struct __pyx_vtabstruct_5thinc_6linalg_MatVec *__pyx_vtabptr_5thinc_6linalg_MatVec;
  1177. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_add_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t, int32_t);
  1178. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_mul(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1179. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_mul_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1180. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_dot(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1181. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_batch_dot(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, int32_t);
  1182. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_T_dot(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1183. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_batch_T_dot(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, int32_t);
  1184. /* "thinc/linalg.pxd":425
  1185. *
  1186. *
  1187. * cdef class MatMat: # <<<<<<<<<<<<<<
  1188. * @staticmethod
  1189. * cdef inline void add(weight_t* output,
  1190. */
  1191. struct __pyx_vtabstruct_5thinc_6linalg_MatMat {
  1192. void (*add)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1193. void (*add_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1194. void (*mul)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1195. void (*mul_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1196. void (*add_outer_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1197. void (*batch_add_outer_i)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, int32_t);
  1198. };
  1199. static struct __pyx_vtabstruct_5thinc_6linalg_MatMat *__pyx_vtabptr_5thinc_6linalg_MatMat;
  1200. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_add(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1201. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_add_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1202. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_mul(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1203. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_mul_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1204. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_add_outer_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t);
  1205. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_batch_add_outer_i(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, int32_t);
  1206. /* --- Runtime support code (head) --- */
  1207. /* Refnanny.proto */
  1208. #ifndef CYTHON_REFNANNY
  1209. #define CYTHON_REFNANNY 0
  1210. #endif
  1211. #if CYTHON_REFNANNY
  1212. typedef struct {
  1213. void (*INCREF)(void*, PyObject*, int);
  1214. void (*DECREF)(void*, PyObject*, int);
  1215. void (*GOTREF)(void*, PyObject*, int);
  1216. void (*GIVEREF)(void*, PyObject*, int);
  1217. void* (*SetupContext)(const char*, int, const char*);
  1218. void (*FinishContext)(void**);
  1219. } __Pyx_RefNannyAPIStruct;
  1220. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  1221. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  1222. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  1223. #ifdef WITH_THREAD
  1224. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1225. if (acquire_gil) {\
  1226. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1227. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  1228. PyGILState_Release(__pyx_gilstate_save);\
  1229. } else {\
  1230. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  1231. }
  1232. #else
  1233. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1234. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  1235. #endif
  1236. #define __Pyx_RefNannyFinishContext()\
  1237. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  1238. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1239. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1240. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1241. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1242. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  1243. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  1244. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  1245. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  1246. #else
  1247. #define __Pyx_RefNannyDeclarations
  1248. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  1249. #define __Pyx_RefNannyFinishContext()
  1250. #define __Pyx_INCREF(r) Py_INCREF(r)
  1251. #define __Pyx_DECREF(r) Py_DECREF(r)
  1252. #define __Pyx_GOTREF(r)
  1253. #define __Pyx_GIVEREF(r)
  1254. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  1255. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  1256. #define __Pyx_XGOTREF(r)
  1257. #define __Pyx_XGIVEREF(r)
  1258. #endif
  1259. #define __Pyx_XDECREF_SET(r, v) do {\
  1260. PyObject *tmp = (PyObject *) r;\
  1261. r = v; __Pyx_XDECREF(tmp);\
  1262. } while (0)
  1263. #define __Pyx_DECREF_SET(r, v) do {\
  1264. PyObject *tmp = (PyObject *) r;\
  1265. r = v; __Pyx_DECREF(tmp);\
  1266. } while (0)
  1267. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  1268. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  1269. /* PyObjectGetAttrStr.proto */
  1270. #if CYTHON_USE_TYPE_SLOTS
  1271. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  1272. #else
  1273. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  1274. #endif
  1275. /* GetBuiltinName.proto */
  1276. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  1277. /* PyObject_GenericGetAttrNoDict.proto */
  1278. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1279. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
  1280. #else
  1281. #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
  1282. #endif
  1283. /* PyObject_GenericGetAttr.proto */
  1284. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1285. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
  1286. #else
  1287. #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
  1288. #endif
  1289. /* SetVTable.proto */
  1290. static int __Pyx_SetVtable(PyObject *dict, void *vtable);
  1291. /* TypeImport.proto */
  1292. #ifndef __PYX_HAVE_RT_ImportType_proto
  1293. #define __PYX_HAVE_RT_ImportType_proto
  1294. enum __Pyx_ImportType_CheckSize {
  1295. __Pyx_ImportType_CheckSize_Error = 0,
  1296. __Pyx_ImportType_CheckSize_Warn = 1,
  1297. __Pyx_ImportType_CheckSize_Ignore = 2
  1298. };
  1299. static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
  1300. #endif
  1301. /* GetVTable.proto */
  1302. static void* __Pyx_GetVtable(PyObject *dict);
  1303. /* PyThreadStateGet.proto */
  1304. #if CYTHON_FAST_THREAD_STATE
  1305. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1306. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  1307. #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
  1308. #else
  1309. #define __Pyx_PyThreadState_declare
  1310. #define __Pyx_PyThreadState_assign
  1311. #define __Pyx_PyErr_Occurred() PyErr_Occurred()
  1312. #endif
  1313. /* PyErrFetchRestore.proto */
  1314. #if CYTHON_FAST_THREAD_STATE
  1315. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  1316. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1317. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1318. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1319. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1320. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1321. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1322. #if CYTHON_COMPILING_IN_CPYTHON
  1323. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  1324. #else
  1325. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1326. #endif
  1327. #else
  1328. #define __Pyx_PyErr_Clear() PyErr_Clear()
  1329. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1330. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1331. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1332. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  1333. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  1334. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1335. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1336. #endif
  1337. /* CLineInTraceback.proto */
  1338. #ifdef CYTHON_CLINE_IN_TRACEBACK
  1339. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  1340. #else
  1341. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  1342. #endif
  1343. /* CodeObjectCache.proto */
  1344. typedef struct {
  1345. PyCodeObject* code_object;
  1346. int code_line;
  1347. } __Pyx_CodeObjectCacheEntry;
  1348. struct __Pyx_CodeObjectCache {
  1349. int count;
  1350. int max_count;
  1351. __Pyx_CodeObjectCacheEntry* entries;
  1352. };
  1353. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  1354. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  1355. static PyCodeObject *__pyx_find_code_object(int code_line);
  1356. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  1357. /* AddTraceback.proto */
  1358. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1359. int py_line, const char *filename);
  1360. /* CIntToPy.proto */
  1361. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
  1362. /* CIntToPy.proto */
  1363. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value);
  1364. /* CIntFromPy.proto */
  1365. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  1366. /* CIntFromPy.proto */
  1367. static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *);
  1368. /* CIntToPy.proto */
  1369. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  1370. /* CIntFromPy.proto */
  1371. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  1372. /* FastTypeChecks.proto */
  1373. #if CYTHON_COMPILING_IN_CPYTHON
  1374. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  1375. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  1376. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  1377. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  1378. #else
  1379. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  1380. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  1381. #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
  1382. #endif
  1383. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  1384. /* CheckBinaryVersion.proto */
  1385. static int __Pyx_check_binary_version(void);
  1386. /* InitStrings.proto */
  1387. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  1388. static CYTHON_INLINE int __pyx_f_5thinc_6linalg_3Vec_arg_max(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_scores, int const __pyx_v_n_classes); /* proto*/
  1389. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_3Vec_max(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, int32_t __pyx_v_nr); /* proto*/
  1390. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_3Vec_sum(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr); /* proto*/
  1391. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_3Vec_norm(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr); /* proto*/
  1392. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_add(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_inc, int32_t __pyx_v_nr); /* proto*/
  1393. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_add_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_inc, int32_t __pyx_v_nr); /* proto*/
  1394. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_mul(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scal, int32_t __pyx_v_nr); /* proto*/
  1395. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_mul_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scal, int32_t __pyx_v_nr); /* proto*/
  1396. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_pow(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scal, int32_t __pyx_v_nr); /* proto*/
  1397. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_pow_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t const __pyx_v_scal, int32_t __pyx_v_nr); /* proto*/
  1398. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_div(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scal, int32_t __pyx_v_nr); /* proto*/
  1399. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_div_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t const __pyx_v_scal, int32_t __pyx_v_nr); /* proto*/
  1400. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_exp(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr); /* proto*/
  1401. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_exp_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, int32_t __pyx_v_nr); /* proto*/
  1402. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_reciprocal_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, int32_t __pyx_v_nr); /* proto*/
  1403. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scale, int32_t __pyx_v_nr); /* proto*/
  1404. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scale, int32_t __pyx_v_nr); /* proto*/
  1405. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_batch_add_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scale, int32_t __pyx_v_nr, int32_t __pyx_v_nr_batch); /* proto*/
  1406. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add_pow(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_power, int32_t __pyx_v_nr); /* proto*/
  1407. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add_pow_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_power, int32_t __pyx_v_nr); /* proto*/
  1408. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_mul(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr); /* proto*/
  1409. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_mul_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr); /* proto*/
  1410. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_6VecVec_dot(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr); /* proto*/
  1411. static CYTHON_INLINE int __pyx_f_5thinc_6linalg_6VecVec_arg_max_if_true(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_scores, int const *__pyx_v_is_valid, int const __pyx_v_n_classes); /* proto*/
  1412. static CYTHON_INLINE int __pyx_f_5thinc_6linalg_6VecVec_arg_max_if_zero(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_scores, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_costs, int const __pyx_v_n_classes); /* proto*/
  1413. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Mat_mean_row(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_Ex, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col); /* proto*/
  1414. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Mat_var_row(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_Vx, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_Ex, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_eps); /* proto*/
  1415. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_add_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scale, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col); /* proto*/
  1416. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_mul(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col); /* proto*/
  1417. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_mul_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col); /* proto*/
  1418. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_dot(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col); /* proto*/
  1419. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_batch_dot(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col, int32_t __pyx_v_nr_batch); /* proto*/
  1420. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_T_dot(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col); /* proto*/
  1421. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_batch_T_dot(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col, int32_t __pyx_v_nr_batch); /* proto*/
  1422. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_add(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col); /* proto*/
  1423. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_add_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col); /* proto*/
  1424. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_mul(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col); /* proto*/
  1425. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_mul_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col); /* proto*/
  1426. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_add_outer_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col); /* proto*/
  1427. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_batch_add_outer_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col, int32_t __pyx_v_nr_batch); /* proto*/
  1428. /* Module declarations from 'cython' */
  1429. /* Module declarations from 'libc.stdint' */
  1430. /* Module declarations from 'libc.string' */
  1431. /* Module declarations from 'cymem.cymem' */
  1432. static PyTypeObject *__pyx_ptype_5cymem_5cymem_PyMalloc = 0;
  1433. static PyTypeObject *__pyx_ptype_5cymem_5cymem_PyFree = 0;
  1434. static PyTypeObject *__pyx_ptype_5cymem_5cymem_Pool = 0;
  1435. static PyTypeObject *__pyx_ptype_5cymem_5cymem_Address = 0;
  1436. /* Module declarations from 'thinc.typedefs' */
  1437. /* Module declarations from 'thinc.linalg' */
  1438. static PyTypeObject *__pyx_ptype_5thinc_6linalg_Matrix = 0;
  1439. static PyTypeObject *__pyx_ptype_5thinc_6linalg_Vec = 0;
  1440. static PyTypeObject *__pyx_ptype_5thinc_6linalg_VecVec = 0;
  1441. static PyTypeObject *__pyx_ptype_5thinc_6linalg_Mat = 0;
  1442. static PyTypeObject *__pyx_ptype_5thinc_6linalg_MatVec = 0;
  1443. static PyTypeObject *__pyx_ptype_5thinc_6linalg_MatMat = 0;
  1444. #define __Pyx_MODULE_NAME "thinc.linalg"
  1445. extern int __pyx_module_is_main_thinc__linalg;
  1446. int __pyx_module_is_main_thinc__linalg = 0;
  1447. /* Implementation of 'thinc.linalg' */
  1448. static PyObject *__pyx_builtin_range;
  1449. static const char __pyx_k_Mat[] = "Mat";
  1450. static const char __pyx_k_Vec[] = "Vec";
  1451. static const char __pyx_k_main[] = "__main__";
  1452. static const char __pyx_k_name[] = "__name__";
  1453. static const char __pyx_k_test[] = "__test__";
  1454. static const char __pyx_k_range[] = "range";
  1455. static const char __pyx_k_MatMat[] = "MatMat";
  1456. static const char __pyx_k_MatVec[] = "MatVec";
  1457. static const char __pyx_k_Matrix[] = "Matrix";
  1458. static const char __pyx_k_VecVec[] = "VecVec";
  1459. static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
  1460. static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
  1461. static PyObject *__pyx_n_s_Mat;
  1462. static PyObject *__pyx_n_s_MatMat;
  1463. static PyObject *__pyx_n_s_MatVec;
  1464. static PyObject *__pyx_n_s_Matrix;
  1465. static PyObject *__pyx_n_s_Vec;
  1466. static PyObject *__pyx_n_s_VecVec;
  1467. static PyObject *__pyx_n_s_cline_in_traceback;
  1468. static PyObject *__pyx_n_s_main;
  1469. static PyObject *__pyx_n_s_name;
  1470. static PyObject *__pyx_n_s_pyx_vtable;
  1471. static PyObject *__pyx_n_s_range;
  1472. static PyObject *__pyx_n_s_test;
  1473. static PyObject *__pyx_tp_new_5thinc_6linalg_Matrix(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1474. static PyObject *__pyx_tp_new_5thinc_6linalg_Vec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1475. static PyObject *__pyx_tp_new_5thinc_6linalg_VecVec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1476. static PyObject *__pyx_tp_new_5thinc_6linalg_Mat(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1477. static PyObject *__pyx_tp_new_5thinc_6linalg_MatVec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1478. static PyObject *__pyx_tp_new_5thinc_6linalg_MatMat(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1479. /* Late includes */
  1480. /* "thinc/linalg.pxd":31
  1481. * cdef class Vec:
  1482. * @staticmethod
  1483. * cdef inline int arg_max(const weight_t* scores, const int n_classes) nogil: # <<<<<<<<<<<<<<
  1484. * if n_classes == 2:
  1485. * return 0 if scores[0] > scores[1] else 1
  1486. */
  1487. static CYTHON_INLINE int __pyx_f_5thinc_6linalg_3Vec_arg_max(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_scores, int const __pyx_v_n_classes) {
  1488. int __pyx_v_i;
  1489. int __pyx_v_best;
  1490. __pyx_t_5thinc_8typedefs_weight_t __pyx_v_mode;
  1491. int __pyx_r;
  1492. int __pyx_t_1;
  1493. int __pyx_t_2;
  1494. int __pyx_t_3;
  1495. int __pyx_t_4;
  1496. /* "thinc/linalg.pxd":32
  1497. * @staticmethod
  1498. * cdef inline int arg_max(const weight_t* scores, const int n_classes) nogil:
  1499. * if n_classes == 2: # <<<<<<<<<<<<<<
  1500. * return 0 if scores[0] > scores[1] else 1
  1501. * cdef int i
  1502. */
  1503. __pyx_t_1 = ((__pyx_v_n_classes == 2) != 0);
  1504. if (__pyx_t_1) {
  1505. /* "thinc/linalg.pxd":33
  1506. * cdef inline int arg_max(const weight_t* scores, const int n_classes) nogil:
  1507. * if n_classes == 2:
  1508. * return 0 if scores[0] > scores[1] else 1 # <<<<<<<<<<<<<<
  1509. * cdef int i
  1510. * cdef int best = 0
  1511. */
  1512. if ((((__pyx_v_scores[0]) > (__pyx_v_scores[1])) != 0)) {
  1513. __pyx_t_2 = 0;
  1514. } else {
  1515. __pyx_t_2 = 1;
  1516. }
  1517. __pyx_r = __pyx_t_2;
  1518. goto __pyx_L0;
  1519. /* "thinc/linalg.pxd":32
  1520. * @staticmethod
  1521. * cdef inline int arg_max(const weight_t* scores, const int n_classes) nogil:
  1522. * if n_classes == 2: # <<<<<<<<<<<<<<
  1523. * return 0 if scores[0] > scores[1] else 1
  1524. * cdef int i
  1525. */
  1526. }
  1527. /* "thinc/linalg.pxd":35
  1528. * return 0 if scores[0] > scores[1] else 1
  1529. * cdef int i
  1530. * cdef int best = 0 # <<<<<<<<<<<<<<
  1531. * cdef weight_t mode = scores[0]
  1532. * for i in range(1, n_classes):
  1533. */
  1534. __pyx_v_best = 0;
  1535. /* "thinc/linalg.pxd":36
  1536. * cdef int i
  1537. * cdef int best = 0
  1538. * cdef weight_t mode = scores[0] # <<<<<<<<<<<<<<
  1539. * for i in range(1, n_classes):
  1540. * if scores[i] > mode:
  1541. */
  1542. __pyx_v_mode = (__pyx_v_scores[0]);
  1543. /* "thinc/linalg.pxd":37
  1544. * cdef int best = 0
  1545. * cdef weight_t mode = scores[0]
  1546. * for i in range(1, n_classes): # <<<<<<<<<<<<<<
  1547. * if scores[i] > mode:
  1548. * mode = scores[i]
  1549. */
  1550. __pyx_t_2 = __pyx_v_n_classes;
  1551. __pyx_t_3 = __pyx_t_2;
  1552. for (__pyx_t_4 = 1; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
  1553. __pyx_v_i = __pyx_t_4;
  1554. /* "thinc/linalg.pxd":38
  1555. * cdef weight_t mode = scores[0]
  1556. * for i in range(1, n_classes):
  1557. * if scores[i] > mode: # <<<<<<<<<<<<<<
  1558. * mode = scores[i]
  1559. * best = i
  1560. */
  1561. __pyx_t_1 = (((__pyx_v_scores[__pyx_v_i]) > __pyx_v_mode) != 0);
  1562. if (__pyx_t_1) {
  1563. /* "thinc/linalg.pxd":39
  1564. * for i in range(1, n_classes):
  1565. * if scores[i] > mode:
  1566. * mode = scores[i] # <<<<<<<<<<<<<<
  1567. * best = i
  1568. * return best
  1569. */
  1570. __pyx_v_mode = (__pyx_v_scores[__pyx_v_i]);
  1571. /* "thinc/linalg.pxd":40
  1572. * if scores[i] > mode:
  1573. * mode = scores[i]
  1574. * best = i # <<<<<<<<<<<<<<
  1575. * return best
  1576. *
  1577. */
  1578. __pyx_v_best = __pyx_v_i;
  1579. /* "thinc/linalg.pxd":38
  1580. * cdef weight_t mode = scores[0]
  1581. * for i in range(1, n_classes):
  1582. * if scores[i] > mode: # <<<<<<<<<<<<<<
  1583. * mode = scores[i]
  1584. * best = i
  1585. */
  1586. }
  1587. }
  1588. /* "thinc/linalg.pxd":41
  1589. * mode = scores[i]
  1590. * best = i
  1591. * return best # <<<<<<<<<<<<<<
  1592. *
  1593. * @staticmethod
  1594. */
  1595. __pyx_r = __pyx_v_best;
  1596. goto __pyx_L0;
  1597. /* "thinc/linalg.pxd":31
  1598. * cdef class Vec:
  1599. * @staticmethod
  1600. * cdef inline int arg_max(const weight_t* scores, const int n_classes) nogil: # <<<<<<<<<<<<<<
  1601. * if n_classes == 2:
  1602. * return 0 if scores[0] > scores[1] else 1
  1603. */
  1604. /* function exit code */
  1605. __pyx_L0:;
  1606. return __pyx_r;
  1607. }
  1608. /* "thinc/linalg.pxd":44
  1609. *
  1610. * @staticmethod
  1611. * cdef inline weight_t max(const weight_t* x, int32_t nr) nogil: # <<<<<<<<<<<<<<
  1612. * if nr == 0:
  1613. * return 0
  1614. */
  1615. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_3Vec_max(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, int32_t __pyx_v_nr) {
  1616. int __pyx_v_i;
  1617. __pyx_t_5thinc_8typedefs_weight_t __pyx_v_mode;
  1618. __pyx_t_5thinc_8typedefs_weight_t __pyx_r;
  1619. int __pyx_t_1;
  1620. int32_t __pyx_t_2;
  1621. int32_t __pyx_t_3;
  1622. int __pyx_t_4;
  1623. /* "thinc/linalg.pxd":45
  1624. * @staticmethod
  1625. * cdef inline weight_t max(const weight_t* x, int32_t nr) nogil:
  1626. * if nr == 0: # <<<<<<<<<<<<<<
  1627. * return 0
  1628. * cdef int i
  1629. */
  1630. __pyx_t_1 = ((__pyx_v_nr == 0) != 0);
  1631. if (__pyx_t_1) {
  1632. /* "thinc/linalg.pxd":46
  1633. * cdef inline weight_t max(const weight_t* x, int32_t nr) nogil:
  1634. * if nr == 0:
  1635. * return 0 # <<<<<<<<<<<<<<
  1636. * cdef int i
  1637. * cdef weight_t mode = x[0]
  1638. */
  1639. __pyx_r = 0.0;
  1640. goto __pyx_L0;
  1641. /* "thinc/linalg.pxd":45
  1642. * @staticmethod
  1643. * cdef inline weight_t max(const weight_t* x, int32_t nr) nogil:
  1644. * if nr == 0: # <<<<<<<<<<<<<<
  1645. * return 0
  1646. * cdef int i
  1647. */
  1648. }
  1649. /* "thinc/linalg.pxd":48
  1650. * return 0
  1651. * cdef int i
  1652. * cdef weight_t mode = x[0] # <<<<<<<<<<<<<<
  1653. * for i in range(1, nr):
  1654. * if x[i] > mode:
  1655. */
  1656. __pyx_v_mode = (__pyx_v_x[0]);
  1657. /* "thinc/linalg.pxd":49
  1658. * cdef int i
  1659. * cdef weight_t mode = x[0]
  1660. * for i in range(1, nr): # <<<<<<<<<<<<<<
  1661. * if x[i] > mode:
  1662. * mode = x[i]
  1663. */
  1664. __pyx_t_2 = __pyx_v_nr;
  1665. __pyx_t_3 = __pyx_t_2;
  1666. for (__pyx_t_4 = 1; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
  1667. __pyx_v_i = __pyx_t_4;
  1668. /* "thinc/linalg.pxd":50
  1669. * cdef weight_t mode = x[0]
  1670. * for i in range(1, nr):
  1671. * if x[i] > mode: # <<<<<<<<<<<<<<
  1672. * mode = x[i]
  1673. * return mode
  1674. */
  1675. __pyx_t_1 = (((__pyx_v_x[__pyx_v_i]) > __pyx_v_mode) != 0);
  1676. if (__pyx_t_1) {
  1677. /* "thinc/linalg.pxd":51
  1678. * for i in range(1, nr):
  1679. * if x[i] > mode:
  1680. * mode = x[i] # <<<<<<<<<<<<<<
  1681. * return mode
  1682. *
  1683. */
  1684. __pyx_v_mode = (__pyx_v_x[__pyx_v_i]);
  1685. /* "thinc/linalg.pxd":50
  1686. * cdef weight_t mode = x[0]
  1687. * for i in range(1, nr):
  1688. * if x[i] > mode: # <<<<<<<<<<<<<<
  1689. * mode = x[i]
  1690. * return mode
  1691. */
  1692. }
  1693. }
  1694. /* "thinc/linalg.pxd":52
  1695. * if x[i] > mode:
  1696. * mode = x[i]
  1697. * return mode # <<<<<<<<<<<<<<
  1698. *
  1699. * @staticmethod
  1700. */
  1701. __pyx_r = __pyx_v_mode;
  1702. goto __pyx_L0;
  1703. /* "thinc/linalg.pxd":44
  1704. *
  1705. * @staticmethod
  1706. * cdef inline weight_t max(const weight_t* x, int32_t nr) nogil: # <<<<<<<<<<<<<<
  1707. * if nr == 0:
  1708. * return 0
  1709. */
  1710. /* function exit code */
  1711. __pyx_L0:;
  1712. return __pyx_r;
  1713. }
  1714. /* "thinc/linalg.pxd":55
  1715. *
  1716. * @staticmethod
  1717. * cdef inline weight_t sum(const weight_t* vec, int32_t nr) nogil: # <<<<<<<<<<<<<<
  1718. * cdef int i
  1719. * cdef weight_t total = 0
  1720. */
  1721. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_3Vec_sum(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr) {
  1722. int __pyx_v_i;
  1723. __pyx_t_5thinc_8typedefs_weight_t __pyx_v_total;
  1724. __pyx_t_5thinc_8typedefs_weight_t __pyx_r;
  1725. int32_t __pyx_t_1;
  1726. int32_t __pyx_t_2;
  1727. int __pyx_t_3;
  1728. /* "thinc/linalg.pxd":57
  1729. * cdef inline weight_t sum(const weight_t* vec, int32_t nr) nogil:
  1730. * cdef int i
  1731. * cdef weight_t total = 0 # <<<<<<<<<<<<<<
  1732. * for i in range(nr):
  1733. * total += vec[i]
  1734. */
  1735. __pyx_v_total = 0.0;
  1736. /* "thinc/linalg.pxd":58
  1737. * cdef int i
  1738. * cdef weight_t total = 0
  1739. * for i in range(nr): # <<<<<<<<<<<<<<
  1740. * total += vec[i]
  1741. * return total
  1742. */
  1743. __pyx_t_1 = __pyx_v_nr;
  1744. __pyx_t_2 = __pyx_t_1;
  1745. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  1746. __pyx_v_i = __pyx_t_3;
  1747. /* "thinc/linalg.pxd":59
  1748. * cdef weight_t total = 0
  1749. * for i in range(nr):
  1750. * total += vec[i] # <<<<<<<<<<<<<<
  1751. * return total
  1752. *
  1753. */
  1754. __pyx_v_total = (__pyx_v_total + (__pyx_v_vec[__pyx_v_i]));
  1755. }
  1756. /* "thinc/linalg.pxd":60
  1757. * for i in range(nr):
  1758. * total += vec[i]
  1759. * return total # <<<<<<<<<<<<<<
  1760. *
  1761. * @staticmethod
  1762. */
  1763. __pyx_r = __pyx_v_total;
  1764. goto __pyx_L0;
  1765. /* "thinc/linalg.pxd":55
  1766. *
  1767. * @staticmethod
  1768. * cdef inline weight_t sum(const weight_t* vec, int32_t nr) nogil: # <<<<<<<<<<<<<<
  1769. * cdef int i
  1770. * cdef weight_t total = 0
  1771. */
  1772. /* function exit code */
  1773. __pyx_L0:;
  1774. return __pyx_r;
  1775. }
  1776. /* "thinc/linalg.pxd":63
  1777. *
  1778. * @staticmethod
  1779. * cdef inline weight_t norm(const weight_t* vec, int32_t nr) nogil: # <<<<<<<<<<<<<<
  1780. * cdef weight_t total = 0
  1781. * for i in range(nr):
  1782. */
  1783. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_3Vec_norm(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr) {
  1784. __pyx_t_5thinc_8typedefs_weight_t __pyx_v_total;
  1785. int32_t __pyx_v_i;
  1786. __pyx_t_5thinc_8typedefs_weight_t __pyx_r;
  1787. int32_t __pyx_t_1;
  1788. int32_t __pyx_t_2;
  1789. int32_t __pyx_t_3;
  1790. /* "thinc/linalg.pxd":64
  1791. * @staticmethod
  1792. * cdef inline weight_t norm(const weight_t* vec, int32_t nr) nogil:
  1793. * cdef weight_t total = 0 # <<<<<<<<<<<<<<
  1794. * for i in range(nr):
  1795. * total += vec[i] ** 2
  1796. */
  1797. __pyx_v_total = 0.0;
  1798. /* "thinc/linalg.pxd":65
  1799. * cdef inline weight_t norm(const weight_t* vec, int32_t nr) nogil:
  1800. * cdef weight_t total = 0
  1801. * for i in range(nr): # <<<<<<<<<<<<<<
  1802. * total += vec[i] ** 2
  1803. * return sqrt(total)
  1804. */
  1805. __pyx_t_1 = __pyx_v_nr;
  1806. __pyx_t_2 = __pyx_t_1;
  1807. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  1808. __pyx_v_i = __pyx_t_3;
  1809. /* "thinc/linalg.pxd":66
  1810. * cdef weight_t total = 0
  1811. * for i in range(nr):
  1812. * total += vec[i] ** 2 # <<<<<<<<<<<<<<
  1813. * return sqrt(total)
  1814. *
  1815. */
  1816. __pyx_v_total = (__pyx_v_total + powf(((__pyx_t_5thinc_8typedefs_weight_t)(__pyx_v_vec[__pyx_v_i])), 2.0));
  1817. }
  1818. /* "thinc/linalg.pxd":67
  1819. * for i in range(nr):
  1820. * total += vec[i] ** 2
  1821. * return sqrt(total) # <<<<<<<<<<<<<<
  1822. *
  1823. * @staticmethod
  1824. */
  1825. __pyx_r = sqrt(__pyx_v_total);
  1826. goto __pyx_L0;
  1827. /* "thinc/linalg.pxd":63
  1828. *
  1829. * @staticmethod
  1830. * cdef inline weight_t norm(const weight_t* vec, int32_t nr) nogil: # <<<<<<<<<<<<<<
  1831. * cdef weight_t total = 0
  1832. * for i in range(nr):
  1833. */
  1834. /* function exit code */
  1835. __pyx_L0:;
  1836. return __pyx_r;
  1837. }
  1838. /* "thinc/linalg.pxd":70
  1839. *
  1840. * @staticmethod
  1841. * cdef inline void add(weight_t* output, const weight_t* x, # <<<<<<<<<<<<<<
  1842. * weight_t inc, int32_t nr) nogil:
  1843. * memcpy(output, x, sizeof(output[0]) * nr)
  1844. */
  1845. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_add(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_inc, int32_t __pyx_v_nr) {
  1846. /* "thinc/linalg.pxd":72
  1847. * cdef inline void add(weight_t* output, const weight_t* x,
  1848. * weight_t inc, int32_t nr) nogil:
  1849. * memcpy(output, x, sizeof(output[0]) * nr) # <<<<<<<<<<<<<<
  1850. * Vec.add_i(output, inc, nr)
  1851. *
  1852. */
  1853. (void)(memcpy(__pyx_v_output, __pyx_v_x, ((sizeof((__pyx_v_output[0]))) * __pyx_v_nr)));
  1854. /* "thinc/linalg.pxd":73
  1855. * weight_t inc, int32_t nr) nogil:
  1856. * memcpy(output, x, sizeof(output[0]) * nr)
  1857. * Vec.add_i(output, inc, nr) # <<<<<<<<<<<<<<
  1858. *
  1859. * @staticmethod
  1860. */
  1861. __pyx_f_5thinc_6linalg_3Vec_add_i(__pyx_v_output, __pyx_v_inc, __pyx_v_nr);
  1862. /* "thinc/linalg.pxd":70
  1863. *
  1864. * @staticmethod
  1865. * cdef inline void add(weight_t* output, const weight_t* x, # <<<<<<<<<<<<<<
  1866. * weight_t inc, int32_t nr) nogil:
  1867. * memcpy(output, x, sizeof(output[0]) * nr)
  1868. */
  1869. /* function exit code */
  1870. }
  1871. /* "thinc/linalg.pxd":76
  1872. *
  1873. * @staticmethod
  1874. * cdef inline void add_i(weight_t* vec, weight_t inc, int32_t nr) nogil: # <<<<<<<<<<<<<<
  1875. * cdef int i
  1876. * for i in range(nr):
  1877. */
  1878. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_add_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_inc, int32_t __pyx_v_nr) {
  1879. int __pyx_v_i;
  1880. int32_t __pyx_t_1;
  1881. int32_t __pyx_t_2;
  1882. int __pyx_t_3;
  1883. int __pyx_t_4;
  1884. /* "thinc/linalg.pxd":78
  1885. * cdef inline void add_i(weight_t* vec, weight_t inc, int32_t nr) nogil:
  1886. * cdef int i
  1887. * for i in range(nr): # <<<<<<<<<<<<<<
  1888. * vec[i] += inc
  1889. *
  1890. */
  1891. __pyx_t_1 = __pyx_v_nr;
  1892. __pyx_t_2 = __pyx_t_1;
  1893. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  1894. __pyx_v_i = __pyx_t_3;
  1895. /* "thinc/linalg.pxd":79
  1896. * cdef int i
  1897. * for i in range(nr):
  1898. * vec[i] += inc # <<<<<<<<<<<<<<
  1899. *
  1900. * @staticmethod
  1901. */
  1902. __pyx_t_4 = __pyx_v_i;
  1903. (__pyx_v_vec[__pyx_t_4]) = ((__pyx_v_vec[__pyx_t_4]) + __pyx_v_inc);
  1904. }
  1905. /* "thinc/linalg.pxd":76
  1906. *
  1907. * @staticmethod
  1908. * cdef inline void add_i(weight_t* vec, weight_t inc, int32_t nr) nogil: # <<<<<<<<<<<<<<
  1909. * cdef int i
  1910. * for i in range(nr):
  1911. */
  1912. /* function exit code */
  1913. }
  1914. /* "thinc/linalg.pxd":82
  1915. *
  1916. * @staticmethod
  1917. * cdef inline void mul(weight_t* output, const weight_t* vec, weight_t scal, # <<<<<<<<<<<<<<
  1918. * int32_t nr) nogil:
  1919. * memcpy(output, vec, sizeof(output[0]) * nr)
  1920. */
  1921. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_mul(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scal, int32_t __pyx_v_nr) {
  1922. /* "thinc/linalg.pxd":84
  1923. * cdef inline void mul(weight_t* output, const weight_t* vec, weight_t scal,
  1924. * int32_t nr) nogil:
  1925. * memcpy(output, vec, sizeof(output[0]) * nr) # <<<<<<<<<<<<<<
  1926. * Vec.mul_i(output, scal, nr)
  1927. *
  1928. */
  1929. (void)(memcpy(__pyx_v_output, __pyx_v_vec, ((sizeof((__pyx_v_output[0]))) * __pyx_v_nr)));
  1930. /* "thinc/linalg.pxd":85
  1931. * int32_t nr) nogil:
  1932. * memcpy(output, vec, sizeof(output[0]) * nr)
  1933. * Vec.mul_i(output, scal, nr) # <<<<<<<<<<<<<<
  1934. *
  1935. * @staticmethod
  1936. */
  1937. __pyx_f_5thinc_6linalg_3Vec_mul_i(__pyx_v_output, __pyx_v_scal, __pyx_v_nr);
  1938. /* "thinc/linalg.pxd":82
  1939. *
  1940. * @staticmethod
  1941. * cdef inline void mul(weight_t* output, const weight_t* vec, weight_t scal, # <<<<<<<<<<<<<<
  1942. * int32_t nr) nogil:
  1943. * memcpy(output, vec, sizeof(output[0]) * nr)
  1944. */
  1945. /* function exit code */
  1946. }
  1947. /* "thinc/linalg.pxd":88
  1948. *
  1949. * @staticmethod
  1950. * cdef inline void mul_i(weight_t* vec, weight_t scal, int32_t nr) nogil: # <<<<<<<<<<<<<<
  1951. * cdef int i
  1952. * IF USE_BLAS:
  1953. */
  1954. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_mul_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scal, int32_t __pyx_v_nr) {
  1955. int __pyx_v_i;
  1956. int32_t __pyx_t_1;
  1957. int32_t __pyx_t_2;
  1958. int __pyx_t_3;
  1959. int __pyx_t_4;
  1960. /* "thinc/linalg.pxd":93
  1961. * blis.scalv(blis.NO_CONJUGATE, nr, scal, vec, 1)
  1962. * ELSE:
  1963. * for i in range(nr): # <<<<<<<<<<<<<<
  1964. * vec[i] *= scal
  1965. *
  1966. */
  1967. __pyx_t_1 = __pyx_v_nr;
  1968. __pyx_t_2 = __pyx_t_1;
  1969. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  1970. __pyx_v_i = __pyx_t_3;
  1971. /* "thinc/linalg.pxd":94
  1972. * ELSE:
  1973. * for i in range(nr):
  1974. * vec[i] *= scal # <<<<<<<<<<<<<<
  1975. *
  1976. * @staticmethod
  1977. */
  1978. __pyx_t_4 = __pyx_v_i;
  1979. (__pyx_v_vec[__pyx_t_4]) = ((__pyx_v_vec[__pyx_t_4]) * __pyx_v_scal);
  1980. }
  1981. /* "thinc/linalg.pxd":88
  1982. *
  1983. * @staticmethod
  1984. * cdef inline void mul_i(weight_t* vec, weight_t scal, int32_t nr) nogil: # <<<<<<<<<<<<<<
  1985. * cdef int i
  1986. * IF USE_BLAS:
  1987. */
  1988. /* function exit code */
  1989. }
  1990. /* "thinc/linalg.pxd":97
  1991. *
  1992. * @staticmethod
  1993. * cdef inline void pow(weight_t* output, const weight_t* vec, weight_t scal, # <<<<<<<<<<<<<<
  1994. * int32_t nr) nogil:
  1995. * memcpy(output, vec, sizeof(output[0]) * nr)
  1996. */
  1997. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_pow(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scal, int32_t __pyx_v_nr) {
  1998. /* "thinc/linalg.pxd":99
  1999. * cdef inline void pow(weight_t* output, const weight_t* vec, weight_t scal,
  2000. * int32_t nr) nogil:
  2001. * memcpy(output, vec, sizeof(output[0]) * nr) # <<<<<<<<<<<<<<
  2002. * Vec.pow_i(output, scal, nr)
  2003. *
  2004. */
  2005. (void)(memcpy(__pyx_v_output, __pyx_v_vec, ((sizeof((__pyx_v_output[0]))) * __pyx_v_nr)));
  2006. /* "thinc/linalg.pxd":100
  2007. * int32_t nr) nogil:
  2008. * memcpy(output, vec, sizeof(output[0]) * nr)
  2009. * Vec.pow_i(output, scal, nr) # <<<<<<<<<<<<<<
  2010. *
  2011. * @staticmethod
  2012. */
  2013. __pyx_f_5thinc_6linalg_3Vec_pow_i(__pyx_v_output, __pyx_v_scal, __pyx_v_nr);
  2014. /* "thinc/linalg.pxd":97
  2015. *
  2016. * @staticmethod
  2017. * cdef inline void pow(weight_t* output, const weight_t* vec, weight_t scal, # <<<<<<<<<<<<<<
  2018. * int32_t nr) nogil:
  2019. * memcpy(output, vec, sizeof(output[0]) * nr)
  2020. */
  2021. /* function exit code */
  2022. }
  2023. /* "thinc/linalg.pxd":103
  2024. *
  2025. * @staticmethod
  2026. * cdef inline void pow_i(weight_t* vec, const weight_t scal, int32_t nr) nogil: # <<<<<<<<<<<<<<
  2027. * cdef int i
  2028. * for i in range(nr):
  2029. */
  2030. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_pow_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t const __pyx_v_scal, int32_t __pyx_v_nr) {
  2031. int __pyx_v_i;
  2032. int32_t __pyx_t_1;
  2033. int32_t __pyx_t_2;
  2034. int __pyx_t_3;
  2035. int __pyx_t_4;
  2036. /* "thinc/linalg.pxd":105
  2037. * cdef inline void pow_i(weight_t* vec, const weight_t scal, int32_t nr) nogil:
  2038. * cdef int i
  2039. * for i in range(nr): # <<<<<<<<<<<<<<
  2040. * vec[i] **= scal
  2041. *
  2042. */
  2043. __pyx_t_1 = __pyx_v_nr;
  2044. __pyx_t_2 = __pyx_t_1;
  2045. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2046. __pyx_v_i = __pyx_t_3;
  2047. /* "thinc/linalg.pxd":106
  2048. * cdef int i
  2049. * for i in range(nr):
  2050. * vec[i] **= scal # <<<<<<<<<<<<<<
  2051. *
  2052. * @staticmethod
  2053. */
  2054. __pyx_t_4 = __pyx_v_i;
  2055. (__pyx_v_vec[__pyx_t_4]) = powf((__pyx_v_vec[__pyx_t_4]), ((__pyx_t_5thinc_8typedefs_weight_t)__pyx_v_scal));
  2056. }
  2057. /* "thinc/linalg.pxd":103
  2058. *
  2059. * @staticmethod
  2060. * cdef inline void pow_i(weight_t* vec, const weight_t scal, int32_t nr) nogil: # <<<<<<<<<<<<<<
  2061. * cdef int i
  2062. * for i in range(nr):
  2063. */
  2064. /* function exit code */
  2065. }
  2066. /* "thinc/linalg.pxd":110
  2067. * @staticmethod
  2068. * @cython.cdivision(True)
  2069. * cdef inline void div(weight_t* output, const weight_t* vec, weight_t scal, # <<<<<<<<<<<<<<
  2070. * int32_t nr) nogil:
  2071. * memcpy(output, vec, sizeof(output[0]) * nr)
  2072. */
  2073. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_div(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scal, int32_t __pyx_v_nr) {
  2074. /* "thinc/linalg.pxd":112
  2075. * cdef inline void div(weight_t* output, const weight_t* vec, weight_t scal,
  2076. * int32_t nr) nogil:
  2077. * memcpy(output, vec, sizeof(output[0]) * nr) # <<<<<<<<<<<<<<
  2078. * Vec.div_i(output, scal, nr)
  2079. *
  2080. */
  2081. (void)(memcpy(__pyx_v_output, __pyx_v_vec, ((sizeof((__pyx_v_output[0]))) * __pyx_v_nr)));
  2082. /* "thinc/linalg.pxd":113
  2083. * int32_t nr) nogil:
  2084. * memcpy(output, vec, sizeof(output[0]) * nr)
  2085. * Vec.div_i(output, scal, nr) # <<<<<<<<<<<<<<
  2086. *
  2087. * @staticmethod
  2088. */
  2089. __pyx_f_5thinc_6linalg_3Vec_div_i(__pyx_v_output, __pyx_v_scal, __pyx_v_nr);
  2090. /* "thinc/linalg.pxd":110
  2091. * @staticmethod
  2092. * @cython.cdivision(True)
  2093. * cdef inline void div(weight_t* output, const weight_t* vec, weight_t scal, # <<<<<<<<<<<<<<
  2094. * int32_t nr) nogil:
  2095. * memcpy(output, vec, sizeof(output[0]) * nr)
  2096. */
  2097. /* function exit code */
  2098. }
  2099. /* "thinc/linalg.pxd":117
  2100. * @staticmethod
  2101. * @cython.cdivision(True)
  2102. * cdef inline void div_i(weight_t* vec, const weight_t scal, int32_t nr) nogil: # <<<<<<<<<<<<<<
  2103. * cdef int i
  2104. * for i in range(nr):
  2105. */
  2106. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_div_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t const __pyx_v_scal, int32_t __pyx_v_nr) {
  2107. int __pyx_v_i;
  2108. int32_t __pyx_t_1;
  2109. int32_t __pyx_t_2;
  2110. int __pyx_t_3;
  2111. int __pyx_t_4;
  2112. /* "thinc/linalg.pxd":119
  2113. * cdef inline void div_i(weight_t* vec, const weight_t scal, int32_t nr) nogil:
  2114. * cdef int i
  2115. * for i in range(nr): # <<<<<<<<<<<<<<
  2116. * vec[i] /= scal
  2117. *
  2118. */
  2119. __pyx_t_1 = __pyx_v_nr;
  2120. __pyx_t_2 = __pyx_t_1;
  2121. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2122. __pyx_v_i = __pyx_t_3;
  2123. /* "thinc/linalg.pxd":120
  2124. * cdef int i
  2125. * for i in range(nr):
  2126. * vec[i] /= scal # <<<<<<<<<<<<<<
  2127. *
  2128. * @staticmethod
  2129. */
  2130. __pyx_t_4 = __pyx_v_i;
  2131. (__pyx_v_vec[__pyx_t_4]) = ((__pyx_v_vec[__pyx_t_4]) / __pyx_v_scal);
  2132. }
  2133. /* "thinc/linalg.pxd":117
  2134. * @staticmethod
  2135. * @cython.cdivision(True)
  2136. * cdef inline void div_i(weight_t* vec, const weight_t scal, int32_t nr) nogil: # <<<<<<<<<<<<<<
  2137. * cdef int i
  2138. * for i in range(nr):
  2139. */
  2140. /* function exit code */
  2141. }
  2142. /* "thinc/linalg.pxd":123
  2143. *
  2144. * @staticmethod
  2145. * cdef inline void exp(weight_t* output, const weight_t* vec, int32_t nr) nogil: # <<<<<<<<<<<<<<
  2146. * memcpy(output, vec, sizeof(output[0]) * nr)
  2147. * Vec.exp_i(output, nr)
  2148. */
  2149. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_exp(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr) {
  2150. /* "thinc/linalg.pxd":124
  2151. * @staticmethod
  2152. * cdef inline void exp(weight_t* output, const weight_t* vec, int32_t nr) nogil:
  2153. * memcpy(output, vec, sizeof(output[0]) * nr) # <<<<<<<<<<<<<<
  2154. * Vec.exp_i(output, nr)
  2155. *
  2156. */
  2157. (void)(memcpy(__pyx_v_output, __pyx_v_vec, ((sizeof((__pyx_v_output[0]))) * __pyx_v_nr)));
  2158. /* "thinc/linalg.pxd":125
  2159. * cdef inline void exp(weight_t* output, const weight_t* vec, int32_t nr) nogil:
  2160. * memcpy(output, vec, sizeof(output[0]) * nr)
  2161. * Vec.exp_i(output, nr) # <<<<<<<<<<<<<<
  2162. *
  2163. * @staticmethod
  2164. */
  2165. __pyx_f_5thinc_6linalg_3Vec_exp_i(__pyx_v_output, __pyx_v_nr);
  2166. /* "thinc/linalg.pxd":123
  2167. *
  2168. * @staticmethod
  2169. * cdef inline void exp(weight_t* output, const weight_t* vec, int32_t nr) nogil: # <<<<<<<<<<<<<<
  2170. * memcpy(output, vec, sizeof(output[0]) * nr)
  2171. * Vec.exp_i(output, nr)
  2172. */
  2173. /* function exit code */
  2174. }
  2175. /* "thinc/linalg.pxd":128
  2176. *
  2177. * @staticmethod
  2178. * cdef inline void exp_i(weight_t* vec, int32_t nr) nogil: # <<<<<<<<<<<<<<
  2179. * cdef int i
  2180. * for i in range(nr):
  2181. */
  2182. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_exp_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, int32_t __pyx_v_nr) {
  2183. int __pyx_v_i;
  2184. int32_t __pyx_t_1;
  2185. int32_t __pyx_t_2;
  2186. int __pyx_t_3;
  2187. /* "thinc/linalg.pxd":130
  2188. * cdef inline void exp_i(weight_t* vec, int32_t nr) nogil:
  2189. * cdef int i
  2190. * for i in range(nr): # <<<<<<<<<<<<<<
  2191. * vec[i] = exp(vec[i])
  2192. *
  2193. */
  2194. __pyx_t_1 = __pyx_v_nr;
  2195. __pyx_t_2 = __pyx_t_1;
  2196. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2197. __pyx_v_i = __pyx_t_3;
  2198. /* "thinc/linalg.pxd":131
  2199. * cdef int i
  2200. * for i in range(nr):
  2201. * vec[i] = exp(vec[i]) # <<<<<<<<<<<<<<
  2202. *
  2203. * @staticmethod
  2204. */
  2205. (__pyx_v_vec[__pyx_v_i]) = exp((__pyx_v_vec[__pyx_v_i]));
  2206. }
  2207. /* "thinc/linalg.pxd":128
  2208. *
  2209. * @staticmethod
  2210. * cdef inline void exp_i(weight_t* vec, int32_t nr) nogil: # <<<<<<<<<<<<<<
  2211. * cdef int i
  2212. * for i in range(nr):
  2213. */
  2214. /* function exit code */
  2215. }
  2216. /* "thinc/linalg.pxd":134
  2217. *
  2218. * @staticmethod
  2219. * cdef inline void reciprocal_i(weight_t* vec, int32_t nr) nogil: # <<<<<<<<<<<<<<
  2220. * cdef int i
  2221. * for i in range(nr):
  2222. */
  2223. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Vec_reciprocal_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_vec, int32_t __pyx_v_nr) {
  2224. int __pyx_v_i;
  2225. int32_t __pyx_t_1;
  2226. int32_t __pyx_t_2;
  2227. int __pyx_t_3;
  2228. /* "thinc/linalg.pxd":136
  2229. * cdef inline void reciprocal_i(weight_t* vec, int32_t nr) nogil:
  2230. * cdef int i
  2231. * for i in range(nr): # <<<<<<<<<<<<<<
  2232. * vec[i] = 1.0 / vec[i]
  2233. *
  2234. */
  2235. __pyx_t_1 = __pyx_v_nr;
  2236. __pyx_t_2 = __pyx_t_1;
  2237. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2238. __pyx_v_i = __pyx_t_3;
  2239. /* "thinc/linalg.pxd":137
  2240. * cdef int i
  2241. * for i in range(nr):
  2242. * vec[i] = 1.0 / vec[i] # <<<<<<<<<<<<<<
  2243. *
  2244. *
  2245. */
  2246. (__pyx_v_vec[__pyx_v_i]) = (1.0 / (__pyx_v_vec[__pyx_v_i]));
  2247. }
  2248. /* "thinc/linalg.pxd":134
  2249. *
  2250. * @staticmethod
  2251. * cdef inline void reciprocal_i(weight_t* vec, int32_t nr) nogil: # <<<<<<<<<<<<<<
  2252. * cdef int i
  2253. * for i in range(nr):
  2254. */
  2255. /* function exit code */
  2256. }
  2257. /* "thinc/linalg.pxd":142
  2258. * cdef class VecVec:
  2259. * @staticmethod
  2260. * cdef inline void add(weight_t* output, # <<<<<<<<<<<<<<
  2261. * const weight_t* x,
  2262. * const weight_t* y,
  2263. */
  2264. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scale, int32_t __pyx_v_nr) {
  2265. /* "thinc/linalg.pxd":147
  2266. * weight_t scale,
  2267. * int32_t nr) nogil:
  2268. * memcpy(output, x, sizeof(output[0]) * nr) # <<<<<<<<<<<<<<
  2269. * VecVec.add_i(output, y, scale, nr)
  2270. *
  2271. */
  2272. (void)(memcpy(__pyx_v_output, __pyx_v_x, ((sizeof((__pyx_v_output[0]))) * __pyx_v_nr)));
  2273. /* "thinc/linalg.pxd":148
  2274. * int32_t nr) nogil:
  2275. * memcpy(output, x, sizeof(output[0]) * nr)
  2276. * VecVec.add_i(output, y, scale, nr) # <<<<<<<<<<<<<<
  2277. *
  2278. * @staticmethod
  2279. */
  2280. __pyx_f_5thinc_6linalg_6VecVec_add_i(__pyx_v_output, __pyx_v_y, __pyx_v_scale, __pyx_v_nr);
  2281. /* "thinc/linalg.pxd":142
  2282. * cdef class VecVec:
  2283. * @staticmethod
  2284. * cdef inline void add(weight_t* output, # <<<<<<<<<<<<<<
  2285. * const weight_t* x,
  2286. * const weight_t* y,
  2287. */
  2288. /* function exit code */
  2289. }
  2290. /* "thinc/linalg.pxd":151
  2291. *
  2292. * @staticmethod
  2293. * cdef inline void add_i(weight_t* x, # <<<<<<<<<<<<<<
  2294. * const weight_t* y,
  2295. * weight_t scale,
  2296. */
  2297. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scale, int32_t __pyx_v_nr) {
  2298. int __pyx_v_i;
  2299. int32_t __pyx_t_1;
  2300. int32_t __pyx_t_2;
  2301. int __pyx_t_3;
  2302. int __pyx_t_4;
  2303. /* "thinc/linalg.pxd":159
  2304. * blis.axpyv(blis.NO_CONJUGATE, nr, scale, <weight_t*>y, 1, x, 1)
  2305. * ELSE:
  2306. * for i in range(nr): # <<<<<<<<<<<<<<
  2307. * x[i] += y[i] * scale
  2308. *
  2309. */
  2310. __pyx_t_1 = __pyx_v_nr;
  2311. __pyx_t_2 = __pyx_t_1;
  2312. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2313. __pyx_v_i = __pyx_t_3;
  2314. /* "thinc/linalg.pxd":160
  2315. * ELSE:
  2316. * for i in range(nr):
  2317. * x[i] += y[i] * scale # <<<<<<<<<<<<<<
  2318. *
  2319. * @staticmethod
  2320. */
  2321. __pyx_t_4 = __pyx_v_i;
  2322. (__pyx_v_x[__pyx_t_4]) = ((__pyx_v_x[__pyx_t_4]) + ((__pyx_v_y[__pyx_v_i]) * __pyx_v_scale));
  2323. }
  2324. /* "thinc/linalg.pxd":151
  2325. *
  2326. * @staticmethod
  2327. * cdef inline void add_i(weight_t* x, # <<<<<<<<<<<<<<
  2328. * const weight_t* y,
  2329. * weight_t scale,
  2330. */
  2331. /* function exit code */
  2332. }
  2333. /* "thinc/linalg.pxd":163
  2334. *
  2335. * @staticmethod
  2336. * cdef inline void batch_add_i(weight_t* x, # <<<<<<<<<<<<<<
  2337. * const weight_t* y,
  2338. * weight_t scale,
  2339. */
  2340. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_batch_add_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scale, int32_t __pyx_v_nr, int32_t __pyx_v_nr_batch) {
  2341. CYTHON_UNUSED int __pyx_v__;
  2342. int32_t __pyx_t_1;
  2343. int32_t __pyx_t_2;
  2344. int __pyx_t_3;
  2345. /* "thinc/linalg.pxd":169
  2346. * # For fixed x, matrix of y
  2347. * cdef int i, _
  2348. * for _ in range(nr_batch): # <<<<<<<<<<<<<<
  2349. * VecVec.add_i(x,
  2350. * y, scale, nr)
  2351. */
  2352. __pyx_t_1 = __pyx_v_nr_batch;
  2353. __pyx_t_2 = __pyx_t_1;
  2354. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2355. __pyx_v__ = __pyx_t_3;
  2356. /* "thinc/linalg.pxd":170
  2357. * cdef int i, _
  2358. * for _ in range(nr_batch):
  2359. * VecVec.add_i(x, # <<<<<<<<<<<<<<
  2360. * y, scale, nr)
  2361. * y += nr
  2362. */
  2363. __pyx_f_5thinc_6linalg_6VecVec_add_i(__pyx_v_x, __pyx_v_y, __pyx_v_scale, __pyx_v_nr);
  2364. /* "thinc/linalg.pxd":172
  2365. * VecVec.add_i(x,
  2366. * y, scale, nr)
  2367. * y += nr # <<<<<<<<<<<<<<
  2368. *
  2369. * @staticmethod
  2370. */
  2371. __pyx_v_y = (__pyx_v_y + __pyx_v_nr);
  2372. }
  2373. /* "thinc/linalg.pxd":163
  2374. *
  2375. * @staticmethod
  2376. * cdef inline void batch_add_i(weight_t* x, # <<<<<<<<<<<<<<
  2377. * const weight_t* y,
  2378. * weight_t scale,
  2379. */
  2380. /* function exit code */
  2381. }
  2382. /* "thinc/linalg.pxd":175
  2383. *
  2384. * @staticmethod
  2385. * cdef inline void add_pow(weight_t* output, # <<<<<<<<<<<<<<
  2386. * const weight_t* x, const weight_t* y, weight_t power, int32_t nr) nogil:
  2387. * memcpy(output, x, sizeof(output[0]) * nr)
  2388. */
  2389. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add_pow(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_power, int32_t __pyx_v_nr) {
  2390. /* "thinc/linalg.pxd":177
  2391. * cdef inline void add_pow(weight_t* output,
  2392. * const weight_t* x, const weight_t* y, weight_t power, int32_t nr) nogil:
  2393. * memcpy(output, x, sizeof(output[0]) * nr) # <<<<<<<<<<<<<<
  2394. * VecVec.add_pow_i(output, y, power, nr)
  2395. *
  2396. */
  2397. (void)(memcpy(__pyx_v_output, __pyx_v_x, ((sizeof((__pyx_v_output[0]))) * __pyx_v_nr)));
  2398. /* "thinc/linalg.pxd":178
  2399. * const weight_t* x, const weight_t* y, weight_t power, int32_t nr) nogil:
  2400. * memcpy(output, x, sizeof(output[0]) * nr)
  2401. * VecVec.add_pow_i(output, y, power, nr) # <<<<<<<<<<<<<<
  2402. *
  2403. *
  2404. */
  2405. __pyx_f_5thinc_6linalg_6VecVec_add_pow_i(__pyx_v_output, __pyx_v_y, __pyx_v_power, __pyx_v_nr);
  2406. /* "thinc/linalg.pxd":175
  2407. *
  2408. * @staticmethod
  2409. * cdef inline void add_pow(weight_t* output, # <<<<<<<<<<<<<<
  2410. * const weight_t* x, const weight_t* y, weight_t power, int32_t nr) nogil:
  2411. * memcpy(output, x, sizeof(output[0]) * nr)
  2412. */
  2413. /* function exit code */
  2414. }
  2415. /* "thinc/linalg.pxd":182
  2416. *
  2417. * @staticmethod
  2418. * cdef inline void add_pow_i(weight_t* x, # <<<<<<<<<<<<<<
  2419. * const weight_t* y, weight_t power, int32_t nr) nogil:
  2420. * cdef int i
  2421. */
  2422. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_add_pow_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_power, int32_t __pyx_v_nr) {
  2423. int __pyx_v_i;
  2424. int32_t __pyx_t_1;
  2425. int32_t __pyx_t_2;
  2426. int __pyx_t_3;
  2427. int __pyx_t_4;
  2428. /* "thinc/linalg.pxd":185
  2429. * const weight_t* y, weight_t power, int32_t nr) nogil:
  2430. * cdef int i
  2431. * for i in range(nr): # <<<<<<<<<<<<<<
  2432. * x[i] += y[i] ** power
  2433. *
  2434. */
  2435. __pyx_t_1 = __pyx_v_nr;
  2436. __pyx_t_2 = __pyx_t_1;
  2437. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2438. __pyx_v_i = __pyx_t_3;
  2439. /* "thinc/linalg.pxd":186
  2440. * cdef int i
  2441. * for i in range(nr):
  2442. * x[i] += y[i] ** power # <<<<<<<<<<<<<<
  2443. *
  2444. * @staticmethod
  2445. */
  2446. __pyx_t_4 = __pyx_v_i;
  2447. (__pyx_v_x[__pyx_t_4]) = ((__pyx_v_x[__pyx_t_4]) + powf(((__pyx_t_5thinc_8typedefs_weight_t)(__pyx_v_y[__pyx_v_i])), __pyx_v_power));
  2448. }
  2449. /* "thinc/linalg.pxd":182
  2450. *
  2451. * @staticmethod
  2452. * cdef inline void add_pow_i(weight_t* x, # <<<<<<<<<<<<<<
  2453. * const weight_t* y, weight_t power, int32_t nr) nogil:
  2454. * cdef int i
  2455. */
  2456. /* function exit code */
  2457. }
  2458. /* "thinc/linalg.pxd":189
  2459. *
  2460. * @staticmethod
  2461. * cdef inline void mul(weight_t* output, # <<<<<<<<<<<<<<
  2462. * const weight_t* x, const weight_t* y, int32_t nr) nogil:
  2463. * memcpy(output, x, sizeof(output[0]) * nr)
  2464. */
  2465. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_mul(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr) {
  2466. /* "thinc/linalg.pxd":191
  2467. * cdef inline void mul(weight_t* output,
  2468. * const weight_t* x, const weight_t* y, int32_t nr) nogil:
  2469. * memcpy(output, x, sizeof(output[0]) * nr) # <<<<<<<<<<<<<<
  2470. * VecVec.mul_i(output, y, nr)
  2471. *
  2472. */
  2473. (void)(memcpy(__pyx_v_output, __pyx_v_x, ((sizeof((__pyx_v_output[0]))) * __pyx_v_nr)));
  2474. /* "thinc/linalg.pxd":192
  2475. * const weight_t* x, const weight_t* y, int32_t nr) nogil:
  2476. * memcpy(output, x, sizeof(output[0]) * nr)
  2477. * VecVec.mul_i(output, y, nr) # <<<<<<<<<<<<<<
  2478. *
  2479. * @staticmethod
  2480. */
  2481. __pyx_f_5thinc_6linalg_6VecVec_mul_i(__pyx_v_output, __pyx_v_y, __pyx_v_nr);
  2482. /* "thinc/linalg.pxd":189
  2483. *
  2484. * @staticmethod
  2485. * cdef inline void mul(weight_t* output, # <<<<<<<<<<<<<<
  2486. * const weight_t* x, const weight_t* y, int32_t nr) nogil:
  2487. * memcpy(output, x, sizeof(output[0]) * nr)
  2488. */
  2489. /* function exit code */
  2490. }
  2491. /* "thinc/linalg.pxd":195
  2492. *
  2493. * @staticmethod
  2494. * cdef inline void mul_i(weight_t* x, # <<<<<<<<<<<<<<
  2495. * const weight_t* y, int32_t nr) nogil:
  2496. * cdef int i
  2497. */
  2498. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6VecVec_mul_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr) {
  2499. int __pyx_v_i;
  2500. int32_t __pyx_t_1;
  2501. int32_t __pyx_t_2;
  2502. int __pyx_t_3;
  2503. int __pyx_t_4;
  2504. /* "thinc/linalg.pxd":198
  2505. * const weight_t* y, int32_t nr) nogil:
  2506. * cdef int i
  2507. * for i in range(nr): # <<<<<<<<<<<<<<
  2508. * x[i] *= y[i]
  2509. *
  2510. */
  2511. __pyx_t_1 = __pyx_v_nr;
  2512. __pyx_t_2 = __pyx_t_1;
  2513. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2514. __pyx_v_i = __pyx_t_3;
  2515. /* "thinc/linalg.pxd":199
  2516. * cdef int i
  2517. * for i in range(nr):
  2518. * x[i] *= y[i] # <<<<<<<<<<<<<<
  2519. *
  2520. * @staticmethod
  2521. */
  2522. __pyx_t_4 = __pyx_v_i;
  2523. (__pyx_v_x[__pyx_t_4]) = ((__pyx_v_x[__pyx_t_4]) * (__pyx_v_y[__pyx_v_i]));
  2524. }
  2525. /* "thinc/linalg.pxd":195
  2526. *
  2527. * @staticmethod
  2528. * cdef inline void mul_i(weight_t* x, # <<<<<<<<<<<<<<
  2529. * const weight_t* y, int32_t nr) nogil:
  2530. * cdef int i
  2531. */
  2532. /* function exit code */
  2533. }
  2534. /* "thinc/linalg.pxd":202
  2535. *
  2536. * @staticmethod
  2537. * cdef inline weight_t dot( # <<<<<<<<<<<<<<
  2538. * const weight_t* x, const weight_t* y, int32_t nr) nogil:
  2539. * cdef int i
  2540. */
  2541. static CYTHON_INLINE __pyx_t_5thinc_8typedefs_weight_t __pyx_f_5thinc_6linalg_6VecVec_dot(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr) {
  2542. int __pyx_v_i;
  2543. __pyx_t_5thinc_8typedefs_weight_t __pyx_v_total;
  2544. __pyx_t_5thinc_8typedefs_weight_t __pyx_r;
  2545. int32_t __pyx_t_1;
  2546. int32_t __pyx_t_2;
  2547. int __pyx_t_3;
  2548. /* "thinc/linalg.pxd":205
  2549. * const weight_t* x, const weight_t* y, int32_t nr) nogil:
  2550. * cdef int i
  2551. * cdef weight_t total = 0 # <<<<<<<<<<<<<<
  2552. * for i in range(nr):
  2553. * total += x[i] * y[i]
  2554. */
  2555. __pyx_v_total = 0.0;
  2556. /* "thinc/linalg.pxd":206
  2557. * cdef int i
  2558. * cdef weight_t total = 0
  2559. * for i in range(nr): # <<<<<<<<<<<<<<
  2560. * total += x[i] * y[i]
  2561. * return total
  2562. */
  2563. __pyx_t_1 = __pyx_v_nr;
  2564. __pyx_t_2 = __pyx_t_1;
  2565. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2566. __pyx_v_i = __pyx_t_3;
  2567. /* "thinc/linalg.pxd":207
  2568. * cdef weight_t total = 0
  2569. * for i in range(nr):
  2570. * total += x[i] * y[i] # <<<<<<<<<<<<<<
  2571. * return total
  2572. *
  2573. */
  2574. __pyx_v_total = (__pyx_v_total + ((__pyx_v_x[__pyx_v_i]) * (__pyx_v_y[__pyx_v_i])));
  2575. }
  2576. /* "thinc/linalg.pxd":208
  2577. * for i in range(nr):
  2578. * total += x[i] * y[i]
  2579. * return total # <<<<<<<<<<<<<<
  2580. *
  2581. * @staticmethod
  2582. */
  2583. __pyx_r = __pyx_v_total;
  2584. goto __pyx_L0;
  2585. /* "thinc/linalg.pxd":202
  2586. *
  2587. * @staticmethod
  2588. * cdef inline weight_t dot( # <<<<<<<<<<<<<<
  2589. * const weight_t* x, const weight_t* y, int32_t nr) nogil:
  2590. * cdef int i
  2591. */
  2592. /* function exit code */
  2593. __pyx_L0:;
  2594. return __pyx_r;
  2595. }
  2596. /* "thinc/linalg.pxd":211
  2597. *
  2598. * @staticmethod
  2599. * cdef inline int arg_max_if_true( # <<<<<<<<<<<<<<
  2600. * const weight_t* scores, const int* is_valid, const int n_classes) nogil:
  2601. * cdef int i
  2602. */
  2603. static CYTHON_INLINE int __pyx_f_5thinc_6linalg_6VecVec_arg_max_if_true(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_scores, int const *__pyx_v_is_valid, int const __pyx_v_n_classes) {
  2604. int __pyx_v_i;
  2605. int __pyx_v_best;
  2606. int __pyx_r;
  2607. int __pyx_t_1;
  2608. int __pyx_t_2;
  2609. int __pyx_t_3;
  2610. int __pyx_t_4;
  2611. int __pyx_t_5;
  2612. /* "thinc/linalg.pxd":214
  2613. * const weight_t* scores, const int* is_valid, const int n_classes) nogil:
  2614. * cdef int i
  2615. * cdef int best = -1 # <<<<<<<<<<<<<<
  2616. * for i in range(n_classes):
  2617. * if is_valid[i] and (best == -1 or scores[i] > scores[best]):
  2618. */
  2619. __pyx_v_best = -1;
  2620. /* "thinc/linalg.pxd":215
  2621. * cdef int i
  2622. * cdef int best = -1
  2623. * for i in range(n_classes): # <<<<<<<<<<<<<<
  2624. * if is_valid[i] and (best == -1 or scores[i] > scores[best]):
  2625. * best = i
  2626. */
  2627. __pyx_t_1 = __pyx_v_n_classes;
  2628. __pyx_t_2 = __pyx_t_1;
  2629. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2630. __pyx_v_i = __pyx_t_3;
  2631. /* "thinc/linalg.pxd":216
  2632. * cdef int best = -1
  2633. * for i in range(n_classes):
  2634. * if is_valid[i] and (best == -1 or scores[i] > scores[best]): # <<<<<<<<<<<<<<
  2635. * best = i
  2636. * return best
  2637. */
  2638. __pyx_t_5 = ((__pyx_v_is_valid[__pyx_v_i]) != 0);
  2639. if (__pyx_t_5) {
  2640. } else {
  2641. __pyx_t_4 = __pyx_t_5;
  2642. goto __pyx_L6_bool_binop_done;
  2643. }
  2644. __pyx_t_5 = ((__pyx_v_best == -1L) != 0);
  2645. if (!__pyx_t_5) {
  2646. } else {
  2647. __pyx_t_4 = __pyx_t_5;
  2648. goto __pyx_L6_bool_binop_done;
  2649. }
  2650. __pyx_t_5 = (((__pyx_v_scores[__pyx_v_i]) > (__pyx_v_scores[__pyx_v_best])) != 0);
  2651. __pyx_t_4 = __pyx_t_5;
  2652. __pyx_L6_bool_binop_done:;
  2653. if (__pyx_t_4) {
  2654. /* "thinc/linalg.pxd":217
  2655. * for i in range(n_classes):
  2656. * if is_valid[i] and (best == -1 or scores[i] > scores[best]):
  2657. * best = i # <<<<<<<<<<<<<<
  2658. * return best
  2659. *
  2660. */
  2661. __pyx_v_best = __pyx_v_i;
  2662. /* "thinc/linalg.pxd":216
  2663. * cdef int best = -1
  2664. * for i in range(n_classes):
  2665. * if is_valid[i] and (best == -1 or scores[i] > scores[best]): # <<<<<<<<<<<<<<
  2666. * best = i
  2667. * return best
  2668. */
  2669. }
  2670. }
  2671. /* "thinc/linalg.pxd":218
  2672. * if is_valid[i] and (best == -1 or scores[i] > scores[best]):
  2673. * best = i
  2674. * return best # <<<<<<<<<<<<<<
  2675. *
  2676. * @staticmethod
  2677. */
  2678. __pyx_r = __pyx_v_best;
  2679. goto __pyx_L0;
  2680. /* "thinc/linalg.pxd":211
  2681. *
  2682. * @staticmethod
  2683. * cdef inline int arg_max_if_true( # <<<<<<<<<<<<<<
  2684. * const weight_t* scores, const int* is_valid, const int n_classes) nogil:
  2685. * cdef int i
  2686. */
  2687. /* function exit code */
  2688. __pyx_L0:;
  2689. return __pyx_r;
  2690. }
  2691. /* "thinc/linalg.pxd":221
  2692. *
  2693. * @staticmethod
  2694. * cdef inline int arg_max_if_zero( # <<<<<<<<<<<<<<
  2695. * const weight_t* scores, const weight_t* costs, const int n_classes) nogil:
  2696. * cdef int i
  2697. */
  2698. static CYTHON_INLINE int __pyx_f_5thinc_6linalg_6VecVec_arg_max_if_zero(__pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_scores, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_costs, int const __pyx_v_n_classes) {
  2699. int __pyx_v_i;
  2700. int __pyx_v_best;
  2701. int __pyx_r;
  2702. int __pyx_t_1;
  2703. int __pyx_t_2;
  2704. int __pyx_t_3;
  2705. int __pyx_t_4;
  2706. int __pyx_t_5;
  2707. /* "thinc/linalg.pxd":224
  2708. * const weight_t* scores, const weight_t* costs, const int n_classes) nogil:
  2709. * cdef int i
  2710. * cdef int best = -1 # <<<<<<<<<<<<<<
  2711. * for i in range(n_classes):
  2712. * if costs[i] == 0 and (best == -1 or scores[i] > scores[best]):
  2713. */
  2714. __pyx_v_best = -1;
  2715. /* "thinc/linalg.pxd":225
  2716. * cdef int i
  2717. * cdef int best = -1
  2718. * for i in range(n_classes): # <<<<<<<<<<<<<<
  2719. * if costs[i] == 0 and (best == -1 or scores[i] > scores[best]):
  2720. * best = i
  2721. */
  2722. __pyx_t_1 = __pyx_v_n_classes;
  2723. __pyx_t_2 = __pyx_t_1;
  2724. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2725. __pyx_v_i = __pyx_t_3;
  2726. /* "thinc/linalg.pxd":226
  2727. * cdef int best = -1
  2728. * for i in range(n_classes):
  2729. * if costs[i] == 0 and (best == -1 or scores[i] > scores[best]): # <<<<<<<<<<<<<<
  2730. * best = i
  2731. * return best
  2732. */
  2733. __pyx_t_5 = (((__pyx_v_costs[__pyx_v_i]) == 0.0) != 0);
  2734. if (__pyx_t_5) {
  2735. } else {
  2736. __pyx_t_4 = __pyx_t_5;
  2737. goto __pyx_L6_bool_binop_done;
  2738. }
  2739. __pyx_t_5 = ((__pyx_v_best == -1L) != 0);
  2740. if (!__pyx_t_5) {
  2741. } else {
  2742. __pyx_t_4 = __pyx_t_5;
  2743. goto __pyx_L6_bool_binop_done;
  2744. }
  2745. __pyx_t_5 = (((__pyx_v_scores[__pyx_v_i]) > (__pyx_v_scores[__pyx_v_best])) != 0);
  2746. __pyx_t_4 = __pyx_t_5;
  2747. __pyx_L6_bool_binop_done:;
  2748. if (__pyx_t_4) {
  2749. /* "thinc/linalg.pxd":227
  2750. * for i in range(n_classes):
  2751. * if costs[i] == 0 and (best == -1 or scores[i] > scores[best]):
  2752. * best = i # <<<<<<<<<<<<<<
  2753. * return best
  2754. *
  2755. */
  2756. __pyx_v_best = __pyx_v_i;
  2757. /* "thinc/linalg.pxd":226
  2758. * cdef int best = -1
  2759. * for i in range(n_classes):
  2760. * if costs[i] == 0 and (best == -1 or scores[i] > scores[best]): # <<<<<<<<<<<<<<
  2761. * best = i
  2762. * return best
  2763. */
  2764. }
  2765. }
  2766. /* "thinc/linalg.pxd":228
  2767. * if costs[i] == 0 and (best == -1 or scores[i] > scores[best]):
  2768. * best = i
  2769. * return best # <<<<<<<<<<<<<<
  2770. *
  2771. *
  2772. */
  2773. __pyx_r = __pyx_v_best;
  2774. goto __pyx_L0;
  2775. /* "thinc/linalg.pxd":221
  2776. *
  2777. * @staticmethod
  2778. * cdef inline int arg_max_if_zero( # <<<<<<<<<<<<<<
  2779. * const weight_t* scores, const weight_t* costs, const int n_classes) nogil:
  2780. * cdef int i
  2781. */
  2782. /* function exit code */
  2783. __pyx_L0:;
  2784. return __pyx_r;
  2785. }
  2786. /* "thinc/linalg.pxd":233
  2787. * cdef class Mat:
  2788. * @staticmethod
  2789. * cdef inline void mean_row(weight_t* Ex, # <<<<<<<<<<<<<<
  2790. * const weight_t* mat, int32_t nr_row, int32_t nr_col) nogil:
  2791. * memset(Ex, 0, sizeof(Ex[0]) * nr_col)
  2792. */
  2793. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Mat_mean_row(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_Ex, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col) {
  2794. int32_t __pyx_v_i;
  2795. int32_t __pyx_t_1;
  2796. int32_t __pyx_t_2;
  2797. int32_t __pyx_t_3;
  2798. /* "thinc/linalg.pxd":235
  2799. * cdef inline void mean_row(weight_t* Ex,
  2800. * const weight_t* mat, int32_t nr_row, int32_t nr_col) nogil:
  2801. * memset(Ex, 0, sizeof(Ex[0]) * nr_col) # <<<<<<<<<<<<<<
  2802. * for i in range(nr_row):
  2803. * VecVec.add_i(Ex, &mat[i * nr_col], 1.0, nr_col)
  2804. */
  2805. (void)(memset(__pyx_v_Ex, 0, ((sizeof((__pyx_v_Ex[0]))) * __pyx_v_nr_col)));
  2806. /* "thinc/linalg.pxd":236
  2807. * const weight_t* mat, int32_t nr_row, int32_t nr_col) nogil:
  2808. * memset(Ex, 0, sizeof(Ex[0]) * nr_col)
  2809. * for i in range(nr_row): # <<<<<<<<<<<<<<
  2810. * VecVec.add_i(Ex, &mat[i * nr_col], 1.0, nr_col)
  2811. * Vec.mul_i(Ex, 1.0 / nr_row, nr_col)
  2812. */
  2813. __pyx_t_1 = __pyx_v_nr_row;
  2814. __pyx_t_2 = __pyx_t_1;
  2815. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  2816. __pyx_v_i = __pyx_t_3;
  2817. /* "thinc/linalg.pxd":237
  2818. * memset(Ex, 0, sizeof(Ex[0]) * nr_col)
  2819. * for i in range(nr_row):
  2820. * VecVec.add_i(Ex, &mat[i * nr_col], 1.0, nr_col) # <<<<<<<<<<<<<<
  2821. * Vec.mul_i(Ex, 1.0 / nr_row, nr_col)
  2822. *
  2823. */
  2824. __pyx_f_5thinc_6linalg_6VecVec_add_i(__pyx_v_Ex, (&(__pyx_v_mat[(__pyx_v_i * __pyx_v_nr_col)])), 1.0, __pyx_v_nr_col);
  2825. }
  2826. /* "thinc/linalg.pxd":238
  2827. * for i in range(nr_row):
  2828. * VecVec.add_i(Ex, &mat[i * nr_col], 1.0, nr_col)
  2829. * Vec.mul_i(Ex, 1.0 / nr_row, nr_col) # <<<<<<<<<<<<<<
  2830. *
  2831. * @staticmethod
  2832. */
  2833. __pyx_f_5thinc_6linalg_3Vec_mul_i(__pyx_v_Ex, (1.0 / __pyx_v_nr_row), __pyx_v_nr_col);
  2834. /* "thinc/linalg.pxd":233
  2835. * cdef class Mat:
  2836. * @staticmethod
  2837. * cdef inline void mean_row(weight_t* Ex, # <<<<<<<<<<<<<<
  2838. * const weight_t* mat, int32_t nr_row, int32_t nr_col) nogil:
  2839. * memset(Ex, 0, sizeof(Ex[0]) * nr_col)
  2840. */
  2841. /* function exit code */
  2842. }
  2843. /* "thinc/linalg.pxd":241
  2844. *
  2845. * @staticmethod
  2846. * cdef inline void var_row(weight_t* Vx, # <<<<<<<<<<<<<<
  2847. * const weight_t* mat, const weight_t* Ex,
  2848. * int32_t nr_row, int32_t nr_col, weight_t eps) nogil:
  2849. */
  2850. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_3Mat_var_row(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_Vx, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_Ex, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_eps) {
  2851. __pyx_t_5thinc_8typedefs_weight_t __pyx_v_sum_;
  2852. __pyx_t_5thinc_8typedefs_weight_t __pyx_v_sum2;
  2853. int32_t __pyx_v_i;
  2854. int32_t __pyx_v_j;
  2855. __pyx_t_5thinc_8typedefs_weight_t __pyx_v_x;
  2856. int __pyx_t_1;
  2857. int __pyx_t_2;
  2858. int32_t __pyx_t_3;
  2859. int32_t __pyx_t_4;
  2860. int32_t __pyx_t_5;
  2861. int32_t __pyx_t_6;
  2862. int32_t __pyx_t_7;
  2863. int32_t __pyx_t_8;
  2864. /* "thinc/linalg.pxd":245
  2865. * int32_t nr_row, int32_t nr_col, weight_t eps) nogil:
  2866. * # From https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  2867. * if nr_row == 0 or nr_col == 0: # <<<<<<<<<<<<<<
  2868. * return
  2869. * cdef weight_t sum_, sum2
  2870. */
  2871. __pyx_t_2 = ((__pyx_v_nr_row == 0) != 0);
  2872. if (!__pyx_t_2) {
  2873. } else {
  2874. __pyx_t_1 = __pyx_t_2;
  2875. goto __pyx_L4_bool_binop_done;
  2876. }
  2877. __pyx_t_2 = ((__pyx_v_nr_col == 0) != 0);
  2878. __pyx_t_1 = __pyx_t_2;
  2879. __pyx_L4_bool_binop_done:;
  2880. if (__pyx_t_1) {
  2881. /* "thinc/linalg.pxd":246
  2882. * # From https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  2883. * if nr_row == 0 or nr_col == 0:
  2884. * return # <<<<<<<<<<<<<<
  2885. * cdef weight_t sum_, sum2
  2886. * for i in range(nr_col):
  2887. */
  2888. goto __pyx_L0;
  2889. /* "thinc/linalg.pxd":245
  2890. * int32_t nr_row, int32_t nr_col, weight_t eps) nogil:
  2891. * # From https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  2892. * if nr_row == 0 or nr_col == 0: # <<<<<<<<<<<<<<
  2893. * return
  2894. * cdef weight_t sum_, sum2
  2895. */
  2896. }
  2897. /* "thinc/linalg.pxd":248
  2898. * return
  2899. * cdef weight_t sum_, sum2
  2900. * for i in range(nr_col): # <<<<<<<<<<<<<<
  2901. * sum_ = 0.0
  2902. * sum2 = 0.0
  2903. */
  2904. __pyx_t_3 = __pyx_v_nr_col;
  2905. __pyx_t_4 = __pyx_t_3;
  2906. for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
  2907. __pyx_v_i = __pyx_t_5;
  2908. /* "thinc/linalg.pxd":249
  2909. * cdef weight_t sum_, sum2
  2910. * for i in range(nr_col):
  2911. * sum_ = 0.0 # <<<<<<<<<<<<<<
  2912. * sum2 = 0.0
  2913. * for j in range(nr_row):
  2914. */
  2915. __pyx_v_sum_ = 0.0;
  2916. /* "thinc/linalg.pxd":250
  2917. * for i in range(nr_col):
  2918. * sum_ = 0.0
  2919. * sum2 = 0.0 # <<<<<<<<<<<<<<
  2920. * for j in range(nr_row):
  2921. * x = mat[j * nr_col + i]
  2922. */
  2923. __pyx_v_sum2 = 0.0;
  2924. /* "thinc/linalg.pxd":251
  2925. * sum_ = 0.0
  2926. * sum2 = 0.0
  2927. * for j in range(nr_row): # <<<<<<<<<<<<<<
  2928. * x = mat[j * nr_col + i]
  2929. * sum2 += (x - Ex[i]) ** 2
  2930. */
  2931. __pyx_t_6 = __pyx_v_nr_row;
  2932. __pyx_t_7 = __pyx_t_6;
  2933. for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
  2934. __pyx_v_j = __pyx_t_8;
  2935. /* "thinc/linalg.pxd":252
  2936. * sum2 = 0.0
  2937. * for j in range(nr_row):
  2938. * x = mat[j * nr_col + i] # <<<<<<<<<<<<<<
  2939. * sum2 += (x - Ex[i]) ** 2
  2940. * sum_ += x - Ex[i]
  2941. */
  2942. __pyx_v_x = (__pyx_v_mat[((__pyx_v_j * __pyx_v_nr_col) + __pyx_v_i)]);
  2943. /* "thinc/linalg.pxd":253
  2944. * for j in range(nr_row):
  2945. * x = mat[j * nr_col + i]
  2946. * sum2 += (x - Ex[i]) ** 2 # <<<<<<<<<<<<<<
  2947. * sum_ += x - Ex[i]
  2948. * Vx[i] = (sum2 - sum_**2 / nr_row) / nr_row
  2949. */
  2950. __pyx_v_sum2 = (__pyx_v_sum2 + powf((__pyx_v_x - (__pyx_v_Ex[__pyx_v_i])), 2.0));
  2951. /* "thinc/linalg.pxd":254
  2952. * x = mat[j * nr_col + i]
  2953. * sum2 += (x - Ex[i]) ** 2
  2954. * sum_ += x - Ex[i] # <<<<<<<<<<<<<<
  2955. * Vx[i] = (sum2 - sum_**2 / nr_row) / nr_row
  2956. * Vx[i] += eps
  2957. */
  2958. __pyx_v_sum_ = (__pyx_v_sum_ + (__pyx_v_x - (__pyx_v_Ex[__pyx_v_i])));
  2959. }
  2960. /* "thinc/linalg.pxd":255
  2961. * sum2 += (x - Ex[i]) ** 2
  2962. * sum_ += x - Ex[i]
  2963. * Vx[i] = (sum2 - sum_**2 / nr_row) / nr_row # <<<<<<<<<<<<<<
  2964. * Vx[i] += eps
  2965. *
  2966. */
  2967. (__pyx_v_Vx[__pyx_v_i]) = ((__pyx_v_sum2 - (powf(__pyx_v_sum_, 2.0) / __pyx_v_nr_row)) / __pyx_v_nr_row);
  2968. /* "thinc/linalg.pxd":256
  2969. * sum_ += x - Ex[i]
  2970. * Vx[i] = (sum2 - sum_**2 / nr_row) / nr_row
  2971. * Vx[i] += eps # <<<<<<<<<<<<<<
  2972. *
  2973. *
  2974. */
  2975. __pyx_t_6 = __pyx_v_i;
  2976. (__pyx_v_Vx[__pyx_t_6]) = ((__pyx_v_Vx[__pyx_t_6]) + __pyx_v_eps);
  2977. }
  2978. /* "thinc/linalg.pxd":241
  2979. *
  2980. * @staticmethod
  2981. * cdef inline void var_row(weight_t* Vx, # <<<<<<<<<<<<<<
  2982. * const weight_t* mat, const weight_t* Ex,
  2983. * int32_t nr_row, int32_t nr_col, weight_t eps) nogil:
  2984. */
  2985. /* function exit code */
  2986. __pyx_L0:;
  2987. }
  2988. /* "thinc/linalg.pxd":261
  2989. * cdef class MatVec:
  2990. * @staticmethod
  2991. * cdef inline void add_i(weight_t* mat, # <<<<<<<<<<<<<<
  2992. * const weight_t* vec, weight_t scale, int32_t nr_row, int32_t nr_col) nogil:
  2993. * cdef int i
  2994. */
  2995. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_add_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, __pyx_t_5thinc_8typedefs_weight_t __pyx_v_scale, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col) {
  2996. int __pyx_v_i;
  2997. int32_t __pyx_t_1;
  2998. int32_t __pyx_t_2;
  2999. int __pyx_t_3;
  3000. /* "thinc/linalg.pxd":264
  3001. * const weight_t* vec, weight_t scale, int32_t nr_row, int32_t nr_col) nogil:
  3002. * cdef int i
  3003. * for i in range(nr_row): # <<<<<<<<<<<<<<
  3004. * VecVec.add_i(mat + (i * nr_col),
  3005. * vec, scale, nr_col)
  3006. */
  3007. __pyx_t_1 = __pyx_v_nr_row;
  3008. __pyx_t_2 = __pyx_t_1;
  3009. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  3010. __pyx_v_i = __pyx_t_3;
  3011. /* "thinc/linalg.pxd":265
  3012. * cdef int i
  3013. * for i in range(nr_row):
  3014. * VecVec.add_i(mat + (i * nr_col), # <<<<<<<<<<<<<<
  3015. * vec, scale, nr_col)
  3016. *
  3017. */
  3018. __pyx_f_5thinc_6linalg_6VecVec_add_i((__pyx_v_mat + (__pyx_v_i * __pyx_v_nr_col)), __pyx_v_vec, __pyx_v_scale, __pyx_v_nr_col);
  3019. }
  3020. /* "thinc/linalg.pxd":261
  3021. * cdef class MatVec:
  3022. * @staticmethod
  3023. * cdef inline void add_i(weight_t* mat, # <<<<<<<<<<<<<<
  3024. * const weight_t* vec, weight_t scale, int32_t nr_row, int32_t nr_col) nogil:
  3025. * cdef int i
  3026. */
  3027. /* function exit code */
  3028. }
  3029. /* "thinc/linalg.pxd":269
  3030. *
  3031. * @staticmethod
  3032. * cdef inline void mul(weight_t* output, # <<<<<<<<<<<<<<
  3033. * const weight_t* mat,
  3034. * const weight_t* vec,
  3035. */
  3036. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_mul(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col) {
  3037. /* "thinc/linalg.pxd":273
  3038. * const weight_t* vec,
  3039. * int32_t nr_row, int32_t nr_col) nogil:
  3040. * memcpy(output, mat, sizeof(output[0]) * nr_row * nr_col) # <<<<<<<<<<<<<<
  3041. * MatVec.mul_i(output, vec, nr_row, nr_col)
  3042. *
  3043. */
  3044. (void)(memcpy(__pyx_v_output, __pyx_v_mat, (((sizeof((__pyx_v_output[0]))) * __pyx_v_nr_row) * __pyx_v_nr_col)));
  3045. /* "thinc/linalg.pxd":274
  3046. * int32_t nr_row, int32_t nr_col) nogil:
  3047. * memcpy(output, mat, sizeof(output[0]) * nr_row * nr_col)
  3048. * MatVec.mul_i(output, vec, nr_row, nr_col) # <<<<<<<<<<<<<<
  3049. *
  3050. * @staticmethod
  3051. */
  3052. __pyx_f_5thinc_6linalg_6MatVec_mul_i(__pyx_v_output, __pyx_v_vec, __pyx_v_nr_row, __pyx_v_nr_col);
  3053. /* "thinc/linalg.pxd":269
  3054. *
  3055. * @staticmethod
  3056. * cdef inline void mul(weight_t* output, # <<<<<<<<<<<<<<
  3057. * const weight_t* mat,
  3058. * const weight_t* vec,
  3059. */
  3060. /* function exit code */
  3061. }
  3062. /* "thinc/linalg.pxd":277
  3063. *
  3064. * @staticmethod
  3065. * cdef inline void mul_i(weight_t* mat, # <<<<<<<<<<<<<<
  3066. * const weight_t* vec,
  3067. * int32_t nr_row, int32_t nr_col) nogil:
  3068. */
  3069. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_mul_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col) {
  3070. int __pyx_v_i;
  3071. int __pyx_v_row;
  3072. int __pyx_v_col;
  3073. int32_t __pyx_t_1;
  3074. int32_t __pyx_t_2;
  3075. int __pyx_t_3;
  3076. int32_t __pyx_t_4;
  3077. int32_t __pyx_t_5;
  3078. int __pyx_t_6;
  3079. int __pyx_t_7;
  3080. /* "thinc/linalg.pxd":281
  3081. * int32_t nr_row, int32_t nr_col) nogil:
  3082. * cdef int i, row, col
  3083. * for i in range(nr_row): # <<<<<<<<<<<<<<
  3084. * row = i * nr_col
  3085. * for col in range(nr_col):
  3086. */
  3087. __pyx_t_1 = __pyx_v_nr_row;
  3088. __pyx_t_2 = __pyx_t_1;
  3089. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  3090. __pyx_v_i = __pyx_t_3;
  3091. /* "thinc/linalg.pxd":282
  3092. * cdef int i, row, col
  3093. * for i in range(nr_row):
  3094. * row = i * nr_col # <<<<<<<<<<<<<<
  3095. * for col in range(nr_col):
  3096. * mat[row + col] *= vec[col]
  3097. */
  3098. __pyx_v_row = (__pyx_v_i * __pyx_v_nr_col);
  3099. /* "thinc/linalg.pxd":283
  3100. * for i in range(nr_row):
  3101. * row = i * nr_col
  3102. * for col in range(nr_col): # <<<<<<<<<<<<<<
  3103. * mat[row + col] *= vec[col]
  3104. *
  3105. */
  3106. __pyx_t_4 = __pyx_v_nr_col;
  3107. __pyx_t_5 = __pyx_t_4;
  3108. for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
  3109. __pyx_v_col = __pyx_t_6;
  3110. /* "thinc/linalg.pxd":284
  3111. * row = i * nr_col
  3112. * for col in range(nr_col):
  3113. * mat[row + col] *= vec[col] # <<<<<<<<<<<<<<
  3114. *
  3115. * @staticmethod
  3116. */
  3117. __pyx_t_7 = (__pyx_v_row + __pyx_v_col);
  3118. (__pyx_v_mat[__pyx_t_7]) = ((__pyx_v_mat[__pyx_t_7]) * (__pyx_v_vec[__pyx_v_col]));
  3119. }
  3120. }
  3121. /* "thinc/linalg.pxd":277
  3122. *
  3123. * @staticmethod
  3124. * cdef inline void mul_i(weight_t* mat, # <<<<<<<<<<<<<<
  3125. * const weight_t* vec,
  3126. * int32_t nr_row, int32_t nr_col) nogil:
  3127. */
  3128. /* function exit code */
  3129. }
  3130. /* "thinc/linalg.pxd":287
  3131. *
  3132. * @staticmethod
  3133. * cdef inline void dot(weight_t* output, # <<<<<<<<<<<<<<
  3134. * const weight_t* mat,
  3135. * const weight_t* vec,
  3136. */
  3137. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_dot(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col) {
  3138. int __pyx_v_i;
  3139. int __pyx_v_row;
  3140. int __pyx_v_col;
  3141. CYTHON_UNUSED double __pyx_v_zero;
  3142. int32_t __pyx_t_1;
  3143. int32_t __pyx_t_2;
  3144. int __pyx_t_3;
  3145. int32_t __pyx_t_4;
  3146. int32_t __pyx_t_5;
  3147. int __pyx_t_6;
  3148. int __pyx_t_7;
  3149. /* "thinc/linalg.pxd":292
  3150. * int32_t nr_row, int32_t nr_col) nogil:
  3151. * cdef int i, row, col
  3152. * cdef double zero = 0.0 # <<<<<<<<<<<<<<
  3153. * IF USE_BLAS:
  3154. * blis.gemv(
  3155. */
  3156. __pyx_v_zero = 0.0;
  3157. /* "thinc/linalg.pxd":306
  3158. * )
  3159. * ELSE:
  3160. * for i in range(nr_row): # <<<<<<<<<<<<<<
  3161. * row = i * nr_col
  3162. * for col in range(nr_col):
  3163. */
  3164. __pyx_t_1 = __pyx_v_nr_row;
  3165. __pyx_t_2 = __pyx_t_1;
  3166. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  3167. __pyx_v_i = __pyx_t_3;
  3168. /* "thinc/linalg.pxd":307
  3169. * ELSE:
  3170. * for i in range(nr_row):
  3171. * row = i * nr_col # <<<<<<<<<<<<<<
  3172. * for col in range(nr_col):
  3173. * output[i] += mat[row + col] * vec[col]
  3174. */
  3175. __pyx_v_row = (__pyx_v_i * __pyx_v_nr_col);
  3176. /* "thinc/linalg.pxd":308
  3177. * for i in range(nr_row):
  3178. * row = i * nr_col
  3179. * for col in range(nr_col): # <<<<<<<<<<<<<<
  3180. * output[i] += mat[row + col] * vec[col]
  3181. *
  3182. */
  3183. __pyx_t_4 = __pyx_v_nr_col;
  3184. __pyx_t_5 = __pyx_t_4;
  3185. for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
  3186. __pyx_v_col = __pyx_t_6;
  3187. /* "thinc/linalg.pxd":309
  3188. * row = i * nr_col
  3189. * for col in range(nr_col):
  3190. * output[i] += mat[row + col] * vec[col] # <<<<<<<<<<<<<<
  3191. *
  3192. * @staticmethod
  3193. */
  3194. __pyx_t_7 = __pyx_v_i;
  3195. (__pyx_v_output[__pyx_t_7]) = ((__pyx_v_output[__pyx_t_7]) + ((__pyx_v_mat[(__pyx_v_row + __pyx_v_col)]) * (__pyx_v_vec[__pyx_v_col])));
  3196. }
  3197. }
  3198. /* "thinc/linalg.pxd":287
  3199. *
  3200. * @staticmethod
  3201. * cdef inline void dot(weight_t* output, # <<<<<<<<<<<<<<
  3202. * const weight_t* mat,
  3203. * const weight_t* vec,
  3204. */
  3205. /* function exit code */
  3206. }
  3207. /* "thinc/linalg.pxd":312
  3208. *
  3209. * @staticmethod
  3210. * cdef inline void batch_dot(weight_t* output, # <<<<<<<<<<<<<<
  3211. * const weight_t* mat,
  3212. * const weight_t* vec,
  3213. */
  3214. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_batch_dot(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col, int32_t __pyx_v_nr_batch) {
  3215. CYTHON_UNUSED double __pyx_v_one;
  3216. CYTHON_UNUSED int32_t __pyx_v_b;
  3217. int32_t __pyx_t_1;
  3218. int32_t __pyx_t_2;
  3219. int32_t __pyx_t_3;
  3220. /* "thinc/linalg.pxd":327
  3221. * # out: M * N
  3222. * cdef int i, row, col
  3223. * cdef double one = 1.0 # <<<<<<<<<<<<<<
  3224. * IF USE_BLAS:
  3225. * blis.gemm(
  3226. */
  3227. __pyx_v_one = 1.0;
  3228. /* "thinc/linalg.pxd":347
  3229. * 1)
  3230. * ELSE:
  3231. * for b in range(nr_batch): # <<<<<<<<<<<<<<
  3232. * MatVec.dot(output,
  3233. * mat, vec, nr_row, nr_col)
  3234. */
  3235. __pyx_t_1 = __pyx_v_nr_batch;
  3236. __pyx_t_2 = __pyx_t_1;
  3237. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  3238. __pyx_v_b = __pyx_t_3;
  3239. /* "thinc/linalg.pxd":348
  3240. * ELSE:
  3241. * for b in range(nr_batch):
  3242. * MatVec.dot(output, # <<<<<<<<<<<<<<
  3243. * mat, vec, nr_row, nr_col)
  3244. * output += nr_row
  3245. */
  3246. __pyx_f_5thinc_6linalg_6MatVec_dot(__pyx_v_output, __pyx_v_mat, __pyx_v_vec, __pyx_v_nr_row, __pyx_v_nr_col);
  3247. /* "thinc/linalg.pxd":350
  3248. * MatVec.dot(output,
  3249. * mat, vec, nr_row, nr_col)
  3250. * output += nr_row # <<<<<<<<<<<<<<
  3251. * vec += nr_col
  3252. *
  3253. */
  3254. __pyx_v_output = (__pyx_v_output + __pyx_v_nr_row);
  3255. /* "thinc/linalg.pxd":351
  3256. * mat, vec, nr_row, nr_col)
  3257. * output += nr_row
  3258. * vec += nr_col # <<<<<<<<<<<<<<
  3259. *
  3260. * @staticmethod
  3261. */
  3262. __pyx_v_vec = (__pyx_v_vec + __pyx_v_nr_col);
  3263. }
  3264. /* "thinc/linalg.pxd":312
  3265. *
  3266. * @staticmethod
  3267. * cdef inline void batch_dot(weight_t* output, # <<<<<<<<<<<<<<
  3268. * const weight_t* mat,
  3269. * const weight_t* vec,
  3270. */
  3271. /* function exit code */
  3272. }
  3273. /* "thinc/linalg.pxd":354
  3274. *
  3275. * @staticmethod
  3276. * cdef inline void T_dot(weight_t* output, # <<<<<<<<<<<<<<
  3277. * const weight_t* mat,
  3278. * const weight_t* vec,
  3279. */
  3280. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_T_dot(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col) {
  3281. int __pyx_v_row;
  3282. int __pyx_v_col;
  3283. CYTHON_UNUSED double __pyx_v_zero;
  3284. CYTHON_UNUSED double __pyx_v_one;
  3285. int32_t __pyx_t_1;
  3286. int32_t __pyx_t_2;
  3287. int __pyx_t_3;
  3288. int32_t __pyx_t_4;
  3289. int32_t __pyx_t_5;
  3290. int __pyx_t_6;
  3291. int __pyx_t_7;
  3292. /* "thinc/linalg.pxd":360
  3293. * int32_t nr_col) nogil:
  3294. * cdef int i, row, col
  3295. * cdef double zero = 0.0 # <<<<<<<<<<<<<<
  3296. * cdef double one = 1.0
  3297. * IF USE_BLAS:
  3298. */
  3299. __pyx_v_zero = 0.0;
  3300. /* "thinc/linalg.pxd":361
  3301. * cdef int i, row, col
  3302. * cdef double zero = 0.0
  3303. * cdef double one = 1.0 # <<<<<<<<<<<<<<
  3304. * IF USE_BLAS:
  3305. * blis.gemv(
  3306. */
  3307. __pyx_v_one = 1.0;
  3308. /* "thinc/linalg.pxd":374
  3309. * )
  3310. * ELSE:
  3311. * for row in range(nr_row): # <<<<<<<<<<<<<<
  3312. * for col in range(nr_col):
  3313. * output[col] += vec[row] * mat[(row * nr_col) + col]
  3314. */
  3315. __pyx_t_1 = __pyx_v_nr_row;
  3316. __pyx_t_2 = __pyx_t_1;
  3317. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  3318. __pyx_v_row = __pyx_t_3;
  3319. /* "thinc/linalg.pxd":375
  3320. * ELSE:
  3321. * for row in range(nr_row):
  3322. * for col in range(nr_col): # <<<<<<<<<<<<<<
  3323. * output[col] += vec[row] * mat[(row * nr_col) + col]
  3324. *
  3325. */
  3326. __pyx_t_4 = __pyx_v_nr_col;
  3327. __pyx_t_5 = __pyx_t_4;
  3328. for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
  3329. __pyx_v_col = __pyx_t_6;
  3330. /* "thinc/linalg.pxd":376
  3331. * for row in range(nr_row):
  3332. * for col in range(nr_col):
  3333. * output[col] += vec[row] * mat[(row * nr_col) + col] # <<<<<<<<<<<<<<
  3334. *
  3335. * @staticmethod
  3336. */
  3337. __pyx_t_7 = __pyx_v_col;
  3338. (__pyx_v_output[__pyx_t_7]) = ((__pyx_v_output[__pyx_t_7]) + ((__pyx_v_vec[__pyx_v_row]) * (__pyx_v_mat[((__pyx_v_row * __pyx_v_nr_col) + __pyx_v_col)])));
  3339. }
  3340. }
  3341. /* "thinc/linalg.pxd":354
  3342. *
  3343. * @staticmethod
  3344. * cdef inline void T_dot(weight_t* output, # <<<<<<<<<<<<<<
  3345. * const weight_t* mat,
  3346. * const weight_t* vec,
  3347. */
  3348. /* function exit code */
  3349. }
  3350. /* "thinc/linalg.pxd":379
  3351. *
  3352. * @staticmethod
  3353. * cdef inline void batch_T_dot(weight_t* output, # <<<<<<<<<<<<<<
  3354. * const weight_t* mat,
  3355. * const weight_t* vec,
  3356. */
  3357. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatVec_batch_T_dot(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_vec, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col, int32_t __pyx_v_nr_batch) {
  3358. CYTHON_UNUSED int __pyx_v__;
  3359. CYTHON_UNUSED double __pyx_v_one;
  3360. int32_t __pyx_t_1;
  3361. int32_t __pyx_t_2;
  3362. int __pyx_t_3;
  3363. /* "thinc/linalg.pxd":386
  3364. * int32_t nr_batch) nogil:
  3365. * cdef int _
  3366. * cdef double one = 1.0 # <<<<<<<<<<<<<<
  3367. * IF USE_BLAS:
  3368. * # output is (nr_batch, nr_col)
  3369. */
  3370. __pyx_v_one = 1.0;
  3371. /* "thinc/linalg.pxd":418
  3372. * 1)
  3373. * ELSE:
  3374. * for _ in range(nr_batch): # <<<<<<<<<<<<<<
  3375. * MatVec.T_dot(output,
  3376. * mat, vec, nr_row, nr_col)
  3377. */
  3378. __pyx_t_1 = __pyx_v_nr_batch;
  3379. __pyx_t_2 = __pyx_t_1;
  3380. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  3381. __pyx_v__ = __pyx_t_3;
  3382. /* "thinc/linalg.pxd":419
  3383. * ELSE:
  3384. * for _ in range(nr_batch):
  3385. * MatVec.T_dot(output, # <<<<<<<<<<<<<<
  3386. * mat, vec, nr_row, nr_col)
  3387. * output += nr_col
  3388. */
  3389. __pyx_f_5thinc_6linalg_6MatVec_T_dot(__pyx_v_output, __pyx_v_mat, __pyx_v_vec, __pyx_v_nr_row, __pyx_v_nr_col);
  3390. /* "thinc/linalg.pxd":421
  3391. * MatVec.T_dot(output,
  3392. * mat, vec, nr_row, nr_col)
  3393. * output += nr_col # <<<<<<<<<<<<<<
  3394. * vec += nr_row
  3395. *
  3396. */
  3397. __pyx_v_output = (__pyx_v_output + __pyx_v_nr_col);
  3398. /* "thinc/linalg.pxd":422
  3399. * mat, vec, nr_row, nr_col)
  3400. * output += nr_col
  3401. * vec += nr_row # <<<<<<<<<<<<<<
  3402. *
  3403. *
  3404. */
  3405. __pyx_v_vec = (__pyx_v_vec + __pyx_v_nr_row);
  3406. }
  3407. /* "thinc/linalg.pxd":379
  3408. *
  3409. * @staticmethod
  3410. * cdef inline void batch_T_dot(weight_t* output, # <<<<<<<<<<<<<<
  3411. * const weight_t* mat,
  3412. * const weight_t* vec,
  3413. */
  3414. /* function exit code */
  3415. }
  3416. /* "thinc/linalg.pxd":427
  3417. * cdef class MatMat:
  3418. * @staticmethod
  3419. * cdef inline void add(weight_t* output, # <<<<<<<<<<<<<<
  3420. * const weight_t* x,
  3421. * const weight_t* y,
  3422. */
  3423. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_add(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col) {
  3424. /* "thinc/linalg.pxd":431
  3425. * const weight_t* y,
  3426. * int32_t nr_row, int32_t nr_col) nogil:
  3427. * memcpy(output, x, sizeof(output[0]) * nr_row * nr_col) # <<<<<<<<<<<<<<
  3428. * MatMat.add_i(output, y, nr_row, nr_col)
  3429. *
  3430. */
  3431. (void)(memcpy(__pyx_v_output, __pyx_v_x, (((sizeof((__pyx_v_output[0]))) * __pyx_v_nr_row) * __pyx_v_nr_col)));
  3432. /* "thinc/linalg.pxd":432
  3433. * int32_t nr_row, int32_t nr_col) nogil:
  3434. * memcpy(output, x, sizeof(output[0]) * nr_row * nr_col)
  3435. * MatMat.add_i(output, y, nr_row, nr_col) # <<<<<<<<<<<<<<
  3436. *
  3437. * @staticmethod
  3438. */
  3439. __pyx_f_5thinc_6linalg_6MatMat_add_i(__pyx_v_output, __pyx_v_y, __pyx_v_nr_row, __pyx_v_nr_col);
  3440. /* "thinc/linalg.pxd":427
  3441. * cdef class MatMat:
  3442. * @staticmethod
  3443. * cdef inline void add(weight_t* output, # <<<<<<<<<<<<<<
  3444. * const weight_t* x,
  3445. * const weight_t* y,
  3446. */
  3447. /* function exit code */
  3448. }
  3449. /* "thinc/linalg.pxd":435
  3450. *
  3451. * @staticmethod
  3452. * cdef inline void add_i(weight_t* x, # <<<<<<<<<<<<<<
  3453. * const weight_t* y,
  3454. * int32_t nr_row, int32_t nr_col) nogil:
  3455. */
  3456. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_add_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col) {
  3457. int __pyx_v_i;
  3458. int __pyx_v_row;
  3459. int __pyx_v_col;
  3460. int32_t __pyx_t_1;
  3461. int32_t __pyx_t_2;
  3462. int __pyx_t_3;
  3463. int32_t __pyx_t_4;
  3464. int32_t __pyx_t_5;
  3465. int __pyx_t_6;
  3466. int __pyx_t_7;
  3467. /* "thinc/linalg.pxd":439
  3468. * int32_t nr_row, int32_t nr_col) nogil:
  3469. * cdef int i, row, col
  3470. * for i in range(nr_row): # <<<<<<<<<<<<<<
  3471. * row = i * nr_col
  3472. * for col in range(nr_col):
  3473. */
  3474. __pyx_t_1 = __pyx_v_nr_row;
  3475. __pyx_t_2 = __pyx_t_1;
  3476. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  3477. __pyx_v_i = __pyx_t_3;
  3478. /* "thinc/linalg.pxd":440
  3479. * cdef int i, row, col
  3480. * for i in range(nr_row):
  3481. * row = i * nr_col # <<<<<<<<<<<<<<
  3482. * for col in range(nr_col):
  3483. * x[row + col] += y[row + col]
  3484. */
  3485. __pyx_v_row = (__pyx_v_i * __pyx_v_nr_col);
  3486. /* "thinc/linalg.pxd":441
  3487. * for i in range(nr_row):
  3488. * row = i * nr_col
  3489. * for col in range(nr_col): # <<<<<<<<<<<<<<
  3490. * x[row + col] += y[row + col]
  3491. *
  3492. */
  3493. __pyx_t_4 = __pyx_v_nr_col;
  3494. __pyx_t_5 = __pyx_t_4;
  3495. for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
  3496. __pyx_v_col = __pyx_t_6;
  3497. /* "thinc/linalg.pxd":442
  3498. * row = i * nr_col
  3499. * for col in range(nr_col):
  3500. * x[row + col] += y[row + col] # <<<<<<<<<<<<<<
  3501. *
  3502. * @staticmethod
  3503. */
  3504. __pyx_t_7 = (__pyx_v_row + __pyx_v_col);
  3505. (__pyx_v_x[__pyx_t_7]) = ((__pyx_v_x[__pyx_t_7]) + (__pyx_v_y[(__pyx_v_row + __pyx_v_col)]));
  3506. }
  3507. }
  3508. /* "thinc/linalg.pxd":435
  3509. *
  3510. * @staticmethod
  3511. * cdef inline void add_i(weight_t* x, # <<<<<<<<<<<<<<
  3512. * const weight_t* y,
  3513. * int32_t nr_row, int32_t nr_col) nogil:
  3514. */
  3515. /* function exit code */
  3516. }
  3517. /* "thinc/linalg.pxd":445
  3518. *
  3519. * @staticmethod
  3520. * cdef inline void mul(weight_t* output, # <<<<<<<<<<<<<<
  3521. * const weight_t* x,
  3522. * const weight_t* y,
  3523. */
  3524. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_mul(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col) {
  3525. /* "thinc/linalg.pxd":449
  3526. * const weight_t* y,
  3527. * int32_t nr_row, int32_t nr_col) nogil:
  3528. * memcpy(output, x, sizeof(output[0]) * nr_row * nr_col) # <<<<<<<<<<<<<<
  3529. * MatMat.mul_i(output, y, nr_row, nr_col)
  3530. *
  3531. */
  3532. (void)(memcpy(__pyx_v_output, __pyx_v_x, (((sizeof((__pyx_v_output[0]))) * __pyx_v_nr_row) * __pyx_v_nr_col)));
  3533. /* "thinc/linalg.pxd":450
  3534. * int32_t nr_row, int32_t nr_col) nogil:
  3535. * memcpy(output, x, sizeof(output[0]) * nr_row * nr_col)
  3536. * MatMat.mul_i(output, y, nr_row, nr_col) # <<<<<<<<<<<<<<
  3537. *
  3538. * @staticmethod
  3539. */
  3540. __pyx_f_5thinc_6linalg_6MatMat_mul_i(__pyx_v_output, __pyx_v_y, __pyx_v_nr_row, __pyx_v_nr_col);
  3541. /* "thinc/linalg.pxd":445
  3542. *
  3543. * @staticmethod
  3544. * cdef inline void mul(weight_t* output, # <<<<<<<<<<<<<<
  3545. * const weight_t* x,
  3546. * const weight_t* y,
  3547. */
  3548. /* function exit code */
  3549. }
  3550. /* "thinc/linalg.pxd":453
  3551. *
  3552. * @staticmethod
  3553. * cdef inline void mul_i(weight_t* x, # <<<<<<<<<<<<<<
  3554. * const weight_t* y,
  3555. * int32_t nr_row, int32_t nr_col) nogil:
  3556. */
  3557. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_mul_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col) {
  3558. int __pyx_v_i;
  3559. int __pyx_v_row;
  3560. int __pyx_v_col;
  3561. int32_t __pyx_t_1;
  3562. int32_t __pyx_t_2;
  3563. int __pyx_t_3;
  3564. int32_t __pyx_t_4;
  3565. int32_t __pyx_t_5;
  3566. int __pyx_t_6;
  3567. int __pyx_t_7;
  3568. /* "thinc/linalg.pxd":457
  3569. * int32_t nr_row, int32_t nr_col) nogil:
  3570. * cdef int i, row, col
  3571. * for i in range(nr_row): # <<<<<<<<<<<<<<
  3572. * row = i * nr_col
  3573. * for col in range(nr_col):
  3574. */
  3575. __pyx_t_1 = __pyx_v_nr_row;
  3576. __pyx_t_2 = __pyx_t_1;
  3577. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  3578. __pyx_v_i = __pyx_t_3;
  3579. /* "thinc/linalg.pxd":458
  3580. * cdef int i, row, col
  3581. * for i in range(nr_row):
  3582. * row = i * nr_col # <<<<<<<<<<<<<<
  3583. * for col in range(nr_col):
  3584. * x[row + col] *= y[row + col]
  3585. */
  3586. __pyx_v_row = (__pyx_v_i * __pyx_v_nr_col);
  3587. /* "thinc/linalg.pxd":459
  3588. * for i in range(nr_row):
  3589. * row = i * nr_col
  3590. * for col in range(nr_col): # <<<<<<<<<<<<<<
  3591. * x[row + col] *= y[row + col]
  3592. *
  3593. */
  3594. __pyx_t_4 = __pyx_v_nr_col;
  3595. __pyx_t_5 = __pyx_t_4;
  3596. for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
  3597. __pyx_v_col = __pyx_t_6;
  3598. /* "thinc/linalg.pxd":460
  3599. * row = i * nr_col
  3600. * for col in range(nr_col):
  3601. * x[row + col] *= y[row + col] # <<<<<<<<<<<<<<
  3602. *
  3603. * @staticmethod
  3604. */
  3605. __pyx_t_7 = (__pyx_v_row + __pyx_v_col);
  3606. (__pyx_v_x[__pyx_t_7]) = ((__pyx_v_x[__pyx_t_7]) * (__pyx_v_y[(__pyx_v_row + __pyx_v_col)]));
  3607. }
  3608. }
  3609. /* "thinc/linalg.pxd":453
  3610. *
  3611. * @staticmethod
  3612. * cdef inline void mul_i(weight_t* x, # <<<<<<<<<<<<<<
  3613. * const weight_t* y,
  3614. * int32_t nr_row, int32_t nr_col) nogil:
  3615. */
  3616. /* function exit code */
  3617. }
  3618. /* "thinc/linalg.pxd":463
  3619. *
  3620. * @staticmethod
  3621. * cdef inline void add_outer_i(weight_t* mat, # <<<<<<<<<<<<<<
  3622. * const weight_t* x,
  3623. * const weight_t* y,
  3624. */
  3625. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_add_outer_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_mat, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col) {
  3626. int __pyx_v_i;
  3627. int __pyx_v_j;
  3628. int __pyx_v_row;
  3629. CYTHON_UNUSED double __pyx_v_one;
  3630. int32_t __pyx_t_1;
  3631. int32_t __pyx_t_2;
  3632. int __pyx_t_3;
  3633. int32_t __pyx_t_4;
  3634. int32_t __pyx_t_5;
  3635. int __pyx_t_6;
  3636. int __pyx_t_7;
  3637. /* "thinc/linalg.pxd":469
  3638. * int32_t nr_col) nogil:
  3639. * cdef int i, j, row
  3640. * cdef double one = 1.0 # <<<<<<<<<<<<<<
  3641. * IF USE_BLAS:
  3642. * blis.ger(
  3643. */
  3644. __pyx_v_one = 1.0;
  3645. /* "thinc/linalg.pxd":480
  3646. * )
  3647. * ELSE:
  3648. * for i in range(nr_row): # <<<<<<<<<<<<<<
  3649. * row = i * nr_col
  3650. * for j in range(nr_col):
  3651. */
  3652. __pyx_t_1 = __pyx_v_nr_row;
  3653. __pyx_t_2 = __pyx_t_1;
  3654. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  3655. __pyx_v_i = __pyx_t_3;
  3656. /* "thinc/linalg.pxd":481
  3657. * ELSE:
  3658. * for i in range(nr_row):
  3659. * row = i * nr_col # <<<<<<<<<<<<<<
  3660. * for j in range(nr_col):
  3661. * mat[row + j] += x[i] * y[j]
  3662. */
  3663. __pyx_v_row = (__pyx_v_i * __pyx_v_nr_col);
  3664. /* "thinc/linalg.pxd":482
  3665. * for i in range(nr_row):
  3666. * row = i * nr_col
  3667. * for j in range(nr_col): # <<<<<<<<<<<<<<
  3668. * mat[row + j] += x[i] * y[j]
  3669. *
  3670. */
  3671. __pyx_t_4 = __pyx_v_nr_col;
  3672. __pyx_t_5 = __pyx_t_4;
  3673. for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
  3674. __pyx_v_j = __pyx_t_6;
  3675. /* "thinc/linalg.pxd":483
  3676. * row = i * nr_col
  3677. * for j in range(nr_col):
  3678. * mat[row + j] += x[i] * y[j] # <<<<<<<<<<<<<<
  3679. *
  3680. * @staticmethod
  3681. */
  3682. __pyx_t_7 = (__pyx_v_row + __pyx_v_j);
  3683. (__pyx_v_mat[__pyx_t_7]) = ((__pyx_v_mat[__pyx_t_7]) + ((__pyx_v_x[__pyx_v_i]) * (__pyx_v_y[__pyx_v_j])));
  3684. }
  3685. }
  3686. /* "thinc/linalg.pxd":463
  3687. *
  3688. * @staticmethod
  3689. * cdef inline void add_outer_i(weight_t* mat, # <<<<<<<<<<<<<<
  3690. * const weight_t* x,
  3691. * const weight_t* y,
  3692. */
  3693. /* function exit code */
  3694. }
  3695. /* "thinc/linalg.pxd":486
  3696. *
  3697. * @staticmethod
  3698. * cdef inline void batch_add_outer_i(weight_t* output, # <<<<<<<<<<<<<<
  3699. * const weight_t* x,
  3700. * const weight_t* y,
  3701. */
  3702. static CYTHON_INLINE void __pyx_f_5thinc_6linalg_6MatMat_batch_add_outer_i(__pyx_t_5thinc_8typedefs_weight_t *__pyx_v_output, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_x, __pyx_t_5thinc_8typedefs_weight_t const *__pyx_v_y, int32_t __pyx_v_nr_row, int32_t __pyx_v_nr_col, int32_t __pyx_v_nr_batch) {
  3703. CYTHON_UNUSED double __pyx_v_one;
  3704. CYTHON_UNUSED int32_t __pyx_v__;
  3705. int32_t __pyx_v_i;
  3706. int32_t __pyx_v_row;
  3707. int32_t __pyx_v_j;
  3708. int32_t __pyx_t_1;
  3709. int32_t __pyx_t_2;
  3710. int32_t __pyx_t_3;
  3711. int32_t __pyx_t_4;
  3712. int32_t __pyx_t_5;
  3713. int32_t __pyx_t_6;
  3714. int32_t __pyx_t_7;
  3715. int32_t __pyx_t_8;
  3716. int32_t __pyx_t_9;
  3717. int32_t __pyx_t_10;
  3718. /* "thinc/linalg.pxd":504
  3719. * # y: K * N
  3720. * # out: M * N
  3721. * cdef double one = 1.0 # <<<<<<<<<<<<<<
  3722. * IF USE_BLAS:
  3723. * blis.gemm(
  3724. */
  3725. __pyx_v_one = 1.0;
  3726. /* "thinc/linalg.pxd":524
  3727. * 1)
  3728. * ELSE:
  3729. * for _ in range(nr_batch): # <<<<<<<<<<<<<<
  3730. * for i in range(nr_row):
  3731. * row = i * nr_col
  3732. */
  3733. __pyx_t_1 = __pyx_v_nr_batch;
  3734. __pyx_t_2 = __pyx_t_1;
  3735. for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
  3736. __pyx_v__ = __pyx_t_3;
  3737. /* "thinc/linalg.pxd":525
  3738. * ELSE:
  3739. * for _ in range(nr_batch):
  3740. * for i in range(nr_row): # <<<<<<<<<<<<<<
  3741. * row = i * nr_col
  3742. * for j in range(nr_col):
  3743. */
  3744. __pyx_t_4 = __pyx_v_nr_row;
  3745. __pyx_t_5 = __pyx_t_4;
  3746. for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
  3747. __pyx_v_i = __pyx_t_6;
  3748. /* "thinc/linalg.pxd":526
  3749. * for _ in range(nr_batch):
  3750. * for i in range(nr_row):
  3751. * row = i * nr_col # <<<<<<<<<<<<<<
  3752. * for j in range(nr_col):
  3753. * output[row + j] += x[i] * y[j]
  3754. */
  3755. __pyx_v_row = (__pyx_v_i * __pyx_v_nr_col);
  3756. /* "thinc/linalg.pxd":527
  3757. * for i in range(nr_row):
  3758. * row = i * nr_col
  3759. * for j in range(nr_col): # <<<<<<<<<<<<<<
  3760. * output[row + j] += x[i] * y[j]
  3761. * x += nr_row
  3762. */
  3763. __pyx_t_7 = __pyx_v_nr_col;
  3764. __pyx_t_8 = __pyx_t_7;
  3765. for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
  3766. __pyx_v_j = __pyx_t_9;
  3767. /* "thinc/linalg.pxd":528
  3768. * row = i * nr_col
  3769. * for j in range(nr_col):
  3770. * output[row + j] += x[i] * y[j] # <<<<<<<<<<<<<<
  3771. * x += nr_row
  3772. * y += nr_col
  3773. */
  3774. __pyx_t_10 = (__pyx_v_row + __pyx_v_j);
  3775. (__pyx_v_output[__pyx_t_10]) = ((__pyx_v_output[__pyx_t_10]) + ((__pyx_v_x[__pyx_v_i]) * (__pyx_v_y[__pyx_v_j])));
  3776. }
  3777. }
  3778. /* "thinc/linalg.pxd":529
  3779. * for j in range(nr_col):
  3780. * output[row + j] += x[i] * y[j]
  3781. * x += nr_row # <<<<<<<<<<<<<<
  3782. * y += nr_col
  3783. */
  3784. __pyx_v_x = (__pyx_v_x + __pyx_v_nr_row);
  3785. /* "thinc/linalg.pxd":530
  3786. * output[row + j] += x[i] * y[j]
  3787. * x += nr_row
  3788. * y += nr_col # <<<<<<<<<<<<<<
  3789. */
  3790. __pyx_v_y = (__pyx_v_y + __pyx_v_nr_col);
  3791. }
  3792. /* "thinc/linalg.pxd":486
  3793. *
  3794. * @staticmethod
  3795. * cdef inline void batch_add_outer_i(weight_t* output, # <<<<<<<<<<<<<<
  3796. * const weight_t* x,
  3797. * const weight_t* y,
  3798. */
  3799. /* function exit code */
  3800. }
  3801. static PyObject *__pyx_tp_new_5thinc_6linalg_Matrix(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  3802. struct __pyx_obj_5thinc_6linalg_Matrix *p;
  3803. PyObject *o;
  3804. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  3805. o = (*t->tp_alloc)(t, 0);
  3806. } else {
  3807. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  3808. }
  3809. if (unlikely(!o)) return 0;
  3810. p = ((struct __pyx_obj_5thinc_6linalg_Matrix *)o);
  3811. p->mem = ((struct __pyx_obj_5cymem_5cymem_Pool *)Py_None); Py_INCREF(Py_None);
  3812. return o;
  3813. }
  3814. static void __pyx_tp_dealloc_5thinc_6linalg_Matrix(PyObject *o) {
  3815. struct __pyx_obj_5thinc_6linalg_Matrix *p = (struct __pyx_obj_5thinc_6linalg_Matrix *)o;
  3816. #if CYTHON_USE_TP_FINALIZE
  3817. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
  3818. if (PyObject_CallFinalizerFromDealloc(o)) return;
  3819. }
  3820. #endif
  3821. PyObject_GC_UnTrack(o);
  3822. Py_CLEAR(p->mem);
  3823. (*Py_TYPE(o)->tp_free)(o);
  3824. }
  3825. static int __pyx_tp_traverse_5thinc_6linalg_Matrix(PyObject *o, visitproc v, void *a) {
  3826. int e;
  3827. struct __pyx_obj_5thinc_6linalg_Matrix *p = (struct __pyx_obj_5thinc_6linalg_Matrix *)o;
  3828. if (p->mem) {
  3829. e = (*v)(((PyObject *)p->mem), a); if (e) return e;
  3830. }
  3831. return 0;
  3832. }
  3833. static int __pyx_tp_clear_5thinc_6linalg_Matrix(PyObject *o) {
  3834. PyObject* tmp;
  3835. struct __pyx_obj_5thinc_6linalg_Matrix *p = (struct __pyx_obj_5thinc_6linalg_Matrix *)o;
  3836. tmp = ((PyObject*)p->mem);
  3837. p->mem = ((struct __pyx_obj_5cymem_5cymem_Pool *)Py_None); Py_INCREF(Py_None);
  3838. Py_XDECREF(tmp);
  3839. return 0;
  3840. }
  3841. static PyTypeObject __pyx_type_5thinc_6linalg_Matrix = {
  3842. PyVarObject_HEAD_INIT(0, 0)
  3843. "thinc.linalg.Matrix", /*tp_name*/
  3844. sizeof(struct __pyx_obj_5thinc_6linalg_Matrix), /*tp_basicsize*/
  3845. 0, /*tp_itemsize*/
  3846. __pyx_tp_dealloc_5thinc_6linalg_Matrix, /*tp_dealloc*/
  3847. 0, /*tp_print*/
  3848. 0, /*tp_getattr*/
  3849. 0, /*tp_setattr*/
  3850. #if PY_MAJOR_VERSION < 3
  3851. 0, /*tp_compare*/
  3852. #endif
  3853. #if PY_MAJOR_VERSION >= 3
  3854. 0, /*tp_as_async*/
  3855. #endif
  3856. 0, /*tp_repr*/
  3857. 0, /*tp_as_number*/
  3858. 0, /*tp_as_sequence*/
  3859. 0, /*tp_as_mapping*/
  3860. 0, /*tp_hash*/
  3861. 0, /*tp_call*/
  3862. 0, /*tp_str*/
  3863. 0, /*tp_getattro*/
  3864. 0, /*tp_setattro*/
  3865. 0, /*tp_as_buffer*/
  3866. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  3867. 0, /*tp_doc*/
  3868. __pyx_tp_traverse_5thinc_6linalg_Matrix, /*tp_traverse*/
  3869. __pyx_tp_clear_5thinc_6linalg_Matrix, /*tp_clear*/
  3870. 0, /*tp_richcompare*/
  3871. 0, /*tp_weaklistoffset*/
  3872. 0, /*tp_iter*/
  3873. 0, /*tp_iternext*/
  3874. 0, /*tp_methods*/
  3875. 0, /*tp_members*/
  3876. 0, /*tp_getset*/
  3877. 0, /*tp_base*/
  3878. 0, /*tp_dict*/
  3879. 0, /*tp_descr_get*/
  3880. 0, /*tp_descr_set*/
  3881. 0, /*tp_dictoffset*/
  3882. 0, /*tp_init*/
  3883. 0, /*tp_alloc*/
  3884. __pyx_tp_new_5thinc_6linalg_Matrix, /*tp_new*/
  3885. 0, /*tp_free*/
  3886. 0, /*tp_is_gc*/
  3887. 0, /*tp_bases*/
  3888. 0, /*tp_mro*/
  3889. 0, /*tp_cache*/
  3890. 0, /*tp_subclasses*/
  3891. 0, /*tp_weaklist*/
  3892. 0, /*tp_del*/
  3893. 0, /*tp_version_tag*/
  3894. #if PY_VERSION_HEX >= 0x030400a1
  3895. 0, /*tp_finalize*/
  3896. #endif
  3897. };
  3898. static struct __pyx_vtabstruct_5thinc_6linalg_Vec __pyx_vtable_5thinc_6linalg_Vec;
  3899. static PyObject *__pyx_tp_new_5thinc_6linalg_Vec(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  3900. struct __pyx_obj_5thinc_6linalg_Vec *p;
  3901. PyObject *o;
  3902. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  3903. o = (*t->tp_alloc)(t, 0);
  3904. } else {
  3905. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  3906. }
  3907. if (unlikely(!o)) return 0;
  3908. p = ((struct __pyx_obj_5thinc_6linalg_Vec *)o);
  3909. p->__pyx_vtab = __pyx_vtabptr_5thinc_6linalg_Vec;
  3910. return o;
  3911. }
  3912. static void __pyx_tp_dealloc_5thinc_6linalg_Vec(PyObject *o) {
  3913. #if CYTHON_USE_TP_FINALIZE
  3914. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
  3915. if (PyObject_CallFinalizerFromDealloc(o)) return;
  3916. }
  3917. #endif
  3918. (*Py_TYPE(o)->tp_free)(o);
  3919. }
  3920. static PyTypeObject __pyx_type_5thinc_6linalg_Vec = {
  3921. PyVarObject_HEAD_INIT(0, 0)
  3922. "thinc.linalg.Vec", /*tp_name*/
  3923. sizeof(struct __pyx_obj_5thinc_6linalg_Vec), /*tp_basicsize*/
  3924. 0, /*tp_itemsize*/
  3925. __pyx_tp_dealloc_5thinc_6linalg_Vec, /*tp_dealloc*/
  3926. 0, /*tp_print*/
  3927. 0, /*tp_getattr*/
  3928. 0, /*tp_setattr*/
  3929. #if PY_MAJOR_VERSION < 3
  3930. 0, /*tp_compare*/
  3931. #endif
  3932. #if PY_MAJOR_VERSION >= 3
  3933. 0, /*tp_as_async*/
  3934. #endif
  3935. 0, /*tp_repr*/
  3936. 0, /*tp_as_number*/
  3937. 0, /*tp_as_sequence*/
  3938. 0, /*tp_as_mapping*/
  3939. 0, /*tp_hash*/
  3940. 0, /*tp_call*/
  3941. 0, /*tp_str*/
  3942. 0, /*tp_getattro*/
  3943. 0, /*tp_setattro*/
  3944. 0, /*tp_as_buffer*/
  3945. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  3946. 0, /*tp_doc*/
  3947. 0, /*tp_traverse*/
  3948. 0, /*tp_clear*/
  3949. 0, /*tp_richcompare*/
  3950. 0, /*tp_weaklistoffset*/
  3951. 0, /*tp_iter*/
  3952. 0, /*tp_iternext*/
  3953. 0, /*tp_methods*/
  3954. 0, /*tp_members*/
  3955. 0, /*tp_getset*/
  3956. 0, /*tp_base*/
  3957. 0, /*tp_dict*/
  3958. 0, /*tp_descr_get*/
  3959. 0, /*tp_descr_set*/
  3960. 0, /*tp_dictoffset*/
  3961. 0, /*tp_init*/
  3962. 0, /*tp_alloc*/
  3963. __pyx_tp_new_5thinc_6linalg_Vec, /*tp_new*/
  3964. 0, /*tp_free*/
  3965. 0, /*tp_is_gc*/
  3966. 0, /*tp_bases*/
  3967. 0, /*tp_mro*/
  3968. 0, /*tp_cache*/
  3969. 0, /*tp_subclasses*/
  3970. 0, /*tp_weaklist*/
  3971. 0, /*tp_del*/
  3972. 0, /*tp_version_tag*/
  3973. #if PY_VERSION_HEX >= 0x030400a1
  3974. 0, /*tp_finalize*/
  3975. #endif
  3976. };
  3977. static struct __pyx_vtabstruct_5thinc_6linalg_VecVec __pyx_vtable_5thinc_6linalg_VecVec;
  3978. static PyObject *__pyx_tp_new_5thinc_6linalg_VecVec(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  3979. struct __pyx_obj_5thinc_6linalg_VecVec *p;
  3980. PyObject *o;
  3981. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  3982. o = (*t->tp_alloc)(t, 0);
  3983. } else {
  3984. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  3985. }
  3986. if (unlikely(!o)) return 0;
  3987. p = ((struct __pyx_obj_5thinc_6linalg_VecVec *)o);
  3988. p->__pyx_vtab = __pyx_vtabptr_5thinc_6linalg_VecVec;
  3989. return o;
  3990. }
  3991. static void __pyx_tp_dealloc_5thinc_6linalg_VecVec(PyObject *o) {
  3992. #if CYTHON_USE_TP_FINALIZE
  3993. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
  3994. if (PyObject_CallFinalizerFromDealloc(o)) return;
  3995. }
  3996. #endif
  3997. (*Py_TYPE(o)->tp_free)(o);
  3998. }
  3999. static PyTypeObject __pyx_type_5thinc_6linalg_VecVec = {
  4000. PyVarObject_HEAD_INIT(0, 0)
  4001. "thinc.linalg.VecVec", /*tp_name*/
  4002. sizeof(struct __pyx_obj_5thinc_6linalg_VecVec), /*tp_basicsize*/
  4003. 0, /*tp_itemsize*/
  4004. __pyx_tp_dealloc_5thinc_6linalg_VecVec, /*tp_dealloc*/
  4005. 0, /*tp_print*/
  4006. 0, /*tp_getattr*/
  4007. 0, /*tp_setattr*/
  4008. #if PY_MAJOR_VERSION < 3
  4009. 0, /*tp_compare*/
  4010. #endif
  4011. #if PY_MAJOR_VERSION >= 3
  4012. 0, /*tp_as_async*/
  4013. #endif
  4014. 0, /*tp_repr*/
  4015. 0, /*tp_as_number*/
  4016. 0, /*tp_as_sequence*/
  4017. 0, /*tp_as_mapping*/
  4018. 0, /*tp_hash*/
  4019. 0, /*tp_call*/
  4020. 0, /*tp_str*/
  4021. 0, /*tp_getattro*/
  4022. 0, /*tp_setattro*/
  4023. 0, /*tp_as_buffer*/
  4024. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  4025. 0, /*tp_doc*/
  4026. 0, /*tp_traverse*/
  4027. 0, /*tp_clear*/
  4028. 0, /*tp_richcompare*/
  4029. 0, /*tp_weaklistoffset*/
  4030. 0, /*tp_iter*/
  4031. 0, /*tp_iternext*/
  4032. 0, /*tp_methods*/
  4033. 0, /*tp_members*/
  4034. 0, /*tp_getset*/
  4035. 0, /*tp_base*/
  4036. 0, /*tp_dict*/
  4037. 0, /*tp_descr_get*/
  4038. 0, /*tp_descr_set*/
  4039. 0, /*tp_dictoffset*/
  4040. 0, /*tp_init*/
  4041. 0, /*tp_alloc*/
  4042. __pyx_tp_new_5thinc_6linalg_VecVec, /*tp_new*/
  4043. 0, /*tp_free*/
  4044. 0, /*tp_is_gc*/
  4045. 0, /*tp_bases*/
  4046. 0, /*tp_mro*/
  4047. 0, /*tp_cache*/
  4048. 0, /*tp_subclasses*/
  4049. 0, /*tp_weaklist*/
  4050. 0, /*tp_del*/
  4051. 0, /*tp_version_tag*/
  4052. #if PY_VERSION_HEX >= 0x030400a1
  4053. 0, /*tp_finalize*/
  4054. #endif
  4055. };
  4056. static struct __pyx_vtabstruct_5thinc_6linalg_Mat __pyx_vtable_5thinc_6linalg_Mat;
  4057. static PyObject *__pyx_tp_new_5thinc_6linalg_Mat(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  4058. struct __pyx_obj_5thinc_6linalg_Mat *p;
  4059. PyObject *o;
  4060. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  4061. o = (*t->tp_alloc)(t, 0);
  4062. } else {
  4063. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  4064. }
  4065. if (unlikely(!o)) return 0;
  4066. p = ((struct __pyx_obj_5thinc_6linalg_Mat *)o);
  4067. p->__pyx_vtab = __pyx_vtabptr_5thinc_6linalg_Mat;
  4068. return o;
  4069. }
  4070. static void __pyx_tp_dealloc_5thinc_6linalg_Mat(PyObject *o) {
  4071. #if CYTHON_USE_TP_FINALIZE
  4072. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
  4073. if (PyObject_CallFinalizerFromDealloc(o)) return;
  4074. }
  4075. #endif
  4076. (*Py_TYPE(o)->tp_free)(o);
  4077. }
  4078. static PyTypeObject __pyx_type_5thinc_6linalg_Mat = {
  4079. PyVarObject_HEAD_INIT(0, 0)
  4080. "thinc.linalg.Mat", /*tp_name*/
  4081. sizeof(struct __pyx_obj_5thinc_6linalg_Mat), /*tp_basicsize*/
  4082. 0, /*tp_itemsize*/
  4083. __pyx_tp_dealloc_5thinc_6linalg_Mat, /*tp_dealloc*/
  4084. 0, /*tp_print*/
  4085. 0, /*tp_getattr*/
  4086. 0, /*tp_setattr*/
  4087. #if PY_MAJOR_VERSION < 3
  4088. 0, /*tp_compare*/
  4089. #endif
  4090. #if PY_MAJOR_VERSION >= 3
  4091. 0, /*tp_as_async*/
  4092. #endif
  4093. 0, /*tp_repr*/
  4094. 0, /*tp_as_number*/
  4095. 0, /*tp_as_sequence*/
  4096. 0, /*tp_as_mapping*/
  4097. 0, /*tp_hash*/
  4098. 0, /*tp_call*/
  4099. 0, /*tp_str*/
  4100. 0, /*tp_getattro*/
  4101. 0, /*tp_setattro*/
  4102. 0, /*tp_as_buffer*/
  4103. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  4104. 0, /*tp_doc*/
  4105. 0, /*tp_traverse*/
  4106. 0, /*tp_clear*/
  4107. 0, /*tp_richcompare*/
  4108. 0, /*tp_weaklistoffset*/
  4109. 0, /*tp_iter*/
  4110. 0, /*tp_iternext*/
  4111. 0, /*tp_methods*/
  4112. 0, /*tp_members*/
  4113. 0, /*tp_getset*/
  4114. 0, /*tp_base*/
  4115. 0, /*tp_dict*/
  4116. 0, /*tp_descr_get*/
  4117. 0, /*tp_descr_set*/
  4118. 0, /*tp_dictoffset*/
  4119. 0, /*tp_init*/
  4120. 0, /*tp_alloc*/
  4121. __pyx_tp_new_5thinc_6linalg_Mat, /*tp_new*/
  4122. 0, /*tp_free*/
  4123. 0, /*tp_is_gc*/
  4124. 0, /*tp_bases*/
  4125. 0, /*tp_mro*/
  4126. 0, /*tp_cache*/
  4127. 0, /*tp_subclasses*/
  4128. 0, /*tp_weaklist*/
  4129. 0, /*tp_del*/
  4130. 0, /*tp_version_tag*/
  4131. #if PY_VERSION_HEX >= 0x030400a1
  4132. 0, /*tp_finalize*/
  4133. #endif
  4134. };
  4135. static struct __pyx_vtabstruct_5thinc_6linalg_MatVec __pyx_vtable_5thinc_6linalg_MatVec;
  4136. static PyObject *__pyx_tp_new_5thinc_6linalg_MatVec(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  4137. struct __pyx_obj_5thinc_6linalg_MatVec *p;
  4138. PyObject *o;
  4139. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  4140. o = (*t->tp_alloc)(t, 0);
  4141. } else {
  4142. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  4143. }
  4144. if (unlikely(!o)) return 0;
  4145. p = ((struct __pyx_obj_5thinc_6linalg_MatVec *)o);
  4146. p->__pyx_vtab = __pyx_vtabptr_5thinc_6linalg_MatVec;
  4147. return o;
  4148. }
  4149. static void __pyx_tp_dealloc_5thinc_6linalg_MatVec(PyObject *o) {
  4150. #if CYTHON_USE_TP_FINALIZE
  4151. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
  4152. if (PyObject_CallFinalizerFromDealloc(o)) return;
  4153. }
  4154. #endif
  4155. (*Py_TYPE(o)->tp_free)(o);
  4156. }
  4157. static PyTypeObject __pyx_type_5thinc_6linalg_MatVec = {
  4158. PyVarObject_HEAD_INIT(0, 0)
  4159. "thinc.linalg.MatVec", /*tp_name*/
  4160. sizeof(struct __pyx_obj_5thinc_6linalg_MatVec), /*tp_basicsize*/
  4161. 0, /*tp_itemsize*/
  4162. __pyx_tp_dealloc_5thinc_6linalg_MatVec, /*tp_dealloc*/
  4163. 0, /*tp_print*/
  4164. 0, /*tp_getattr*/
  4165. 0, /*tp_setattr*/
  4166. #if PY_MAJOR_VERSION < 3
  4167. 0, /*tp_compare*/
  4168. #endif
  4169. #if PY_MAJOR_VERSION >= 3
  4170. 0, /*tp_as_async*/
  4171. #endif
  4172. 0, /*tp_repr*/
  4173. 0, /*tp_as_number*/
  4174. 0, /*tp_as_sequence*/
  4175. 0, /*tp_as_mapping*/
  4176. 0, /*tp_hash*/
  4177. 0, /*tp_call*/
  4178. 0, /*tp_str*/
  4179. 0, /*tp_getattro*/
  4180. 0, /*tp_setattro*/
  4181. 0, /*tp_as_buffer*/
  4182. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  4183. 0, /*tp_doc*/
  4184. 0, /*tp_traverse*/
  4185. 0, /*tp_clear*/
  4186. 0, /*tp_richcompare*/
  4187. 0, /*tp_weaklistoffset*/
  4188. 0, /*tp_iter*/
  4189. 0, /*tp_iternext*/
  4190. 0, /*tp_methods*/
  4191. 0, /*tp_members*/
  4192. 0, /*tp_getset*/
  4193. 0, /*tp_base*/
  4194. 0, /*tp_dict*/
  4195. 0, /*tp_descr_get*/
  4196. 0, /*tp_descr_set*/
  4197. 0, /*tp_dictoffset*/
  4198. 0, /*tp_init*/
  4199. 0, /*tp_alloc*/
  4200. __pyx_tp_new_5thinc_6linalg_MatVec, /*tp_new*/
  4201. 0, /*tp_free*/
  4202. 0, /*tp_is_gc*/
  4203. 0, /*tp_bases*/
  4204. 0, /*tp_mro*/
  4205. 0, /*tp_cache*/
  4206. 0, /*tp_subclasses*/
  4207. 0, /*tp_weaklist*/
  4208. 0, /*tp_del*/
  4209. 0, /*tp_version_tag*/
  4210. #if PY_VERSION_HEX >= 0x030400a1
  4211. 0, /*tp_finalize*/
  4212. #endif
  4213. };
  4214. static struct __pyx_vtabstruct_5thinc_6linalg_MatMat __pyx_vtable_5thinc_6linalg_MatMat;
  4215. static PyObject *__pyx_tp_new_5thinc_6linalg_MatMat(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  4216. struct __pyx_obj_5thinc_6linalg_MatMat *p;
  4217. PyObject *o;
  4218. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  4219. o = (*t->tp_alloc)(t, 0);
  4220. } else {
  4221. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  4222. }
  4223. if (unlikely(!o)) return 0;
  4224. p = ((struct __pyx_obj_5thinc_6linalg_MatMat *)o);
  4225. p->__pyx_vtab = __pyx_vtabptr_5thinc_6linalg_MatMat;
  4226. return o;
  4227. }
  4228. static void __pyx_tp_dealloc_5thinc_6linalg_MatMat(PyObject *o) {
  4229. #if CYTHON_USE_TP_FINALIZE
  4230. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
  4231. if (PyObject_CallFinalizerFromDealloc(o)) return;
  4232. }
  4233. #endif
  4234. (*Py_TYPE(o)->tp_free)(o);
  4235. }
  4236. static PyTypeObject __pyx_type_5thinc_6linalg_MatMat = {
  4237. PyVarObject_HEAD_INIT(0, 0)
  4238. "thinc.linalg.MatMat", /*tp_name*/
  4239. sizeof(struct __pyx_obj_5thinc_6linalg_MatMat), /*tp_basicsize*/
  4240. 0, /*tp_itemsize*/
  4241. __pyx_tp_dealloc_5thinc_6linalg_MatMat, /*tp_dealloc*/
  4242. 0, /*tp_print*/
  4243. 0, /*tp_getattr*/
  4244. 0, /*tp_setattr*/
  4245. #if PY_MAJOR_VERSION < 3
  4246. 0, /*tp_compare*/
  4247. #endif
  4248. #if PY_MAJOR_VERSION >= 3
  4249. 0, /*tp_as_async*/
  4250. #endif
  4251. 0, /*tp_repr*/
  4252. 0, /*tp_as_number*/
  4253. 0, /*tp_as_sequence*/
  4254. 0, /*tp_as_mapping*/
  4255. 0, /*tp_hash*/
  4256. 0, /*tp_call*/
  4257. 0, /*tp_str*/
  4258. 0, /*tp_getattro*/
  4259. 0, /*tp_setattro*/
  4260. 0, /*tp_as_buffer*/
  4261. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  4262. 0, /*tp_doc*/
  4263. 0, /*tp_traverse*/
  4264. 0, /*tp_clear*/
  4265. 0, /*tp_richcompare*/
  4266. 0, /*tp_weaklistoffset*/
  4267. 0, /*tp_iter*/
  4268. 0, /*tp_iternext*/
  4269. 0, /*tp_methods*/
  4270. 0, /*tp_members*/
  4271. 0, /*tp_getset*/
  4272. 0, /*tp_base*/
  4273. 0, /*tp_dict*/
  4274. 0, /*tp_descr_get*/
  4275. 0, /*tp_descr_set*/
  4276. 0, /*tp_dictoffset*/
  4277. 0, /*tp_init*/
  4278. 0, /*tp_alloc*/
  4279. __pyx_tp_new_5thinc_6linalg_MatMat, /*tp_new*/
  4280. 0, /*tp_free*/
  4281. 0, /*tp_is_gc*/
  4282. 0, /*tp_bases*/
  4283. 0, /*tp_mro*/
  4284. 0, /*tp_cache*/
  4285. 0, /*tp_subclasses*/
  4286. 0, /*tp_weaklist*/
  4287. 0, /*tp_del*/
  4288. 0, /*tp_version_tag*/
  4289. #if PY_VERSION_HEX >= 0x030400a1
  4290. 0, /*tp_finalize*/
  4291. #endif
  4292. };
  4293. static PyMethodDef __pyx_methods[] = {
  4294. {0, 0, 0, 0}
  4295. };
  4296. #if PY_MAJOR_VERSION >= 3
  4297. #if CYTHON_PEP489_MULTI_PHASE_INIT
  4298. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  4299. static int __pyx_pymod_exec_linalg(PyObject* module); /*proto*/
  4300. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  4301. {Py_mod_create, (void*)__pyx_pymod_create},
  4302. {Py_mod_exec, (void*)__pyx_pymod_exec_linalg},
  4303. {0, NULL}
  4304. };
  4305. #endif
  4306. static struct PyModuleDef __pyx_moduledef = {
  4307. PyModuleDef_HEAD_INIT,
  4308. "linalg",
  4309. 0, /* m_doc */
  4310. #if CYTHON_PEP489_MULTI_PHASE_INIT
  4311. 0, /* m_size */
  4312. #else
  4313. -1, /* m_size */
  4314. #endif
  4315. __pyx_methods /* m_methods */,
  4316. #if CYTHON_PEP489_MULTI_PHASE_INIT
  4317. __pyx_moduledef_slots, /* m_slots */
  4318. #else
  4319. NULL, /* m_reload */
  4320. #endif
  4321. NULL, /* m_traverse */
  4322. NULL, /* m_clear */
  4323. NULL /* m_free */
  4324. };
  4325. #endif
  4326. #ifndef CYTHON_SMALL_CODE
  4327. #if defined(__clang__)
  4328. #define CYTHON_SMALL_CODE
  4329. #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  4330. #define CYTHON_SMALL_CODE __attribute__((cold))
  4331. #else
  4332. #define CYTHON_SMALL_CODE
  4333. #endif
  4334. #endif
  4335. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  4336. {&__pyx_n_s_Mat, __pyx_k_Mat, sizeof(__pyx_k_Mat), 0, 0, 1, 1},
  4337. {&__pyx_n_s_MatMat, __pyx_k_MatMat, sizeof(__pyx_k_MatMat), 0, 0, 1, 1},
  4338. {&__pyx_n_s_MatVec, __pyx_k_MatVec, sizeof(__pyx_k_MatVec), 0, 0, 1, 1},
  4339. {&__pyx_n_s_Matrix, __pyx_k_Matrix, sizeof(__pyx_k_Matrix), 0, 0, 1, 1},
  4340. {&__pyx_n_s_Vec, __pyx_k_Vec, sizeof(__pyx_k_Vec), 0, 0, 1, 1},
  4341. {&__pyx_n_s_VecVec, __pyx_k_VecVec, sizeof(__pyx_k_VecVec), 0, 0, 1, 1},
  4342. {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  4343. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  4344. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  4345. {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  4346. {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  4347. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  4348. {0, 0, 0, 0, 0, 0, 0}
  4349. };
  4350. static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  4351. __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 37, __pyx_L1_error)
  4352. return 0;
  4353. __pyx_L1_error:;
  4354. return -1;
  4355. }
  4356. static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  4357. __Pyx_RefNannyDeclarations
  4358. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  4359. __Pyx_RefNannyFinishContext();
  4360. return 0;
  4361. }
  4362. static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  4363. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
  4364. return 0;
  4365. __pyx_L1_error:;
  4366. return -1;
  4367. }
  4368. static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
  4369. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
  4370. static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
  4371. static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
  4372. static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
  4373. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
  4374. static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
  4375. static int __Pyx_modinit_global_init_code(void) {
  4376. __Pyx_RefNannyDeclarations
  4377. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  4378. /*--- Global init code ---*/
  4379. __Pyx_RefNannyFinishContext();
  4380. return 0;
  4381. }
  4382. static int __Pyx_modinit_variable_export_code(void) {
  4383. __Pyx_RefNannyDeclarations
  4384. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  4385. /*--- Variable export code ---*/
  4386. __Pyx_RefNannyFinishContext();
  4387. return 0;
  4388. }
  4389. static int __Pyx_modinit_function_export_code(void) {
  4390. __Pyx_RefNannyDeclarations
  4391. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  4392. /*--- Function export code ---*/
  4393. __Pyx_RefNannyFinishContext();
  4394. return 0;
  4395. }
  4396. static int __Pyx_modinit_type_init_code(void) {
  4397. __Pyx_RefNannyDeclarations
  4398. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  4399. /*--- Type init code ---*/
  4400. if (PyType_Ready(&__pyx_type_5thinc_6linalg_Matrix) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
  4401. __pyx_type_5thinc_6linalg_Matrix.tp_print = 0;
  4402. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5thinc_6linalg_Matrix.tp_dictoffset && __pyx_type_5thinc_6linalg_Matrix.tp_getattro == PyObject_GenericGetAttr)) {
  4403. __pyx_type_5thinc_6linalg_Matrix.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  4404. }
  4405. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Matrix, (PyObject *)&__pyx_type_5thinc_6linalg_Matrix) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
  4406. __pyx_ptype_5thinc_6linalg_Matrix = &__pyx_type_5thinc_6linalg_Matrix;
  4407. __pyx_vtabptr_5thinc_6linalg_Vec = &__pyx_vtable_5thinc_6linalg_Vec;
  4408. __pyx_vtable_5thinc_6linalg_Vec.arg_max = (int (*)(__pyx_t_5thinc_8typedefs_weight_t const *, int const ))__pyx_f_5thinc_6linalg_3Vec_arg_max;
  4409. __pyx_vtable_5thinc_6linalg_Vec.max = (__pyx_t_5thinc_8typedefs_weight_t (*)(__pyx_t_5thinc_8typedefs_weight_t const *, int32_t))__pyx_f_5thinc_6linalg_3Vec_max;
  4410. __pyx_vtable_5thinc_6linalg_Vec.sum = (__pyx_t_5thinc_8typedefs_weight_t (*)(__pyx_t_5thinc_8typedefs_weight_t const *, int32_t))__pyx_f_5thinc_6linalg_3Vec_sum;
  4411. __pyx_vtable_5thinc_6linalg_Vec.norm = (__pyx_t_5thinc_8typedefs_weight_t (*)(__pyx_t_5thinc_8typedefs_weight_t const *, int32_t))__pyx_f_5thinc_6linalg_3Vec_norm;
  4412. __pyx_vtable_5thinc_6linalg_Vec.add = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t))__pyx_f_5thinc_6linalg_3Vec_add;
  4413. __pyx_vtable_5thinc_6linalg_Vec.add_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t, int32_t))__pyx_f_5thinc_6linalg_3Vec_add_i;
  4414. __pyx_vtable_5thinc_6linalg_Vec.mul = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t))__pyx_f_5thinc_6linalg_3Vec_mul;
  4415. __pyx_vtable_5thinc_6linalg_Vec.mul_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t, int32_t))__pyx_f_5thinc_6linalg_3Vec_mul_i;
  4416. __pyx_vtable_5thinc_6linalg_Vec.pow = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t))__pyx_f_5thinc_6linalg_3Vec_pow;
  4417. __pyx_vtable_5thinc_6linalg_Vec.pow_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const , int32_t))__pyx_f_5thinc_6linalg_3Vec_pow_i;
  4418. __pyx_vtable_5thinc_6linalg_Vec.div = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t))__pyx_f_5thinc_6linalg_3Vec_div;
  4419. __pyx_vtable_5thinc_6linalg_Vec.div_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const , int32_t))__pyx_f_5thinc_6linalg_3Vec_div_i;
  4420. __pyx_vtable_5thinc_6linalg_Vec.exp = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t))__pyx_f_5thinc_6linalg_3Vec_exp;
  4421. __pyx_vtable_5thinc_6linalg_Vec.exp_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, int32_t))__pyx_f_5thinc_6linalg_3Vec_exp_i;
  4422. __pyx_vtable_5thinc_6linalg_Vec.reciprocal_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, int32_t))__pyx_f_5thinc_6linalg_3Vec_reciprocal_i;
  4423. if (PyType_Ready(&__pyx_type_5thinc_6linalg_Vec) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
  4424. __pyx_type_5thinc_6linalg_Vec.tp_print = 0;
  4425. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5thinc_6linalg_Vec.tp_dictoffset && __pyx_type_5thinc_6linalg_Vec.tp_getattro == PyObject_GenericGetAttr)) {
  4426. __pyx_type_5thinc_6linalg_Vec.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  4427. }
  4428. if (__Pyx_SetVtable(__pyx_type_5thinc_6linalg_Vec.tp_dict, __pyx_vtabptr_5thinc_6linalg_Vec) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
  4429. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Vec, (PyObject *)&__pyx_type_5thinc_6linalg_Vec) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
  4430. __pyx_ptype_5thinc_6linalg_Vec = &__pyx_type_5thinc_6linalg_Vec;
  4431. __pyx_vtabptr_5thinc_6linalg_VecVec = &__pyx_vtable_5thinc_6linalg_VecVec;
  4432. __pyx_vtable_5thinc_6linalg_VecVec.add = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t))__pyx_f_5thinc_6linalg_6VecVec_add;
  4433. __pyx_vtable_5thinc_6linalg_VecVec.add_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t))__pyx_f_5thinc_6linalg_6VecVec_add_i;
  4434. __pyx_vtable_5thinc_6linalg_VecVec.batch_add_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t, int32_t))__pyx_f_5thinc_6linalg_6VecVec_batch_add_i;
  4435. __pyx_vtable_5thinc_6linalg_VecVec.add_pow = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t))__pyx_f_5thinc_6linalg_6VecVec_add_pow;
  4436. __pyx_vtable_5thinc_6linalg_VecVec.add_pow_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t))__pyx_f_5thinc_6linalg_6VecVec_add_pow_i;
  4437. __pyx_vtable_5thinc_6linalg_VecVec.mul = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t))__pyx_f_5thinc_6linalg_6VecVec_mul;
  4438. __pyx_vtable_5thinc_6linalg_VecVec.mul_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t))__pyx_f_5thinc_6linalg_6VecVec_mul_i;
  4439. __pyx_vtable_5thinc_6linalg_VecVec.dot = (__pyx_t_5thinc_8typedefs_weight_t (*)(__pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t))__pyx_f_5thinc_6linalg_6VecVec_dot;
  4440. __pyx_vtable_5thinc_6linalg_VecVec.arg_max_if_true = (int (*)(__pyx_t_5thinc_8typedefs_weight_t const *, int const *, int const ))__pyx_f_5thinc_6linalg_6VecVec_arg_max_if_true;
  4441. __pyx_vtable_5thinc_6linalg_VecVec.arg_max_if_zero = (int (*)(__pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int const ))__pyx_f_5thinc_6linalg_6VecVec_arg_max_if_zero;
  4442. if (PyType_Ready(&__pyx_type_5thinc_6linalg_VecVec) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
  4443. __pyx_type_5thinc_6linalg_VecVec.tp_print = 0;
  4444. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5thinc_6linalg_VecVec.tp_dictoffset && __pyx_type_5thinc_6linalg_VecVec.tp_getattro == PyObject_GenericGetAttr)) {
  4445. __pyx_type_5thinc_6linalg_VecVec.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  4446. }
  4447. if (__Pyx_SetVtable(__pyx_type_5thinc_6linalg_VecVec.tp_dict, __pyx_vtabptr_5thinc_6linalg_VecVec) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
  4448. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_VecVec, (PyObject *)&__pyx_type_5thinc_6linalg_VecVec) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
  4449. __pyx_ptype_5thinc_6linalg_VecVec = &__pyx_type_5thinc_6linalg_VecVec;
  4450. __pyx_vtabptr_5thinc_6linalg_Mat = &__pyx_vtable_5thinc_6linalg_Mat;
  4451. __pyx_vtable_5thinc_6linalg_Mat.mean_row = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t))__pyx_f_5thinc_6linalg_3Mat_mean_row;
  4452. __pyx_vtable_5thinc_6linalg_Mat.var_row = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, __pyx_t_5thinc_8typedefs_weight_t))__pyx_f_5thinc_6linalg_3Mat_var_row;
  4453. if (PyType_Ready(&__pyx_type_5thinc_6linalg_Mat) < 0) __PYX_ERR(0, 231, __pyx_L1_error)
  4454. __pyx_type_5thinc_6linalg_Mat.tp_print = 0;
  4455. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5thinc_6linalg_Mat.tp_dictoffset && __pyx_type_5thinc_6linalg_Mat.tp_getattro == PyObject_GenericGetAttr)) {
  4456. __pyx_type_5thinc_6linalg_Mat.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  4457. }
  4458. if (__Pyx_SetVtable(__pyx_type_5thinc_6linalg_Mat.tp_dict, __pyx_vtabptr_5thinc_6linalg_Mat) < 0) __PYX_ERR(0, 231, __pyx_L1_error)
  4459. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Mat, (PyObject *)&__pyx_type_5thinc_6linalg_Mat) < 0) __PYX_ERR(0, 231, __pyx_L1_error)
  4460. __pyx_ptype_5thinc_6linalg_Mat = &__pyx_type_5thinc_6linalg_Mat;
  4461. __pyx_vtabptr_5thinc_6linalg_MatVec = &__pyx_vtable_5thinc_6linalg_MatVec;
  4462. __pyx_vtable_5thinc_6linalg_MatVec.add_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatVec_add_i;
  4463. __pyx_vtable_5thinc_6linalg_MatVec.mul = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatVec_mul;
  4464. __pyx_vtable_5thinc_6linalg_MatVec.mul_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatVec_mul_i;
  4465. __pyx_vtable_5thinc_6linalg_MatVec.dot = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatVec_dot;
  4466. __pyx_vtable_5thinc_6linalg_MatVec.batch_dot = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatVec_batch_dot;
  4467. __pyx_vtable_5thinc_6linalg_MatVec.T_dot = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatVec_T_dot;
  4468. __pyx_vtable_5thinc_6linalg_MatVec.batch_T_dot = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatVec_batch_T_dot;
  4469. if (PyType_Ready(&__pyx_type_5thinc_6linalg_MatVec) < 0) __PYX_ERR(0, 259, __pyx_L1_error)
  4470. __pyx_type_5thinc_6linalg_MatVec.tp_print = 0;
  4471. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5thinc_6linalg_MatVec.tp_dictoffset && __pyx_type_5thinc_6linalg_MatVec.tp_getattro == PyObject_GenericGetAttr)) {
  4472. __pyx_type_5thinc_6linalg_MatVec.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  4473. }
  4474. if (__Pyx_SetVtable(__pyx_type_5thinc_6linalg_MatVec.tp_dict, __pyx_vtabptr_5thinc_6linalg_MatVec) < 0) __PYX_ERR(0, 259, __pyx_L1_error)
  4475. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_MatVec, (PyObject *)&__pyx_type_5thinc_6linalg_MatVec) < 0) __PYX_ERR(0, 259, __pyx_L1_error)
  4476. __pyx_ptype_5thinc_6linalg_MatVec = &__pyx_type_5thinc_6linalg_MatVec;
  4477. __pyx_vtabptr_5thinc_6linalg_MatMat = &__pyx_vtable_5thinc_6linalg_MatMat;
  4478. __pyx_vtable_5thinc_6linalg_MatMat.add = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatMat_add;
  4479. __pyx_vtable_5thinc_6linalg_MatMat.add_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatMat_add_i;
  4480. __pyx_vtable_5thinc_6linalg_MatMat.mul = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatMat_mul;
  4481. __pyx_vtable_5thinc_6linalg_MatMat.mul_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatMat_mul_i;
  4482. __pyx_vtable_5thinc_6linalg_MatMat.add_outer_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatMat_add_outer_i;
  4483. __pyx_vtable_5thinc_6linalg_MatMat.batch_add_outer_i = (void (*)(__pyx_t_5thinc_8typedefs_weight_t *, __pyx_t_5thinc_8typedefs_weight_t const *, __pyx_t_5thinc_8typedefs_weight_t const *, int32_t, int32_t, int32_t))__pyx_f_5thinc_6linalg_6MatMat_batch_add_outer_i;
  4484. if (PyType_Ready(&__pyx_type_5thinc_6linalg_MatMat) < 0) __PYX_ERR(0, 425, __pyx_L1_error)
  4485. __pyx_type_5thinc_6linalg_MatMat.tp_print = 0;
  4486. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5thinc_6linalg_MatMat.tp_dictoffset && __pyx_type_5thinc_6linalg_MatMat.tp_getattro == PyObject_GenericGetAttr)) {
  4487. __pyx_type_5thinc_6linalg_MatMat.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  4488. }
  4489. if (__Pyx_SetVtable(__pyx_type_5thinc_6linalg_MatMat.tp_dict, __pyx_vtabptr_5thinc_6linalg_MatMat) < 0) __PYX_ERR(0, 425, __pyx_L1_error)
  4490. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_MatMat, (PyObject *)&__pyx_type_5thinc_6linalg_MatMat) < 0) __PYX_ERR(0, 425, __pyx_L1_error)
  4491. __pyx_ptype_5thinc_6linalg_MatMat = &__pyx_type_5thinc_6linalg_MatMat;
  4492. __Pyx_RefNannyFinishContext();
  4493. return 0;
  4494. __pyx_L1_error:;
  4495. __Pyx_RefNannyFinishContext();
  4496. return -1;
  4497. }
  4498. static int __Pyx_modinit_type_import_code(void) {
  4499. __Pyx_RefNannyDeclarations
  4500. PyObject *__pyx_t_1 = NULL;
  4501. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  4502. /*--- Type import code ---*/
  4503. __pyx_t_1 = PyImport_ImportModule("cymem.cymem"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  4504. __Pyx_GOTREF(__pyx_t_1);
  4505. __pyx_ptype_5cymem_5cymem_PyMalloc = __Pyx_ImportType(__pyx_t_1, "cymem.cymem", "PyMalloc", sizeof(struct __pyx_obj_5cymem_5cymem_PyMalloc), __Pyx_ImportType_CheckSize_Warn);
  4506. if (!__pyx_ptype_5cymem_5cymem_PyMalloc) __PYX_ERR(2, 4, __pyx_L1_error)
  4507. __pyx_vtabptr_5cymem_5cymem_PyMalloc = (struct __pyx_vtabstruct_5cymem_5cymem_PyMalloc*)__Pyx_GetVtable(__pyx_ptype_5cymem_5cymem_PyMalloc->tp_dict); if (unlikely(!__pyx_vtabptr_5cymem_5cymem_PyMalloc)) __PYX_ERR(2, 4, __pyx_L1_error)
  4508. __pyx_ptype_5cymem_5cymem_PyFree = __Pyx_ImportType(__pyx_t_1, "cymem.cymem", "PyFree", sizeof(struct __pyx_obj_5cymem_5cymem_PyFree), __Pyx_ImportType_CheckSize_Warn);
  4509. if (!__pyx_ptype_5cymem_5cymem_PyFree) __PYX_ERR(2, 10, __pyx_L1_error)
  4510. __pyx_vtabptr_5cymem_5cymem_PyFree = (struct __pyx_vtabstruct_5cymem_5cymem_PyFree*)__Pyx_GetVtable(__pyx_ptype_5cymem_5cymem_PyFree->tp_dict); if (unlikely(!__pyx_vtabptr_5cymem_5cymem_PyFree)) __PYX_ERR(2, 10, __pyx_L1_error)
  4511. __pyx_ptype_5cymem_5cymem_Pool = __Pyx_ImportType(__pyx_t_1, "cymem.cymem", "Pool", sizeof(struct __pyx_obj_5cymem_5cymem_Pool), __Pyx_ImportType_CheckSize_Warn);
  4512. if (!__pyx_ptype_5cymem_5cymem_Pool) __PYX_ERR(2, 16, __pyx_L1_error)
  4513. __pyx_vtabptr_5cymem_5cymem_Pool = (struct __pyx_vtabstruct_5cymem_5cymem_Pool*)__Pyx_GetVtable(__pyx_ptype_5cymem_5cymem_Pool->tp_dict); if (unlikely(!__pyx_vtabptr_5cymem_5cymem_Pool)) __PYX_ERR(2, 16, __pyx_L1_error)
  4514. __pyx_ptype_5cymem_5cymem_Address = __Pyx_ImportType(__pyx_t_1, "cymem.cymem", "Address", sizeof(struct __pyx_obj_5cymem_5cymem_Address), __Pyx_ImportType_CheckSize_Warn);
  4515. if (!__pyx_ptype_5cymem_5cymem_Address) __PYX_ERR(2, 28, __pyx_L1_error)
  4516. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4517. __Pyx_RefNannyFinishContext();
  4518. return 0;
  4519. __pyx_L1_error:;
  4520. __Pyx_XDECREF(__pyx_t_1);
  4521. __Pyx_RefNannyFinishContext();
  4522. return -1;
  4523. }
  4524. static int __Pyx_modinit_variable_import_code(void) {
  4525. __Pyx_RefNannyDeclarations
  4526. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  4527. /*--- Variable import code ---*/
  4528. __Pyx_RefNannyFinishContext();
  4529. return 0;
  4530. }
  4531. static int __Pyx_modinit_function_import_code(void) {
  4532. __Pyx_RefNannyDeclarations
  4533. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  4534. /*--- Function import code ---*/
  4535. __Pyx_RefNannyFinishContext();
  4536. return 0;
  4537. }
  4538. #if PY_MAJOR_VERSION < 3
  4539. #ifdef CYTHON_NO_PYINIT_EXPORT
  4540. #define __Pyx_PyMODINIT_FUNC void
  4541. #else
  4542. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  4543. #endif
  4544. #else
  4545. #ifdef CYTHON_NO_PYINIT_EXPORT
  4546. #define __Pyx_PyMODINIT_FUNC PyObject *
  4547. #else
  4548. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  4549. #endif
  4550. #endif
  4551. #if PY_MAJOR_VERSION < 3
  4552. __Pyx_PyMODINIT_FUNC initlinalg(void) CYTHON_SMALL_CODE; /*proto*/
  4553. __Pyx_PyMODINIT_FUNC initlinalg(void)
  4554. #else
  4555. __Pyx_PyMODINIT_FUNC PyInit_linalg(void) CYTHON_SMALL_CODE; /*proto*/
  4556. __Pyx_PyMODINIT_FUNC PyInit_linalg(void)
  4557. #if CYTHON_PEP489_MULTI_PHASE_INIT
  4558. {
  4559. return PyModuleDef_Init(&__pyx_moduledef);
  4560. }
  4561. static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
  4562. #if PY_VERSION_HEX >= 0x030700A1
  4563. static PY_INT64_T main_interpreter_id = -1;
  4564. PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
  4565. if (main_interpreter_id == -1) {
  4566. main_interpreter_id = current_id;
  4567. return (unlikely(current_id == -1)) ? -1 : 0;
  4568. } else if (unlikely(main_interpreter_id != current_id))
  4569. #else
  4570. static PyInterpreterState *main_interpreter = NULL;
  4571. PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
  4572. if (!main_interpreter) {
  4573. main_interpreter = current_interpreter;
  4574. } else if (unlikely(main_interpreter != current_interpreter))
  4575. #endif
  4576. {
  4577. PyErr_SetString(
  4578. PyExc_ImportError,
  4579. "Interpreter change detected - this module can only be loaded into one interpreter per process.");
  4580. return -1;
  4581. }
  4582. return 0;
  4583. }
  4584. 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) {
  4585. PyObject *value = PyObject_GetAttrString(spec, from_name);
  4586. int result = 0;
  4587. if (likely(value)) {
  4588. if (allow_none || value != Py_None) {
  4589. result = PyDict_SetItemString(moddict, to_name, value);
  4590. }
  4591. Py_DECREF(value);
  4592. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  4593. PyErr_Clear();
  4594. } else {
  4595. result = -1;
  4596. }
  4597. return result;
  4598. }
  4599. static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
  4600. PyObject *module = NULL, *moddict, *modname;
  4601. if (__Pyx_check_single_interpreter())
  4602. return NULL;
  4603. if (__pyx_m)
  4604. return __Pyx_NewRef(__pyx_m);
  4605. modname = PyObject_GetAttrString(spec, "name");
  4606. if (unlikely(!modname)) goto bad;
  4607. module = PyModule_NewObject(modname);
  4608. Py_DECREF(modname);
  4609. if (unlikely(!module)) goto bad;
  4610. moddict = PyModule_GetDict(module);
  4611. if (unlikely(!moddict)) goto bad;
  4612. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
  4613. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
  4614. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
  4615. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
  4616. return module;
  4617. bad:
  4618. Py_XDECREF(module);
  4619. return NULL;
  4620. }
  4621. static CYTHON_SMALL_CODE int __pyx_pymod_exec_linalg(PyObject *__pyx_pyinit_module)
  4622. #endif
  4623. #endif
  4624. {
  4625. PyObject *__pyx_t_1 = NULL;
  4626. __Pyx_RefNannyDeclarations
  4627. #if CYTHON_PEP489_MULTI_PHASE_INIT
  4628. if (__pyx_m) {
  4629. if (__pyx_m == __pyx_pyinit_module) return 0;
  4630. PyErr_SetString(PyExc_RuntimeError, "Module 'linalg' has already been imported. Re-initialisation is not supported.");
  4631. return -1;
  4632. }
  4633. #elif PY_MAJOR_VERSION >= 3
  4634. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  4635. #endif
  4636. #if CYTHON_REFNANNY
  4637. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  4638. if (!__Pyx_RefNanny) {
  4639. PyErr_Clear();
  4640. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  4641. if (!__Pyx_RefNanny)
  4642. Py_FatalError("failed to import 'refnanny' module");
  4643. }
  4644. #endif
  4645. __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_linalg(void)", 0);
  4646. if (__Pyx_check_binary_version() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4647. #ifdef __Pxy_PyFrame_Initialize_Offsets
  4648. __Pxy_PyFrame_Initialize_Offsets();
  4649. #endif
  4650. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(1, 1, __pyx_L1_error)
  4651. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(1, 1, __pyx_L1_error)
  4652. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(1, 1, __pyx_L1_error)
  4653. #ifdef __Pyx_CyFunction_USED
  4654. if (__pyx_CyFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4655. #endif
  4656. #ifdef __Pyx_FusedFunction_USED
  4657. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4658. #endif
  4659. #ifdef __Pyx_Coroutine_USED
  4660. if (__pyx_Coroutine_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4661. #endif
  4662. #ifdef __Pyx_Generator_USED
  4663. if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4664. #endif
  4665. #ifdef __Pyx_AsyncGen_USED
  4666. if (__pyx_AsyncGen_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4667. #endif
  4668. #ifdef __Pyx_StopAsyncIteration_USED
  4669. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4670. #endif
  4671. /*--- Library function declarations ---*/
  4672. /*--- Threads initialization code ---*/
  4673. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  4674. #ifdef WITH_THREAD /* Python build with threading support? */
  4675. PyEval_InitThreads();
  4676. #endif
  4677. #endif
  4678. /*--- Module creation code ---*/
  4679. #if CYTHON_PEP489_MULTI_PHASE_INIT
  4680. __pyx_m = __pyx_pyinit_module;
  4681. Py_INCREF(__pyx_m);
  4682. #else
  4683. #if PY_MAJOR_VERSION < 3
  4684. __pyx_m = Py_InitModule4("linalg", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  4685. #else
  4686. __pyx_m = PyModule_Create(&__pyx_moduledef);
  4687. #endif
  4688. if (unlikely(!__pyx_m)) __PYX_ERR(1, 1, __pyx_L1_error)
  4689. #endif
  4690. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error)
  4691. Py_INCREF(__pyx_d);
  4692. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error)
  4693. __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(1, 1, __pyx_L1_error)
  4694. #if CYTHON_COMPILING_IN_PYPY
  4695. Py_INCREF(__pyx_b);
  4696. #endif
  4697. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
  4698. /*--- Initialize various global constants etc. ---*/
  4699. if (__Pyx_InitGlobals() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4700. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  4701. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4702. #endif
  4703. if (__pyx_module_is_main_thinc__linalg) {
  4704. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4705. }
  4706. #if PY_MAJOR_VERSION >= 3
  4707. {
  4708. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(1, 1, __pyx_L1_error)
  4709. if (!PyDict_GetItemString(modules, "thinc.linalg")) {
  4710. if (unlikely(PyDict_SetItemString(modules, "thinc.linalg", __pyx_m) < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
  4711. }
  4712. }
  4713. #endif
  4714. /*--- Builtin init code ---*/
  4715. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4716. /*--- Constants init code ---*/
  4717. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4718. /*--- Global type/function init code ---*/
  4719. (void)__Pyx_modinit_global_init_code();
  4720. (void)__Pyx_modinit_variable_export_code();
  4721. (void)__Pyx_modinit_function_export_code();
  4722. if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  4723. if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
  4724. (void)__Pyx_modinit_variable_import_code();
  4725. (void)__Pyx_modinit_function_import_code();
  4726. /*--- Execution code ---*/
  4727. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  4728. if (__Pyx_patch_abc() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4729. #endif
  4730. /* "thinc/linalg.pyx":1
  4731. * # This executes the code in the module, initialising blis # <<<<<<<<<<<<<<
  4732. * #import blis.blis
  4733. */
  4734. __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  4735. __Pyx_GOTREF(__pyx_t_1);
  4736. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  4737. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4738. /* "thinc/linalg.pxd":486
  4739. *
  4740. * @staticmethod
  4741. * cdef inline void batch_add_outer_i(weight_t* output, # <<<<<<<<<<<<<<
  4742. * const weight_t* x,
  4743. * const weight_t* y,
  4744. */
  4745. /*--- Wrapped vars code ---*/
  4746. goto __pyx_L0;
  4747. __pyx_L1_error:;
  4748. __Pyx_XDECREF(__pyx_t_1);
  4749. if (__pyx_m) {
  4750. if (__pyx_d) {
  4751. __Pyx_AddTraceback("init thinc.linalg", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4752. }
  4753. Py_CLEAR(__pyx_m);
  4754. } else if (!PyErr_Occurred()) {
  4755. PyErr_SetString(PyExc_ImportError, "init thinc.linalg");
  4756. }
  4757. __pyx_L0:;
  4758. __Pyx_RefNannyFinishContext();
  4759. #if CYTHON_PEP489_MULTI_PHASE_INIT
  4760. return (__pyx_m != NULL) ? 0 : -1;
  4761. #elif PY_MAJOR_VERSION >= 3
  4762. return __pyx_m;
  4763. #else
  4764. return;
  4765. #endif
  4766. }
  4767. /* --- Runtime support code --- */
  4768. /* Refnanny */
  4769. #if CYTHON_REFNANNY
  4770. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  4771. PyObject *m = NULL, *p = NULL;
  4772. void *r = NULL;
  4773. m = PyImport_ImportModule(modname);
  4774. if (!m) goto end;
  4775. p = PyObject_GetAttrString(m, "RefNannyAPI");
  4776. if (!p) goto end;
  4777. r = PyLong_AsVoidPtr(p);
  4778. end:
  4779. Py_XDECREF(p);
  4780. Py_XDECREF(m);
  4781. return (__Pyx_RefNannyAPIStruct *)r;
  4782. }
  4783. #endif
  4784. /* PyObjectGetAttrStr */
  4785. #if CYTHON_USE_TYPE_SLOTS
  4786. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  4787. PyTypeObject* tp = Py_TYPE(obj);
  4788. if (likely(tp->tp_getattro))
  4789. return tp->tp_getattro(obj, attr_name);
  4790. #if PY_MAJOR_VERSION < 3
  4791. if (likely(tp->tp_getattr))
  4792. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  4793. #endif
  4794. return PyObject_GetAttr(obj, attr_name);
  4795. }
  4796. #endif
  4797. /* GetBuiltinName */
  4798. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  4799. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  4800. if (unlikely(!result)) {
  4801. PyErr_Format(PyExc_NameError,
  4802. #if PY_MAJOR_VERSION >= 3
  4803. "name '%U' is not defined", name);
  4804. #else
  4805. "name '%.200s' is not defined", PyString_AS_STRING(name));
  4806. #endif
  4807. }
  4808. return result;
  4809. }
  4810. /* PyObject_GenericGetAttrNoDict */
  4811. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  4812. static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
  4813. PyErr_Format(PyExc_AttributeError,
  4814. #if PY_MAJOR_VERSION >= 3
  4815. "'%.50s' object has no attribute '%U'",
  4816. tp->tp_name, attr_name);
  4817. #else
  4818. "'%.50s' object has no attribute '%.400s'",
  4819. tp->tp_name, PyString_AS_STRING(attr_name));
  4820. #endif
  4821. return NULL;
  4822. }
  4823. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
  4824. PyObject *descr;
  4825. PyTypeObject *tp = Py_TYPE(obj);
  4826. if (unlikely(!PyString_Check(attr_name))) {
  4827. return PyObject_GenericGetAttr(obj, attr_name);
  4828. }
  4829. assert(!tp->tp_dictoffset);
  4830. descr = _PyType_Lookup(tp, attr_name);
  4831. if (unlikely(!descr)) {
  4832. return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
  4833. }
  4834. Py_INCREF(descr);
  4835. #if PY_MAJOR_VERSION < 3
  4836. if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
  4837. #endif
  4838. {
  4839. descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
  4840. if (unlikely(f)) {
  4841. PyObject *res = f(descr, obj, (PyObject *)tp);
  4842. Py_DECREF(descr);
  4843. return res;
  4844. }
  4845. }
  4846. return descr;
  4847. }
  4848. #endif
  4849. /* PyObject_GenericGetAttr */
  4850. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  4851. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
  4852. if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
  4853. return PyObject_GenericGetAttr(obj, attr_name);
  4854. }
  4855. return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
  4856. }
  4857. #endif
  4858. /* SetVTable */
  4859. static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
  4860. #if PY_VERSION_HEX >= 0x02070000
  4861. PyObject *ob = PyCapsule_New(vtable, 0, 0);
  4862. #else
  4863. PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
  4864. #endif
  4865. if (!ob)
  4866. goto bad;
  4867. if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
  4868. goto bad;
  4869. Py_DECREF(ob);
  4870. return 0;
  4871. bad:
  4872. Py_XDECREF(ob);
  4873. return -1;
  4874. }
  4875. /* TypeImport */
  4876. #ifndef __PYX_HAVE_RT_ImportType
  4877. #define __PYX_HAVE_RT_ImportType
  4878. static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
  4879. size_t size, enum __Pyx_ImportType_CheckSize check_size)
  4880. {
  4881. PyObject *result = 0;
  4882. char warning[200];
  4883. Py_ssize_t basicsize;
  4884. #ifdef Py_LIMITED_API
  4885. PyObject *py_basicsize;
  4886. #endif
  4887. result = PyObject_GetAttrString(module, class_name);
  4888. if (!result)
  4889. goto bad;
  4890. if (!PyType_Check(result)) {
  4891. PyErr_Format(PyExc_TypeError,
  4892. "%.200s.%.200s is not a type object",
  4893. module_name, class_name);
  4894. goto bad;
  4895. }
  4896. #ifndef Py_LIMITED_API
  4897. basicsize = ((PyTypeObject *)result)->tp_basicsize;
  4898. #else
  4899. py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
  4900. if (!py_basicsize)
  4901. goto bad;
  4902. basicsize = PyLong_AsSsize_t(py_basicsize);
  4903. Py_DECREF(py_basicsize);
  4904. py_basicsize = 0;
  4905. if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
  4906. goto bad;
  4907. #endif
  4908. if ((size_t)basicsize < size) {
  4909. PyErr_Format(PyExc_ValueError,
  4910. "%.200s.%.200s size changed, may indicate binary incompatibility. "
  4911. "Expected %zd from C header, got %zd from PyObject",
  4912. module_name, class_name, size, basicsize);
  4913. goto bad;
  4914. }
  4915. if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
  4916. PyErr_Format(PyExc_ValueError,
  4917. "%.200s.%.200s size changed, may indicate binary incompatibility. "
  4918. "Expected %zd from C header, got %zd from PyObject",
  4919. module_name, class_name, size, basicsize);
  4920. goto bad;
  4921. }
  4922. else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
  4923. PyOS_snprintf(warning, sizeof(warning),
  4924. "%s.%s size changed, may indicate binary incompatibility. "
  4925. "Expected %zd from C header, got %zd from PyObject",
  4926. module_name, class_name, size, basicsize);
  4927. if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
  4928. }
  4929. return (PyTypeObject *)result;
  4930. bad:
  4931. Py_XDECREF(result);
  4932. return NULL;
  4933. }
  4934. #endif
  4935. /* GetVTable */
  4936. static void* __Pyx_GetVtable(PyObject *dict) {
  4937. void* ptr;
  4938. PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
  4939. if (!ob)
  4940. goto bad;
  4941. #if PY_VERSION_HEX >= 0x02070000
  4942. ptr = PyCapsule_GetPointer(ob, 0);
  4943. #else
  4944. ptr = PyCObject_AsVoidPtr(ob);
  4945. #endif
  4946. if (!ptr && !PyErr_Occurred())
  4947. PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
  4948. Py_DECREF(ob);
  4949. return ptr;
  4950. bad:
  4951. Py_XDECREF(ob);
  4952. return NULL;
  4953. }
  4954. /* PyErrFetchRestore */
  4955. #if CYTHON_FAST_THREAD_STATE
  4956. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  4957. PyObject *tmp_type, *tmp_value, *tmp_tb;
  4958. tmp_type = tstate->curexc_type;
  4959. tmp_value = tstate->curexc_value;
  4960. tmp_tb = tstate->curexc_traceback;
  4961. tstate->curexc_type = type;
  4962. tstate->curexc_value = value;
  4963. tstate->curexc_traceback = tb;
  4964. Py_XDECREF(tmp_type);
  4965. Py_XDECREF(tmp_value);
  4966. Py_XDECREF(tmp_tb);
  4967. }
  4968. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  4969. *type = tstate->curexc_type;
  4970. *value = tstate->curexc_value;
  4971. *tb = tstate->curexc_traceback;
  4972. tstate->curexc_type = 0;
  4973. tstate->curexc_value = 0;
  4974. tstate->curexc_traceback = 0;
  4975. }
  4976. #endif
  4977. /* CLineInTraceback */
  4978. #ifndef CYTHON_CLINE_IN_TRACEBACK
  4979. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
  4980. PyObject *use_cline;
  4981. PyObject *ptype, *pvalue, *ptraceback;
  4982. #if CYTHON_COMPILING_IN_CPYTHON
  4983. PyObject **cython_runtime_dict;
  4984. #endif
  4985. if (unlikely(!__pyx_cython_runtime)) {
  4986. return c_line;
  4987. }
  4988. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  4989. #if CYTHON_COMPILING_IN_CPYTHON
  4990. cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
  4991. if (likely(cython_runtime_dict)) {
  4992. __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
  4993. use_cline, *cython_runtime_dict,
  4994. __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
  4995. } else
  4996. #endif
  4997. {
  4998. PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
  4999. if (use_cline_obj) {
  5000. use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
  5001. Py_DECREF(use_cline_obj);
  5002. } else {
  5003. PyErr_Clear();
  5004. use_cline = NULL;
  5005. }
  5006. }
  5007. if (!use_cline) {
  5008. c_line = 0;
  5009. PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
  5010. }
  5011. else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
  5012. c_line = 0;
  5013. }
  5014. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  5015. return c_line;
  5016. }
  5017. #endif
  5018. /* CodeObjectCache */
  5019. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  5020. int start = 0, mid = 0, end = count - 1;
  5021. if (end >= 0 && code_line > entries[end].code_line) {
  5022. return count;
  5023. }
  5024. while (start < end) {
  5025. mid = start + (end - start) / 2;
  5026. if (code_line < entries[mid].code_line) {
  5027. end = mid;
  5028. } else if (code_line > entries[mid].code_line) {
  5029. start = mid + 1;
  5030. } else {
  5031. return mid;
  5032. }
  5033. }
  5034. if (code_line <= entries[mid].code_line) {
  5035. return mid;
  5036. } else {
  5037. return mid + 1;
  5038. }
  5039. }
  5040. static PyCodeObject *__pyx_find_code_object(int code_line) {
  5041. PyCodeObject* code_object;
  5042. int pos;
  5043. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  5044. return NULL;
  5045. }
  5046. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  5047. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  5048. return NULL;
  5049. }
  5050. code_object = __pyx_code_cache.entries[pos].code_object;
  5051. Py_INCREF(code_object);
  5052. return code_object;
  5053. }
  5054. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  5055. int pos, i;
  5056. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  5057. if (unlikely(!code_line)) {
  5058. return;
  5059. }
  5060. if (unlikely(!entries)) {
  5061. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  5062. if (likely(entries)) {
  5063. __pyx_code_cache.entries = entries;
  5064. __pyx_code_cache.max_count = 64;
  5065. __pyx_code_cache.count = 1;
  5066. entries[0].code_line = code_line;
  5067. entries[0].code_object = code_object;
  5068. Py_INCREF(code_object);
  5069. }
  5070. return;
  5071. }
  5072. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  5073. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  5074. PyCodeObject* tmp = entries[pos].code_object;
  5075. entries[pos].code_object = code_object;
  5076. Py_DECREF(tmp);
  5077. return;
  5078. }
  5079. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  5080. int new_max = __pyx_code_cache.max_count + 64;
  5081. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  5082. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  5083. if (unlikely(!entries)) {
  5084. return;
  5085. }
  5086. __pyx_code_cache.entries = entries;
  5087. __pyx_code_cache.max_count = new_max;
  5088. }
  5089. for (i=__pyx_code_cache.count; i>pos; i--) {
  5090. entries[i] = entries[i-1];
  5091. }
  5092. entries[pos].code_line = code_line;
  5093. entries[pos].code_object = code_object;
  5094. __pyx_code_cache.count++;
  5095. Py_INCREF(code_object);
  5096. }
  5097. /* AddTraceback */
  5098. #include "compile.h"
  5099. #include "frameobject.h"
  5100. #include "traceback.h"
  5101. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  5102. const char *funcname, int c_line,
  5103. int py_line, const char *filename) {
  5104. PyCodeObject *py_code = 0;
  5105. PyObject *py_srcfile = 0;
  5106. PyObject *py_funcname = 0;
  5107. #if PY_MAJOR_VERSION < 3
  5108. py_srcfile = PyString_FromString(filename);
  5109. #else
  5110. py_srcfile = PyUnicode_FromString(filename);
  5111. #endif
  5112. if (!py_srcfile) goto bad;
  5113. if (c_line) {
  5114. #if PY_MAJOR_VERSION < 3
  5115. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  5116. #else
  5117. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  5118. #endif
  5119. }
  5120. else {
  5121. #if PY_MAJOR_VERSION < 3
  5122. py_funcname = PyString_FromString(funcname);
  5123. #else
  5124. py_funcname = PyUnicode_FromString(funcname);
  5125. #endif
  5126. }
  5127. if (!py_funcname) goto bad;
  5128. py_code = __Pyx_PyCode_New(
  5129. 0,
  5130. 0,
  5131. 0,
  5132. 0,
  5133. 0,
  5134. __pyx_empty_bytes, /*PyObject *code,*/
  5135. __pyx_empty_tuple, /*PyObject *consts,*/
  5136. __pyx_empty_tuple, /*PyObject *names,*/
  5137. __pyx_empty_tuple, /*PyObject *varnames,*/
  5138. __pyx_empty_tuple, /*PyObject *freevars,*/
  5139. __pyx_empty_tuple, /*PyObject *cellvars,*/
  5140. py_srcfile, /*PyObject *filename,*/
  5141. py_funcname, /*PyObject *name,*/
  5142. py_line,
  5143. __pyx_empty_bytes /*PyObject *lnotab*/
  5144. );
  5145. Py_DECREF(py_srcfile);
  5146. Py_DECREF(py_funcname);
  5147. return py_code;
  5148. bad:
  5149. Py_XDECREF(py_srcfile);
  5150. Py_XDECREF(py_funcname);
  5151. return NULL;
  5152. }
  5153. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  5154. int py_line, const char *filename) {
  5155. PyCodeObject *py_code = 0;
  5156. PyFrameObject *py_frame = 0;
  5157. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  5158. if (c_line) {
  5159. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  5160. }
  5161. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  5162. if (!py_code) {
  5163. py_code = __Pyx_CreateCodeObjectForTraceback(
  5164. funcname, c_line, py_line, filename);
  5165. if (!py_code) goto bad;
  5166. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  5167. }
  5168. py_frame = PyFrame_New(
  5169. tstate, /*PyThreadState *tstate,*/
  5170. py_code, /*PyCodeObject *code,*/
  5171. __pyx_d, /*PyObject *globals,*/
  5172. 0 /*PyObject *locals*/
  5173. );
  5174. if (!py_frame) goto bad;
  5175. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  5176. PyTraceBack_Here(py_frame);
  5177. bad:
  5178. Py_XDECREF(py_code);
  5179. Py_XDECREF(py_frame);
  5180. }
  5181. /* CIntToPy */
  5182. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
  5183. const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
  5184. const int is_unsigned = neg_one > const_zero;
  5185. if (is_unsigned) {
  5186. if (sizeof(int) < sizeof(long)) {
  5187. return PyInt_FromLong((long) value);
  5188. } else if (sizeof(int) <= sizeof(unsigned long)) {
  5189. return PyLong_FromUnsignedLong((unsigned long) value);
  5190. #ifdef HAVE_LONG_LONG
  5191. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  5192. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  5193. #endif
  5194. }
  5195. } else {
  5196. if (sizeof(int) <= sizeof(long)) {
  5197. return PyInt_FromLong((long) value);
  5198. #ifdef HAVE_LONG_LONG
  5199. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  5200. return PyLong_FromLongLong((PY_LONG_LONG) value);
  5201. #endif
  5202. }
  5203. }
  5204. {
  5205. int one = 1; int little = (int)*(unsigned char *)&one;
  5206. unsigned char *bytes = (unsigned char *)&value;
  5207. return _PyLong_FromByteArray(bytes, sizeof(int),
  5208. little, !is_unsigned);
  5209. }
  5210. }
  5211. /* CIntFromPyVerify */
  5212. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  5213. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  5214. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  5215. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  5216. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  5217. {\
  5218. func_type value = func_value;\
  5219. if (sizeof(target_type) < sizeof(func_type)) {\
  5220. if (unlikely(value != (func_type) (target_type) value)) {\
  5221. func_type zero = 0;\
  5222. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  5223. return (target_type) -1;\
  5224. if (is_unsigned && unlikely(value < zero))\
  5225. goto raise_neg_overflow;\
  5226. else\
  5227. goto raise_overflow;\
  5228. }\
  5229. }\
  5230. return (target_type) value;\
  5231. }
  5232. /* CIntToPy */
  5233. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value) {
  5234. const int32_t neg_one = (int32_t) ((int32_t) 0 - (int32_t) 1), const_zero = (int32_t) 0;
  5235. const int is_unsigned = neg_one > const_zero;
  5236. if (is_unsigned) {
  5237. if (sizeof(int32_t) < sizeof(long)) {
  5238. return PyInt_FromLong((long) value);
  5239. } else if (sizeof(int32_t) <= sizeof(unsigned long)) {
  5240. return PyLong_FromUnsignedLong((unsigned long) value);
  5241. #ifdef HAVE_LONG_LONG
  5242. } else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) {
  5243. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  5244. #endif
  5245. }
  5246. } else {
  5247. if (sizeof(int32_t) <= sizeof(long)) {
  5248. return PyInt_FromLong((long) value);
  5249. #ifdef HAVE_LONG_LONG
  5250. } else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) {
  5251. return PyLong_FromLongLong((PY_LONG_LONG) value);
  5252. #endif
  5253. }
  5254. }
  5255. {
  5256. int one = 1; int little = (int)*(unsigned char *)&one;
  5257. unsigned char *bytes = (unsigned char *)&value;
  5258. return _PyLong_FromByteArray(bytes, sizeof(int32_t),
  5259. little, !is_unsigned);
  5260. }
  5261. }
  5262. /* CIntFromPy */
  5263. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  5264. const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
  5265. const int is_unsigned = neg_one > const_zero;
  5266. #if PY_MAJOR_VERSION < 3
  5267. if (likely(PyInt_Check(x))) {
  5268. if (sizeof(int) < sizeof(long)) {
  5269. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  5270. } else {
  5271. long val = PyInt_AS_LONG(x);
  5272. if (is_unsigned && unlikely(val < 0)) {
  5273. goto raise_neg_overflow;
  5274. }
  5275. return (int) val;
  5276. }
  5277. } else
  5278. #endif
  5279. if (likely(PyLong_Check(x))) {
  5280. if (is_unsigned) {
  5281. #if CYTHON_USE_PYLONG_INTERNALS
  5282. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5283. switch (Py_SIZE(x)) {
  5284. case 0: return (int) 0;
  5285. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  5286. case 2:
  5287. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  5288. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5289. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5290. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  5291. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  5292. }
  5293. }
  5294. break;
  5295. case 3:
  5296. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  5297. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5298. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5299. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  5300. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  5301. }
  5302. }
  5303. break;
  5304. case 4:
  5305. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  5306. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5307. __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])))
  5308. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  5309. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  5310. }
  5311. }
  5312. break;
  5313. }
  5314. #endif
  5315. #if CYTHON_COMPILING_IN_CPYTHON
  5316. if (unlikely(Py_SIZE(x) < 0)) {
  5317. goto raise_neg_overflow;
  5318. }
  5319. #else
  5320. {
  5321. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  5322. if (unlikely(result < 0))
  5323. return (int) -1;
  5324. if (unlikely(result == 1))
  5325. goto raise_neg_overflow;
  5326. }
  5327. #endif
  5328. if (sizeof(int) <= sizeof(unsigned long)) {
  5329. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  5330. #ifdef HAVE_LONG_LONG
  5331. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  5332. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  5333. #endif
  5334. }
  5335. } else {
  5336. #if CYTHON_USE_PYLONG_INTERNALS
  5337. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5338. switch (Py_SIZE(x)) {
  5339. case 0: return (int) 0;
  5340. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  5341. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  5342. case -2:
  5343. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  5344. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5345. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5346. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  5347. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5348. }
  5349. }
  5350. break;
  5351. case 2:
  5352. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  5353. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5354. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5355. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  5356. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5357. }
  5358. }
  5359. break;
  5360. case -3:
  5361. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  5362. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5363. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5364. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  5365. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5366. }
  5367. }
  5368. break;
  5369. case 3:
  5370. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  5371. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5372. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5373. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  5374. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5375. }
  5376. }
  5377. break;
  5378. case -4:
  5379. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  5380. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5381. __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])))
  5382. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  5383. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5384. }
  5385. }
  5386. break;
  5387. case 4:
  5388. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  5389. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5390. __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])))
  5391. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  5392. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5393. }
  5394. }
  5395. break;
  5396. }
  5397. #endif
  5398. if (sizeof(int) <= sizeof(long)) {
  5399. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  5400. #ifdef HAVE_LONG_LONG
  5401. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  5402. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  5403. #endif
  5404. }
  5405. }
  5406. {
  5407. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  5408. PyErr_SetString(PyExc_RuntimeError,
  5409. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  5410. #else
  5411. int val;
  5412. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  5413. #if PY_MAJOR_VERSION < 3
  5414. if (likely(v) && !PyLong_Check(v)) {
  5415. PyObject *tmp = v;
  5416. v = PyNumber_Long(tmp);
  5417. Py_DECREF(tmp);
  5418. }
  5419. #endif
  5420. if (likely(v)) {
  5421. int one = 1; int is_little = (int)*(unsigned char *)&one;
  5422. unsigned char *bytes = (unsigned char *)&val;
  5423. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  5424. bytes, sizeof(val),
  5425. is_little, !is_unsigned);
  5426. Py_DECREF(v);
  5427. if (likely(!ret))
  5428. return val;
  5429. }
  5430. #endif
  5431. return (int) -1;
  5432. }
  5433. } else {
  5434. int val;
  5435. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  5436. if (!tmp) return (int) -1;
  5437. val = __Pyx_PyInt_As_int(tmp);
  5438. Py_DECREF(tmp);
  5439. return val;
  5440. }
  5441. raise_overflow:
  5442. PyErr_SetString(PyExc_OverflowError,
  5443. "value too large to convert to int");
  5444. return (int) -1;
  5445. raise_neg_overflow:
  5446. PyErr_SetString(PyExc_OverflowError,
  5447. "can't convert negative value to int");
  5448. return (int) -1;
  5449. }
  5450. /* CIntFromPy */
  5451. static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *x) {
  5452. const int32_t neg_one = (int32_t) ((int32_t) 0 - (int32_t) 1), const_zero = (int32_t) 0;
  5453. const int is_unsigned = neg_one > const_zero;
  5454. #if PY_MAJOR_VERSION < 3
  5455. if (likely(PyInt_Check(x))) {
  5456. if (sizeof(int32_t) < sizeof(long)) {
  5457. __PYX_VERIFY_RETURN_INT(int32_t, long, PyInt_AS_LONG(x))
  5458. } else {
  5459. long val = PyInt_AS_LONG(x);
  5460. if (is_unsigned && unlikely(val < 0)) {
  5461. goto raise_neg_overflow;
  5462. }
  5463. return (int32_t) val;
  5464. }
  5465. } else
  5466. #endif
  5467. if (likely(PyLong_Check(x))) {
  5468. if (is_unsigned) {
  5469. #if CYTHON_USE_PYLONG_INTERNALS
  5470. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5471. switch (Py_SIZE(x)) {
  5472. case 0: return (int32_t) 0;
  5473. case 1: __PYX_VERIFY_RETURN_INT(int32_t, digit, digits[0])
  5474. case 2:
  5475. if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) {
  5476. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5477. __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5478. } else if (8 * sizeof(int32_t) >= 2 * PyLong_SHIFT) {
  5479. return (int32_t) (((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
  5480. }
  5481. }
  5482. break;
  5483. case 3:
  5484. if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) {
  5485. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5486. __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5487. } else if (8 * sizeof(int32_t) >= 3 * PyLong_SHIFT) {
  5488. return (int32_t) (((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
  5489. }
  5490. }
  5491. break;
  5492. case 4:
  5493. if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) {
  5494. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5495. __PYX_VERIFY_RETURN_INT(int32_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])))
  5496. } else if (8 * sizeof(int32_t) >= 4 * PyLong_SHIFT) {
  5497. return (int32_t) (((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
  5498. }
  5499. }
  5500. break;
  5501. }
  5502. #endif
  5503. #if CYTHON_COMPILING_IN_CPYTHON
  5504. if (unlikely(Py_SIZE(x) < 0)) {
  5505. goto raise_neg_overflow;
  5506. }
  5507. #else
  5508. {
  5509. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  5510. if (unlikely(result < 0))
  5511. return (int32_t) -1;
  5512. if (unlikely(result == 1))
  5513. goto raise_neg_overflow;
  5514. }
  5515. #endif
  5516. if (sizeof(int32_t) <= sizeof(unsigned long)) {
  5517. __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned long, PyLong_AsUnsignedLong(x))
  5518. #ifdef HAVE_LONG_LONG
  5519. } else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) {
  5520. __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  5521. #endif
  5522. }
  5523. } else {
  5524. #if CYTHON_USE_PYLONG_INTERNALS
  5525. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5526. switch (Py_SIZE(x)) {
  5527. case 0: return (int32_t) 0;
  5528. case -1: __PYX_VERIFY_RETURN_INT(int32_t, sdigit, (sdigit) (-(sdigit)digits[0]))
  5529. case 1: __PYX_VERIFY_RETURN_INT(int32_t, digit, +digits[0])
  5530. case -2:
  5531. if (8 * sizeof(int32_t) - 1 > 1 * PyLong_SHIFT) {
  5532. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5533. __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5534. } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
  5535. return (int32_t) (((int32_t)-1)*(((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
  5536. }
  5537. }
  5538. break;
  5539. case 2:
  5540. if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) {
  5541. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5542. __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5543. } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
  5544. return (int32_t) ((((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
  5545. }
  5546. }
  5547. break;
  5548. case -3:
  5549. if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
  5550. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5551. __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5552. } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
  5553. return (int32_t) (((int32_t)-1)*(((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
  5554. }
  5555. }
  5556. break;
  5557. case 3:
  5558. if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) {
  5559. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5560. __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5561. } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
  5562. return (int32_t) ((((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
  5563. }
  5564. }
  5565. break;
  5566. case -4:
  5567. if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
  5568. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5569. __PYX_VERIFY_RETURN_INT(int32_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])))
  5570. } else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) {
  5571. return (int32_t) (((int32_t)-1)*(((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
  5572. }
  5573. }
  5574. break;
  5575. case 4:
  5576. if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) {
  5577. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5578. __PYX_VERIFY_RETURN_INT(int32_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])))
  5579. } else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) {
  5580. return (int32_t) ((((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
  5581. }
  5582. }
  5583. break;
  5584. }
  5585. #endif
  5586. if (sizeof(int32_t) <= sizeof(long)) {
  5587. __PYX_VERIFY_RETURN_INT_EXC(int32_t, long, PyLong_AsLong(x))
  5588. #ifdef HAVE_LONG_LONG
  5589. } else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) {
  5590. __PYX_VERIFY_RETURN_INT_EXC(int32_t, PY_LONG_LONG, PyLong_AsLongLong(x))
  5591. #endif
  5592. }
  5593. }
  5594. {
  5595. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  5596. PyErr_SetString(PyExc_RuntimeError,
  5597. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  5598. #else
  5599. int32_t val;
  5600. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  5601. #if PY_MAJOR_VERSION < 3
  5602. if (likely(v) && !PyLong_Check(v)) {
  5603. PyObject *tmp = v;
  5604. v = PyNumber_Long(tmp);
  5605. Py_DECREF(tmp);
  5606. }
  5607. #endif
  5608. if (likely(v)) {
  5609. int one = 1; int is_little = (int)*(unsigned char *)&one;
  5610. unsigned char *bytes = (unsigned char *)&val;
  5611. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  5612. bytes, sizeof(val),
  5613. is_little, !is_unsigned);
  5614. Py_DECREF(v);
  5615. if (likely(!ret))
  5616. return val;
  5617. }
  5618. #endif
  5619. return (int32_t) -1;
  5620. }
  5621. } else {
  5622. int32_t val;
  5623. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  5624. if (!tmp) return (int32_t) -1;
  5625. val = __Pyx_PyInt_As_int32_t(tmp);
  5626. Py_DECREF(tmp);
  5627. return val;
  5628. }
  5629. raise_overflow:
  5630. PyErr_SetString(PyExc_OverflowError,
  5631. "value too large to convert to int32_t");
  5632. return (int32_t) -1;
  5633. raise_neg_overflow:
  5634. PyErr_SetString(PyExc_OverflowError,
  5635. "can't convert negative value to int32_t");
  5636. return (int32_t) -1;
  5637. }
  5638. /* CIntToPy */
  5639. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  5640. const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
  5641. const int is_unsigned = neg_one > const_zero;
  5642. if (is_unsigned) {
  5643. if (sizeof(long) < sizeof(long)) {
  5644. return PyInt_FromLong((long) value);
  5645. } else if (sizeof(long) <= sizeof(unsigned long)) {
  5646. return PyLong_FromUnsignedLong((unsigned long) value);
  5647. #ifdef HAVE_LONG_LONG
  5648. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  5649. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  5650. #endif
  5651. }
  5652. } else {
  5653. if (sizeof(long) <= sizeof(long)) {
  5654. return PyInt_FromLong((long) value);
  5655. #ifdef HAVE_LONG_LONG
  5656. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  5657. return PyLong_FromLongLong((PY_LONG_LONG) value);
  5658. #endif
  5659. }
  5660. }
  5661. {
  5662. int one = 1; int little = (int)*(unsigned char *)&one;
  5663. unsigned char *bytes = (unsigned char *)&value;
  5664. return _PyLong_FromByteArray(bytes, sizeof(long),
  5665. little, !is_unsigned);
  5666. }
  5667. }
  5668. /* CIntFromPy */
  5669. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  5670. const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
  5671. const int is_unsigned = neg_one > const_zero;
  5672. #if PY_MAJOR_VERSION < 3
  5673. if (likely(PyInt_Check(x))) {
  5674. if (sizeof(long) < sizeof(long)) {
  5675. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  5676. } else {
  5677. long val = PyInt_AS_LONG(x);
  5678. if (is_unsigned && unlikely(val < 0)) {
  5679. goto raise_neg_overflow;
  5680. }
  5681. return (long) val;
  5682. }
  5683. } else
  5684. #endif
  5685. if (likely(PyLong_Check(x))) {
  5686. if (is_unsigned) {
  5687. #if CYTHON_USE_PYLONG_INTERNALS
  5688. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5689. switch (Py_SIZE(x)) {
  5690. case 0: return (long) 0;
  5691. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  5692. case 2:
  5693. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  5694. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5695. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5696. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  5697. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  5698. }
  5699. }
  5700. break;
  5701. case 3:
  5702. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  5703. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5704. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5705. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  5706. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  5707. }
  5708. }
  5709. break;
  5710. case 4:
  5711. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  5712. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5713. __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])))
  5714. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  5715. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  5716. }
  5717. }
  5718. break;
  5719. }
  5720. #endif
  5721. #if CYTHON_COMPILING_IN_CPYTHON
  5722. if (unlikely(Py_SIZE(x) < 0)) {
  5723. goto raise_neg_overflow;
  5724. }
  5725. #else
  5726. {
  5727. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  5728. if (unlikely(result < 0))
  5729. return (long) -1;
  5730. if (unlikely(result == 1))
  5731. goto raise_neg_overflow;
  5732. }
  5733. #endif
  5734. if (sizeof(long) <= sizeof(unsigned long)) {
  5735. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  5736. #ifdef HAVE_LONG_LONG
  5737. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  5738. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  5739. #endif
  5740. }
  5741. } else {
  5742. #if CYTHON_USE_PYLONG_INTERNALS
  5743. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5744. switch (Py_SIZE(x)) {
  5745. case 0: return (long) 0;
  5746. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  5747. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  5748. case -2:
  5749. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  5750. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5751. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5752. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  5753. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5754. }
  5755. }
  5756. break;
  5757. case 2:
  5758. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  5759. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5760. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5761. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  5762. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5763. }
  5764. }
  5765. break;
  5766. case -3:
  5767. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  5768. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5769. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5770. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  5771. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5772. }
  5773. }
  5774. break;
  5775. case 3:
  5776. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  5777. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5778. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5779. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  5780. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5781. }
  5782. }
  5783. break;
  5784. case -4:
  5785. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  5786. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5787. __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])))
  5788. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  5789. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5790. }
  5791. }
  5792. break;
  5793. case 4:
  5794. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  5795. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5796. __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])))
  5797. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  5798. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5799. }
  5800. }
  5801. break;
  5802. }
  5803. #endif
  5804. if (sizeof(long) <= sizeof(long)) {
  5805. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  5806. #ifdef HAVE_LONG_LONG
  5807. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  5808. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  5809. #endif
  5810. }
  5811. }
  5812. {
  5813. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  5814. PyErr_SetString(PyExc_RuntimeError,
  5815. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  5816. #else
  5817. long val;
  5818. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  5819. #if PY_MAJOR_VERSION < 3
  5820. if (likely(v) && !PyLong_Check(v)) {
  5821. PyObject *tmp = v;
  5822. v = PyNumber_Long(tmp);
  5823. Py_DECREF(tmp);
  5824. }
  5825. #endif
  5826. if (likely(v)) {
  5827. int one = 1; int is_little = (int)*(unsigned char *)&one;
  5828. unsigned char *bytes = (unsigned char *)&val;
  5829. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  5830. bytes, sizeof(val),
  5831. is_little, !is_unsigned);
  5832. Py_DECREF(v);
  5833. if (likely(!ret))
  5834. return val;
  5835. }
  5836. #endif
  5837. return (long) -1;
  5838. }
  5839. } else {
  5840. long val;
  5841. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  5842. if (!tmp) return (long) -1;
  5843. val = __Pyx_PyInt_As_long(tmp);
  5844. Py_DECREF(tmp);
  5845. return val;
  5846. }
  5847. raise_overflow:
  5848. PyErr_SetString(PyExc_OverflowError,
  5849. "value too large to convert to long");
  5850. return (long) -1;
  5851. raise_neg_overflow:
  5852. PyErr_SetString(PyExc_OverflowError,
  5853. "can't convert negative value to long");
  5854. return (long) -1;
  5855. }
  5856. /* FastTypeChecks */
  5857. #if CYTHON_COMPILING_IN_CPYTHON
  5858. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  5859. while (a) {
  5860. a = a->tp_base;
  5861. if (a == b)
  5862. return 1;
  5863. }
  5864. return b == &PyBaseObject_Type;
  5865. }
  5866. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  5867. PyObject *mro;
  5868. if (a == b) return 1;
  5869. mro = a->tp_mro;
  5870. if (likely(mro)) {
  5871. Py_ssize_t i, n;
  5872. n = PyTuple_GET_SIZE(mro);
  5873. for (i = 0; i < n; i++) {
  5874. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  5875. return 1;
  5876. }
  5877. return 0;
  5878. }
  5879. return __Pyx_InBases(a, b);
  5880. }
  5881. #if PY_MAJOR_VERSION == 2
  5882. static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
  5883. PyObject *exception, *value, *tb;
  5884. int res;
  5885. __Pyx_PyThreadState_declare
  5886. __Pyx_PyThreadState_assign
  5887. __Pyx_ErrFetch(&exception, &value, &tb);
  5888. res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
  5889. if (unlikely(res == -1)) {
  5890. PyErr_WriteUnraisable(err);
  5891. res = 0;
  5892. }
  5893. if (!res) {
  5894. res = PyObject_IsSubclass(err, exc_type2);
  5895. if (unlikely(res == -1)) {
  5896. PyErr_WriteUnraisable(err);
  5897. res = 0;
  5898. }
  5899. }
  5900. __Pyx_ErrRestore(exception, value, tb);
  5901. return res;
  5902. }
  5903. #else
  5904. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  5905. int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
  5906. if (!res) {
  5907. res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  5908. }
  5909. return res;
  5910. }
  5911. #endif
  5912. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  5913. Py_ssize_t i, n;
  5914. assert(PyExceptionClass_Check(exc_type));
  5915. n = PyTuple_GET_SIZE(tuple);
  5916. #if PY_MAJOR_VERSION >= 3
  5917. for (i=0; i<n; i++) {
  5918. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  5919. }
  5920. #endif
  5921. for (i=0; i<n; i++) {
  5922. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  5923. #if PY_MAJOR_VERSION < 3
  5924. if (likely(exc_type == t)) return 1;
  5925. #endif
  5926. if (likely(PyExceptionClass_Check(t))) {
  5927. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  5928. } else {
  5929. }
  5930. }
  5931. return 0;
  5932. }
  5933. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  5934. if (likely(err == exc_type)) return 1;
  5935. if (likely(PyExceptionClass_Check(err))) {
  5936. if (likely(PyExceptionClass_Check(exc_type))) {
  5937. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  5938. } else if (likely(PyTuple_Check(exc_type))) {
  5939. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  5940. } else {
  5941. }
  5942. }
  5943. return PyErr_GivenExceptionMatches(err, exc_type);
  5944. }
  5945. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  5946. assert(PyExceptionClass_Check(exc_type1));
  5947. assert(PyExceptionClass_Check(exc_type2));
  5948. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  5949. if (likely(PyExceptionClass_Check(err))) {
  5950. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  5951. }
  5952. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  5953. }
  5954. #endif
  5955. /* CheckBinaryVersion */
  5956. static int __Pyx_check_binary_version(void) {
  5957. char ctversion[4], rtversion[4];
  5958. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  5959. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  5960. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  5961. char message[200];
  5962. PyOS_snprintf(message, sizeof(message),
  5963. "compiletime version %s of module '%.100s' "
  5964. "does not match runtime version %s",
  5965. ctversion, __Pyx_MODULE_NAME, rtversion);
  5966. return PyErr_WarnEx(NULL, message, 1);
  5967. }
  5968. return 0;
  5969. }
  5970. /* InitStrings */
  5971. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  5972. while (t->p) {
  5973. #if PY_MAJOR_VERSION < 3
  5974. if (t->is_unicode) {
  5975. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  5976. } else if (t->intern) {
  5977. *t->p = PyString_InternFromString(t->s);
  5978. } else {
  5979. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  5980. }
  5981. #else
  5982. if (t->is_unicode | t->is_str) {
  5983. if (t->intern) {
  5984. *t->p = PyUnicode_InternFromString(t->s);
  5985. } else if (t->encoding) {
  5986. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  5987. } else {
  5988. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  5989. }
  5990. } else {
  5991. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  5992. }
  5993. #endif
  5994. if (!*t->p)
  5995. return -1;
  5996. if (PyObject_Hash(*t->p) == -1)
  5997. return -1;
  5998. ++t;
  5999. }
  6000. return 0;
  6001. }
  6002. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  6003. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  6004. }
  6005. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  6006. Py_ssize_t ignore;
  6007. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  6008. }
  6009. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  6010. #if !CYTHON_PEP393_ENABLED
  6011. static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  6012. char* defenc_c;
  6013. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  6014. if (!defenc) return NULL;
  6015. defenc_c = PyBytes_AS_STRING(defenc);
  6016. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  6017. {
  6018. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  6019. char* c;
  6020. for (c = defenc_c; c < end; c++) {
  6021. if ((unsigned char) (*c) >= 128) {
  6022. PyUnicode_AsASCIIString(o);
  6023. return NULL;
  6024. }
  6025. }
  6026. }
  6027. #endif
  6028. *length = PyBytes_GET_SIZE(defenc);
  6029. return defenc_c;
  6030. }
  6031. #else
  6032. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  6033. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  6034. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  6035. if (likely(PyUnicode_IS_ASCII(o))) {
  6036. *length = PyUnicode_GET_LENGTH(o);
  6037. return PyUnicode_AsUTF8(o);
  6038. } else {
  6039. PyUnicode_AsASCIIString(o);
  6040. return NULL;
  6041. }
  6042. #else
  6043. return PyUnicode_AsUTF8AndSize(o, length);
  6044. #endif
  6045. }
  6046. #endif
  6047. #endif
  6048. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  6049. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  6050. if (
  6051. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  6052. __Pyx_sys_getdefaultencoding_not_ascii &&
  6053. #endif
  6054. PyUnicode_Check(o)) {
  6055. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  6056. } else
  6057. #endif
  6058. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  6059. if (PyByteArray_Check(o)) {
  6060. *length = PyByteArray_GET_SIZE(o);
  6061. return PyByteArray_AS_STRING(o);
  6062. } else
  6063. #endif
  6064. {
  6065. char* result;
  6066. int r = PyBytes_AsStringAndSize(o, &result, length);
  6067. if (unlikely(r < 0)) {
  6068. return NULL;
  6069. } else {
  6070. return result;
  6071. }
  6072. }
  6073. }
  6074. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  6075. int is_true = x == Py_True;
  6076. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  6077. else return PyObject_IsTrue(x);
  6078. }
  6079. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
  6080. int retval;
  6081. if (unlikely(!x)) return -1;
  6082. retval = __Pyx_PyObject_IsTrue(x);
  6083. Py_DECREF(x);
  6084. return retval;
  6085. }
  6086. static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
  6087. #if PY_MAJOR_VERSION >= 3
  6088. if (PyLong_Check(result)) {
  6089. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  6090. "__int__ returned non-int (type %.200s). "
  6091. "The ability to return an instance of a strict subclass of int "
  6092. "is deprecated, and may be removed in a future version of Python.",
  6093. Py_TYPE(result)->tp_name)) {
  6094. Py_DECREF(result);
  6095. return NULL;
  6096. }
  6097. return result;
  6098. }
  6099. #endif
  6100. PyErr_Format(PyExc_TypeError,
  6101. "__%.4s__ returned non-%.4s (type %.200s)",
  6102. type_name, type_name, Py_TYPE(result)->tp_name);
  6103. Py_DECREF(result);
  6104. return NULL;
  6105. }
  6106. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  6107. #if CYTHON_USE_TYPE_SLOTS
  6108. PyNumberMethods *m;
  6109. #endif
  6110. const char *name = NULL;
  6111. PyObject *res = NULL;
  6112. #if PY_MAJOR_VERSION < 3
  6113. if (likely(PyInt_Check(x) || PyLong_Check(x)))
  6114. #else
  6115. if (likely(PyLong_Check(x)))
  6116. #endif
  6117. return __Pyx_NewRef(x);
  6118. #if CYTHON_USE_TYPE_SLOTS
  6119. m = Py_TYPE(x)->tp_as_number;
  6120. #if PY_MAJOR_VERSION < 3
  6121. if (m && m->nb_int) {
  6122. name = "int";
  6123. res = m->nb_int(x);
  6124. }
  6125. else if (m && m->nb_long) {
  6126. name = "long";
  6127. res = m->nb_long(x);
  6128. }
  6129. #else
  6130. if (likely(m && m->nb_int)) {
  6131. name = "int";
  6132. res = m->nb_int(x);
  6133. }
  6134. #endif
  6135. #else
  6136. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  6137. res = PyNumber_Int(x);
  6138. }
  6139. #endif
  6140. if (likely(res)) {
  6141. #if PY_MAJOR_VERSION < 3
  6142. if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
  6143. #else
  6144. if (unlikely(!PyLong_CheckExact(res))) {
  6145. #endif
  6146. return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
  6147. }
  6148. }
  6149. else if (!PyErr_Occurred()) {
  6150. PyErr_SetString(PyExc_TypeError,
  6151. "an integer is required");
  6152. }
  6153. return res;
  6154. }
  6155. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  6156. Py_ssize_t ival;
  6157. PyObject *x;
  6158. #if PY_MAJOR_VERSION < 3
  6159. if (likely(PyInt_CheckExact(b))) {
  6160. if (sizeof(Py_ssize_t) >= sizeof(long))
  6161. return PyInt_AS_LONG(b);
  6162. else
  6163. return PyInt_AsSsize_t(b);
  6164. }
  6165. #endif
  6166. if (likely(PyLong_CheckExact(b))) {
  6167. #if CYTHON_USE_PYLONG_INTERNALS
  6168. const digit* digits = ((PyLongObject*)b)->ob_digit;
  6169. const Py_ssize_t size = Py_SIZE(b);
  6170. if (likely(__Pyx_sst_abs(size) <= 1)) {
  6171. ival = likely(size) ? digits[0] : 0;
  6172. if (size == -1) ival = -ival;
  6173. return ival;
  6174. } else {
  6175. switch (size) {
  6176. case 2:
  6177. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  6178. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  6179. }
  6180. break;
  6181. case -2:
  6182. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  6183. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  6184. }
  6185. break;
  6186. case 3:
  6187. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  6188. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  6189. }
  6190. break;
  6191. case -3:
  6192. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  6193. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  6194. }
  6195. break;
  6196. case 4:
  6197. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  6198. 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]));
  6199. }
  6200. break;
  6201. case -4:
  6202. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  6203. 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]));
  6204. }
  6205. break;
  6206. }
  6207. }
  6208. #endif
  6209. return PyLong_AsSsize_t(b);
  6210. }
  6211. x = PyNumber_Index(b);
  6212. if (!x) return -1;
  6213. ival = PyInt_AsSsize_t(x);
  6214. Py_DECREF(x);
  6215. return ival;
  6216. }
  6217. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  6218. return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
  6219. }
  6220. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  6221. return PyInt_FromSize_t(ival);
  6222. }
  6223. #endif /* Py_PYTHON_H */